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/diff-model.ts
ADDED
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
import { diffChars, diffWordsWithSpace, lineDiff } from "diff";
|
|
2
|
+
|
|
3
|
+
import type { TextMutationPreviewRange } from "pi-agent-text-editor/api/mutation-preview";
|
|
4
|
+
|
|
5
|
+
export const DIFF_CONTEXT_LINES = 2;
|
|
6
|
+
|
|
7
|
+
export type DiffRowKind = "context" | "modified" | "added" | "removed" | "omitted";
|
|
8
|
+
|
|
9
|
+
export interface DiffTextRange
|
|
10
|
+
{
|
|
11
|
+
readonly from: number;
|
|
12
|
+
readonly to: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface DiffRow
|
|
16
|
+
{
|
|
17
|
+
readonly kind: DiffRowKind;
|
|
18
|
+
readonly text: string;
|
|
19
|
+
readonly beforeLine?: number;
|
|
20
|
+
readonly afterLine?: number;
|
|
21
|
+
readonly changed: boolean;
|
|
22
|
+
readonly addedRanges?: readonly DiffTextRange[];
|
|
23
|
+
readonly omitted?: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface DiffModel
|
|
27
|
+
{
|
|
28
|
+
readonly rows: readonly DiffRow[];
|
|
29
|
+
readonly added: number;
|
|
30
|
+
readonly modified: number;
|
|
31
|
+
readonly removed: number;
|
|
32
|
+
readonly focusRow: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface NumberedLine
|
|
36
|
+
{
|
|
37
|
+
readonly text: string;
|
|
38
|
+
readonly line: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface HunkWindow
|
|
42
|
+
{
|
|
43
|
+
readonly start: number;
|
|
44
|
+
readonly end: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const LINE_PAIR_THRESHOLD = 0.5;
|
|
48
|
+
|
|
49
|
+
const NON_SEMANTIC_TOKENS = new Set([
|
|
50
|
+
"async",
|
|
51
|
+
"boolean",
|
|
52
|
+
"const",
|
|
53
|
+
"export",
|
|
54
|
+
"false",
|
|
55
|
+
"function",
|
|
56
|
+
"interface",
|
|
57
|
+
"let",
|
|
58
|
+
"new",
|
|
59
|
+
"null",
|
|
60
|
+
"number",
|
|
61
|
+
"private",
|
|
62
|
+
"protected",
|
|
63
|
+
"public",
|
|
64
|
+
"readonly",
|
|
65
|
+
"return",
|
|
66
|
+
"static",
|
|
67
|
+
"string",
|
|
68
|
+
"true",
|
|
69
|
+
"type",
|
|
70
|
+
"undefined",
|
|
71
|
+
"var",
|
|
72
|
+
]);
|
|
73
|
+
|
|
74
|
+
export interface DiffModelOptions
|
|
75
|
+
{
|
|
76
|
+
readonly beforeLineOffset?: number;
|
|
77
|
+
readonly afterLineOffset?: number;
|
|
78
|
+
readonly project?: boolean;
|
|
79
|
+
readonly focusAfterLine?: number;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function createDiffModel(
|
|
83
|
+
beforeContent: string,
|
|
84
|
+
afterContent: string,
|
|
85
|
+
ranges: readonly TextMutationPreviewRange[] = [],
|
|
86
|
+
options: DiffModelOptions = {},
|
|
87
|
+
): DiffModel
|
|
88
|
+
{
|
|
89
|
+
const fullRows = createSemanticRows(
|
|
90
|
+
beforeContent,
|
|
91
|
+
afterContent,
|
|
92
|
+
(options.beforeLineOffset ?? 0) + 1,
|
|
93
|
+
(options.afterLineOffset ?? 0) + 1,
|
|
94
|
+
);
|
|
95
|
+
const rows = options.project === false ? fullRows : projectHunks(fullRows);
|
|
96
|
+
const latestAfterLine = options.focusAfterLine ?? (ranges.length === 0
|
|
97
|
+
? undefined
|
|
98
|
+
: lineAtOffset(afterContent, ranges.at(-1)!.to) + (options.afterLineOffset ?? 0));
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
rows,
|
|
102
|
+
added: fullRows.filter(({ kind }) => kind === "added").length,
|
|
103
|
+
modified: fullRows.filter(({ kind }) => kind === "modified").length,
|
|
104
|
+
removed: fullRows.filter(({ kind }) => kind === "removed").length,
|
|
105
|
+
focusRow: findFocusRow(rows, latestAfterLine),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function createSemanticRows(
|
|
110
|
+
beforeContent: string,
|
|
111
|
+
afterContent: string,
|
|
112
|
+
beforeStartLine = 1,
|
|
113
|
+
afterStartLine = 1,
|
|
114
|
+
): readonly DiffRow[]
|
|
115
|
+
{
|
|
116
|
+
const rows: DiffRow[] = [];
|
|
117
|
+
const parts = lineDiff.diff(beforeContent, afterContent, {
|
|
118
|
+
comparator: sameLineIgnoringEdgeWhitespace,
|
|
119
|
+
timeout: 100,
|
|
120
|
+
maxEditLength: 20_000,
|
|
121
|
+
}) ?? [];
|
|
122
|
+
let beforeLine = beforeStartLine;
|
|
123
|
+
let afterLine = afterStartLine;
|
|
124
|
+
|
|
125
|
+
for (let index = 0; index < parts.length;)
|
|
126
|
+
{
|
|
127
|
+
const part = parts[index]!;
|
|
128
|
+
|
|
129
|
+
if (!part.added && !part.removed)
|
|
130
|
+
{
|
|
131
|
+
for (const text of splitPart(part.value))
|
|
132
|
+
{
|
|
133
|
+
rows.push({ kind: "context", text, beforeLine: beforeLine++, afterLine: afterLine++, changed: false });
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
index++;
|
|
137
|
+
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const removed: NumberedLine[] = [];
|
|
142
|
+
const added: NumberedLine[] = [];
|
|
143
|
+
|
|
144
|
+
while (index < parts.length && (parts[index]!.added || parts[index]!.removed))
|
|
145
|
+
{
|
|
146
|
+
const changedPart = parts[index]!;
|
|
147
|
+
|
|
148
|
+
if (changedPart.removed)
|
|
149
|
+
{
|
|
150
|
+
for (const text of splitPart(changedPart.value))
|
|
151
|
+
{
|
|
152
|
+
removed.push({ text, line: beforeLine++ });
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
else
|
|
156
|
+
{
|
|
157
|
+
for (const text of splitPart(changedPart.value))
|
|
158
|
+
{
|
|
159
|
+
added.push({ text, line: afterLine++ });
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
index++;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
rows.push(...alignChangedLines(removed, added));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return rows;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function sameLineIgnoringEdgeWhitespace(before: unknown, after: unknown): boolean
|
|
173
|
+
{
|
|
174
|
+
return typeof before === "string"
|
|
175
|
+
&& typeof after === "string"
|
|
176
|
+
&& normalizedLineToken(before) === normalizedLineToken(after);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function normalizedLineToken(value: string): string
|
|
180
|
+
{
|
|
181
|
+
const newline = value.endsWith("\r\n") ? "\r\n" : value.endsWith("\n") ? "\n" : "";
|
|
182
|
+
return value.slice(0, value.length - newline.length).trim() + newline;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function alignChangedLines(removed: readonly NumberedLine[], added: readonly NumberedLine[]): readonly DiffRow[]
|
|
186
|
+
{
|
|
187
|
+
if (removed.length === 1 && added.length === 1)
|
|
188
|
+
{
|
|
189
|
+
return [modifiedRow(removed[0]!, added[0]!)];
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const scores = Array.from(
|
|
193
|
+
{ length: removed.length + 1 },
|
|
194
|
+
() => Array.from<number>({ length: added.length + 1 }).fill(0),
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
for (let oldIndex = 1; oldIndex <= removed.length; oldIndex++)
|
|
198
|
+
{
|
|
199
|
+
for (let newIndex = 1; newIndex <= added.length; newIndex++)
|
|
200
|
+
{
|
|
201
|
+
const similarity = lineSimilarity(removed[oldIndex - 1]!.text, added[newIndex - 1]!.text);
|
|
202
|
+
const pair = similarity >= LINE_PAIR_THRESHOLD
|
|
203
|
+
? scores[oldIndex - 1]![newIndex - 1]! + similarity
|
|
204
|
+
: Number.NEGATIVE_INFINITY;
|
|
205
|
+
scores[oldIndex]![newIndex] = Math.max(
|
|
206
|
+
scores[oldIndex - 1]![newIndex]!,
|
|
207
|
+
scores[oldIndex]![newIndex - 1]!,
|
|
208
|
+
pair,
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const reversed: DiffRow[] = [];
|
|
214
|
+
let oldIndex = removed.length;
|
|
215
|
+
let newIndex = added.length;
|
|
216
|
+
|
|
217
|
+
while (oldIndex > 0 || newIndex > 0)
|
|
218
|
+
{
|
|
219
|
+
const similarity = oldIndex > 0 && newIndex > 0
|
|
220
|
+
? lineSimilarity(removed[oldIndex - 1]!.text, added[newIndex - 1]!.text)
|
|
221
|
+
: 0;
|
|
222
|
+
const pairScore = oldIndex > 0 && newIndex > 0 && similarity >= LINE_PAIR_THRESHOLD
|
|
223
|
+
? scores[oldIndex - 1]![newIndex - 1]! + similarity
|
|
224
|
+
: Number.NEGATIVE_INFINITY;
|
|
225
|
+
|
|
226
|
+
if (pairScore === scores[oldIndex]![newIndex])
|
|
227
|
+
{
|
|
228
|
+
reversed.push(modifiedRow(removed[oldIndex - 1]!, added[newIndex - 1]!));
|
|
229
|
+
oldIndex--;
|
|
230
|
+
newIndex--;
|
|
231
|
+
}
|
|
232
|
+
else if (
|
|
233
|
+
newIndex > 0
|
|
234
|
+
&& scores[oldIndex]![newIndex - 1]!
|
|
235
|
+
>= (oldIndex > 0 ? scores[oldIndex - 1]![newIndex]! : Number.NEGATIVE_INFINITY)
|
|
236
|
+
)
|
|
237
|
+
{
|
|
238
|
+
const line = added[newIndex - 1]!;
|
|
239
|
+
reversed.push({ kind: "added", text: line.text, afterLine: line.line, changed: true });
|
|
240
|
+
newIndex--;
|
|
241
|
+
}
|
|
242
|
+
else
|
|
243
|
+
{
|
|
244
|
+
const line = removed[oldIndex - 1]!;
|
|
245
|
+
reversed.push({ kind: "removed", text: line.text, beforeLine: line.line, changed: true });
|
|
246
|
+
oldIndex--;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return reversed.reverse();
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function modifiedRow(before: NumberedLine, after: NumberedLine): DiffRow
|
|
254
|
+
{
|
|
255
|
+
return {
|
|
256
|
+
kind: "modified",
|
|
257
|
+
text: after.text,
|
|
258
|
+
beforeLine: before.line,
|
|
259
|
+
afterLine: after.line,
|
|
260
|
+
changed: true,
|
|
261
|
+
addedRanges: changedTextRanges(before.text, after.text),
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function changedTextRanges(before: string, after: string): readonly DiffTextRange[]
|
|
266
|
+
{
|
|
267
|
+
const ranges: DiffTextRange[] = [];
|
|
268
|
+
const parts = diffWordsWithSpace(before, after, { timeout: 50, maxEditLength: 5_000 }) ?? diffChars(before, after);
|
|
269
|
+
let offset = 0;
|
|
270
|
+
|
|
271
|
+
for (const part of parts)
|
|
272
|
+
{
|
|
273
|
+
if (part.removed)
|
|
274
|
+
{
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (part.added && part.value.length > 0)
|
|
279
|
+
{
|
|
280
|
+
let from = offset;
|
|
281
|
+
let to = offset + part.value.length;
|
|
282
|
+
|
|
283
|
+
if (from === 0)
|
|
284
|
+
{
|
|
285
|
+
from += part.value.length - part.value.trimStart().length;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (to === after.length)
|
|
289
|
+
{
|
|
290
|
+
to -= part.value.length - part.value.trimEnd().length;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (from < to)
|
|
294
|
+
{
|
|
295
|
+
ranges.push({ from, to });
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
offset += part.value.length;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return ranges;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function lineSimilarity(before: string, after: string): number
|
|
306
|
+
{
|
|
307
|
+
const characterScore = characterSimilarity(before, after);
|
|
308
|
+
const beforeTokens = semanticTokens(before);
|
|
309
|
+
const afterTokens = semanticTokens(after);
|
|
310
|
+
|
|
311
|
+
if (beforeTokens.length === 0 && afterTokens.length === 0)
|
|
312
|
+
{
|
|
313
|
+
return characterScore;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
const tokenScore = (
|
|
317
|
+
directionalTokenSimilarity(beforeTokens, afterTokens)
|
|
318
|
+
+ directionalTokenSimilarity(afterTokens, beforeTokens)
|
|
319
|
+
) / 2;
|
|
320
|
+
return characterScore * 0.35 + tokenScore * 0.65;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function semanticTokens(line: string): readonly string[]
|
|
324
|
+
{
|
|
325
|
+
return (line.toLowerCase().match(/[\p{L}\p{N}_$]+/gu) ?? [])
|
|
326
|
+
.filter((token) => !NON_SEMANTIC_TOKENS.has(token));
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function directionalTokenSimilarity(source: readonly string[], target: readonly string[]): number
|
|
330
|
+
{
|
|
331
|
+
if (source.length === 0 || target.length === 0)
|
|
332
|
+
{
|
|
333
|
+
return 0;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
return source.reduce(
|
|
337
|
+
(total, token) => total + Math.max(...target.map((candidate) => characterSimilarity(token, candidate))),
|
|
338
|
+
0,
|
|
339
|
+
) / source.length;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function characterSimilarity(before: string, after: string): number
|
|
343
|
+
{
|
|
344
|
+
const longest = Math.max(before.length, after.length);
|
|
345
|
+
|
|
346
|
+
if (longest === 0)
|
|
347
|
+
{
|
|
348
|
+
return 1;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
const unchanged = diffChars(before, after, { timeout: 25, maxEditLength: 2_000 })
|
|
352
|
+
?.filter((part) => !part.added && !part.removed)
|
|
353
|
+
.reduce((length, part) => length + part.value.length, 0) ?? 0;
|
|
354
|
+
return unchanged / longest;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function projectHunks(rows: readonly DiffRow[]): readonly DiffRow[]
|
|
358
|
+
{
|
|
359
|
+
const windows: HunkWindow[] = [];
|
|
360
|
+
|
|
361
|
+
for (let index = 0; index < rows.length; index++)
|
|
362
|
+
{
|
|
363
|
+
if (!rows[index]!.changed)
|
|
364
|
+
{
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
const changedStart = index;
|
|
369
|
+
|
|
370
|
+
while (index + 1 < rows.length && rows[index + 1]!.changed)
|
|
371
|
+
{
|
|
372
|
+
index++;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
const next = {
|
|
376
|
+
start: Math.max(0, changedStart - DIFF_CONTEXT_LINES),
|
|
377
|
+
end: Math.min(rows.length - 1, index + DIFF_CONTEXT_LINES),
|
|
378
|
+
};
|
|
379
|
+
const previous = windows.at(-1);
|
|
380
|
+
|
|
381
|
+
if (previous !== undefined && next.start <= previous.end + 1)
|
|
382
|
+
{
|
|
383
|
+
windows[windows.length - 1] = { start: previous.start, end: Math.max(previous.end, next.end) };
|
|
384
|
+
}
|
|
385
|
+
else
|
|
386
|
+
{
|
|
387
|
+
windows.push(next);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
return windows.flatMap((window, index) =>
|
|
392
|
+
{
|
|
393
|
+
const previous = windows[index - 1];
|
|
394
|
+
const omitted = previous === undefined ? [] : [omittedRow(window.start - previous.end - 1)];
|
|
395
|
+
return [...omitted, ...rows.slice(window.start, window.end + 1)];
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
function omittedRow(count: number): DiffRow
|
|
400
|
+
{
|
|
401
|
+
return { kind: "omitted", text: "", changed: false, omitted: count };
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
function splitPart(value: string): readonly string[]
|
|
405
|
+
{
|
|
406
|
+
if (value.length === 0)
|
|
407
|
+
{
|
|
408
|
+
return [];
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
const normalized = value.replaceAll("\r\n", "\n");
|
|
412
|
+
const lines = normalized.split("\n");
|
|
413
|
+
|
|
414
|
+
if (normalized.endsWith("\n"))
|
|
415
|
+
{
|
|
416
|
+
lines.pop();
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
return lines;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
function lineAtOffset(content: string, offset: number): number
|
|
423
|
+
{
|
|
424
|
+
let line = 1;
|
|
425
|
+
|
|
426
|
+
for (let index = 0; index < Math.min(offset, content.length); index++)
|
|
427
|
+
{
|
|
428
|
+
if (content[index] === "\n")
|
|
429
|
+
{
|
|
430
|
+
line++;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
return line;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
function findFocusRow(rows: readonly DiffRow[], latestAfterLine: number | undefined): number
|
|
438
|
+
{
|
|
439
|
+
if (latestAfterLine !== undefined)
|
|
440
|
+
{
|
|
441
|
+
const exact = rows.findLastIndex((row) =>
|
|
442
|
+
row.afterLine !== undefined && row.afterLine <= latestAfterLine && row.changed
|
|
443
|
+
);
|
|
444
|
+
|
|
445
|
+
if (exact !== -1)
|
|
446
|
+
{
|
|
447
|
+
return exact;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
return Math.max(0, rows.findLastIndex((row) => row.changed));
|
|
452
|
+
}
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { keyHint, type Theme } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
3
|
+
|
|
4
|
+
import { createDiffThemePalette, type DiffThemePalette, type DiffThemeTone } from "./diff-theme.js";
|
|
5
|
+
import { compactViewport, expandedViewport, type ViewportRow } from "./diff-viewport.js";
|
|
6
|
+
|
|
7
|
+
import type { DiffModel, DiffRow, DiffTextRange } from "./diff-model.js";
|
|
8
|
+
|
|
9
|
+
export interface DiffPanelResource
|
|
10
|
+
{
|
|
11
|
+
readonly path: string;
|
|
12
|
+
readonly link?: string;
|
|
13
|
+
readonly model: DiffModel;
|
|
14
|
+
readonly highlightedRows: ReadonlyMap<DiffRow, string>;
|
|
15
|
+
readonly cursor?: { readonly line: number; readonly column: number; };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function renderDiffPanel(
|
|
19
|
+
resource: DiffPanelResource,
|
|
20
|
+
width: number,
|
|
21
|
+
theme: Theme,
|
|
22
|
+
expanded: boolean,
|
|
23
|
+
pending: boolean,
|
|
24
|
+
): string[]
|
|
25
|
+
{
|
|
26
|
+
const panelWidth = Math.max(20, width);
|
|
27
|
+
const innerWidth = panelWidth - 2;
|
|
28
|
+
const palette = createDiffThemePalette(theme, pending);
|
|
29
|
+
const styleFrame = (text: string): string => theme.fg("borderMuted", text);
|
|
30
|
+
const lines = [styleFrame(border("╭", "─", "╮", innerWidth))];
|
|
31
|
+
const viewport = expanded ? expandedViewport(resource.model) : compactViewport(resource.model);
|
|
32
|
+
let greatestLine = 0;
|
|
33
|
+
|
|
34
|
+
for (const row of resource.model.rows)
|
|
35
|
+
{
|
|
36
|
+
greatestLine = Math.max(greatestLine, row.beforeLine ?? 0, row.afterLine ?? 0);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const gutterWidth = Math.max(3, String(greatestLine).length);
|
|
40
|
+
let expandHintShown = false;
|
|
41
|
+
|
|
42
|
+
for (const row of viewport)
|
|
43
|
+
{
|
|
44
|
+
const showExpandHint: boolean = !expanded && row.omitted !== undefined && !expandHintShown;
|
|
45
|
+
|
|
46
|
+
if (showExpandHint)
|
|
47
|
+
{
|
|
48
|
+
expandHintShown = true;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const tone = diffTone(row.row?.kind, palette);
|
|
52
|
+
const background = tone === undefined
|
|
53
|
+
? undefined
|
|
54
|
+
: (text: string) => withBackground(tone.background, text, palette.restoreBackground);
|
|
55
|
+
lines.push(framed(
|
|
56
|
+
renderRow(row, resource, gutterWidth, theme, palette, showExpandHint),
|
|
57
|
+
innerWidth,
|
|
58
|
+
styleFrame,
|
|
59
|
+
background,
|
|
60
|
+
));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
lines.push(styleFrame(border("╰", "─", "╯", innerWidth)));
|
|
64
|
+
return lines.map((line) => truncateToWidth(line, panelWidth));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function renderRow(
|
|
68
|
+
item: ViewportRow,
|
|
69
|
+
resource: DiffPanelResource,
|
|
70
|
+
gutterWidth: number,
|
|
71
|
+
theme: Theme,
|
|
72
|
+
palette: DiffThemePalette,
|
|
73
|
+
showExpandHint: boolean,
|
|
74
|
+
): string
|
|
75
|
+
{
|
|
76
|
+
const omitted = item.omitted ?? item.row?.omitted;
|
|
77
|
+
|
|
78
|
+
if (omitted !== undefined)
|
|
79
|
+
{
|
|
80
|
+
const summary = withForeground(palette.contextForeground, ` ··· ${String(omitted)} lines omitted`);
|
|
81
|
+
return showExpandHint
|
|
82
|
+
? `${summary}${withForeground(palette.contextForeground, " · ")}${
|
|
83
|
+
keyHint("app.tools.expand", "to expand")
|
|
84
|
+
}${withForeground(palette.contextForeground, " ···")}`
|
|
85
|
+
: `${summary}${withForeground(palette.contextForeground, " ···")}`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (item.row === undefined)
|
|
89
|
+
{
|
|
90
|
+
return "";
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const row = item.row;
|
|
94
|
+
const number = String(row.kind === "removed" ? row.beforeLine ?? "" : row.afterLine ?? "").padStart(gutterWidth);
|
|
95
|
+
const marker = row.kind === "added" ? "+" : row.kind === "removed" ? "-" : row.kind === "modified" ? "~" : " ";
|
|
96
|
+
const gutter = `${number} ${marker} `;
|
|
97
|
+
const tone = diffTone(row.kind, palette);
|
|
98
|
+
const styledGutter = withForeground(tone?.foreground ?? palette.contextForeground, gutter);
|
|
99
|
+
let content = resource.highlightedRows.get(row) ?? row.text.replaceAll("\t", " ");
|
|
100
|
+
|
|
101
|
+
if (row.kind === "modified")
|
|
102
|
+
{
|
|
103
|
+
content = highlightRanges(content, row.text, row.addedRanges ?? [], palette.modified);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const cursor = resource.cursor;
|
|
107
|
+
|
|
108
|
+
if (cursor !== undefined && cursor.line === row.afterLine && row.kind !== "removed")
|
|
109
|
+
{
|
|
110
|
+
content = insertCursor(content, expandedOffset(row.text, cursor.column), theme.fg("accent", "▌"));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return `${styledGutter}${content}`;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function diffTone(kind: DiffRow["kind"] | undefined, palette: DiffThemePalette): DiffThemeTone | undefined
|
|
117
|
+
{
|
|
118
|
+
return kind === "added"
|
|
119
|
+
? palette.added
|
|
120
|
+
: kind === "removed"
|
|
121
|
+
? palette.removed
|
|
122
|
+
: kind === "modified"
|
|
123
|
+
? palette.modified
|
|
124
|
+
: undefined;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function highlightRanges(
|
|
128
|
+
highlighted: string,
|
|
129
|
+
source: string,
|
|
130
|
+
ranges: readonly DiffTextRange[],
|
|
131
|
+
tone: DiffThemeTone,
|
|
132
|
+
): string
|
|
133
|
+
{
|
|
134
|
+
const expandedRanges = ranges.map(({ from, to }) => ({
|
|
135
|
+
from: expandedOffset(source, from),
|
|
136
|
+
to: expandedOffset(source, to),
|
|
137
|
+
}));
|
|
138
|
+
const changedBackground = tone.emphasisBackground;
|
|
139
|
+
const editingBackground = tone.background;
|
|
140
|
+
let rendered = "";
|
|
141
|
+
let sourceIndex = 0;
|
|
142
|
+
let visibleOffset = 0;
|
|
143
|
+
let rangeIndex = 0;
|
|
144
|
+
let highlighting = false;
|
|
145
|
+
|
|
146
|
+
while (sourceIndex < highlighted.length)
|
|
147
|
+
{
|
|
148
|
+
const ansi = ansiSequenceAt(highlighted, sourceIndex);
|
|
149
|
+
|
|
150
|
+
if (ansi !== undefined)
|
|
151
|
+
{
|
|
152
|
+
rendered += ansi;
|
|
153
|
+
|
|
154
|
+
if (highlighting)
|
|
155
|
+
{
|
|
156
|
+
rendered += changedBackground;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
sourceIndex += ansi.length;
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (highlighting && expandedRanges[rangeIndex]?.to === visibleOffset)
|
|
164
|
+
{
|
|
165
|
+
rendered += editingBackground;
|
|
166
|
+
highlighting = false;
|
|
167
|
+
rangeIndex++;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (!highlighting && expandedRanges[rangeIndex]?.from === visibleOffset)
|
|
171
|
+
{
|
|
172
|
+
rendered += changedBackground;
|
|
173
|
+
highlighting = true;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
rendered += highlighted[sourceIndex]!;
|
|
177
|
+
sourceIndex++;
|
|
178
|
+
visibleOffset++;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (highlighting)
|
|
182
|
+
{
|
|
183
|
+
rendered += editingBackground;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return rendered;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function ansiSequenceAt(text: string, index: number): string | undefined
|
|
190
|
+
{
|
|
191
|
+
if (text[index] !== "\u001B" || text[index + 1] !== "[")
|
|
192
|
+
{
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
for (let end = index + 2; end < text.length; end++)
|
|
197
|
+
{
|
|
198
|
+
const code = text.codePointAt(end)!;
|
|
199
|
+
|
|
200
|
+
if (code >= 0x40 && code <= 0x7E)
|
|
201
|
+
{
|
|
202
|
+
return text.slice(index, end + 1);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return undefined;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function insertCursor(text: string, offset: number, cursor: string): string
|
|
210
|
+
{
|
|
211
|
+
let visibleOffset = 0;
|
|
212
|
+
|
|
213
|
+
for (let index = 0; index < text.length;)
|
|
214
|
+
{
|
|
215
|
+
if (visibleOffset === offset)
|
|
216
|
+
{
|
|
217
|
+
return `${text.slice(0, index)}${cursor}${text.slice(index)}`;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const ansi = ansiSequenceAt(text, index);
|
|
221
|
+
|
|
222
|
+
if (ansi === undefined)
|
|
223
|
+
{
|
|
224
|
+
index++;
|
|
225
|
+
visibleOffset++;
|
|
226
|
+
}
|
|
227
|
+
else
|
|
228
|
+
{
|
|
229
|
+
index += ansi.length;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return `${text}${cursor}`;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function expandedOffset(text: string, offset: number): number
|
|
237
|
+
{
|
|
238
|
+
return text.slice(0, offset).replaceAll("\t", " ").length;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function framed(
|
|
242
|
+
content: string,
|
|
243
|
+
width: number,
|
|
244
|
+
styleFrame: (text: string) => string,
|
|
245
|
+
background?: (text: string) => string,
|
|
246
|
+
): string
|
|
247
|
+
{
|
|
248
|
+
const clipped = truncateToWidth(` ${content}`, width);
|
|
249
|
+
const body = `${clipped}${" ".repeat(Math.max(0, width - visibleWidth(clipped)))}`;
|
|
250
|
+
return `${styleFrame("│")}${background?.(body) ?? body}${styleFrame("│")}`;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function withForeground(ansi: string, text: string): string
|
|
254
|
+
{
|
|
255
|
+
return `${ansi}${text}\u001B[39m`;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function withBackground(ansi: string, text: string, restoreBackground: string): string
|
|
259
|
+
{
|
|
260
|
+
return `${ansi}${text}${restoreBackground}`;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function border(left: string, fill: string, right: string, width: number): string
|
|
264
|
+
{
|
|
265
|
+
return `${left}${fill.repeat(width)}${right}`;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export function changedRows(model: DiffModel): readonly DiffRow[]
|
|
269
|
+
{
|
|
270
|
+
return model.rows.filter((row) => row.changed);
|
|
271
|
+
}
|