pi-agent-ide 0.1.0 → 0.1.1
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/README.md +31 -9
- package/docs/architecture.md +18 -6
- package/docs/configuration.md +70 -40
- package/docs/development.md +14 -2
- package/docs/extensions.md +132 -150
- package/docs/generated/tool-catalog/c.md +9 -0
- package/docs/generated/tool-catalog/cmake.md +9 -0
- package/docs/generated/tool-catalog/cpp.md +9 -0
- package/docs/generated/tool-catalog/csharp.md +9 -0
- package/docs/generated/tool-catalog/css.md +10 -0
- package/docs/generated/tool-catalog/dockerfile.md +9 -0
- package/docs/generated/tool-catalog/go.md +10 -0
- package/docs/generated/tool-catalog/html.md +9 -0
- package/docs/generated/tool-catalog/index.md +30 -0
- package/docs/generated/tool-catalog/java.md +9 -0
- package/docs/generated/tool-catalog/javascript.md +10 -0
- package/docs/generated/tool-catalog/json.md +10 -0
- package/docs/generated/tool-catalog/kotlin.md +9 -0
- package/docs/generated/tool-catalog/lua.md +9 -0
- package/docs/generated/tool-catalog/markdown.md +9 -0
- package/docs/generated/tool-catalog/php.md +9 -0
- package/docs/generated/tool-catalog/python.md +10 -0
- package/docs/generated/tool-catalog/ruby.md +9 -0
- package/docs/generated/tool-catalog/rust.md +9 -0
- package/docs/generated/tool-catalog/shell.md +9 -0
- package/docs/generated/tool-catalog/sql.md +9 -0
- package/docs/generated/tool-catalog/swift.md +9 -0
- package/docs/generated/tool-catalog/terraform.md +9 -0
- package/docs/generated/tool-catalog/toml.md +9 -0
- package/docs/generated/tool-catalog/typescript.md +10 -0
- package/docs/generated/tool-catalog/xml.md +9 -0
- package/docs/generated/tool-catalog/yaml.md +9 -0
- package/node_modules/pi-agent-doctor/package.json +26 -0
- package/node_modules/pi-agent-doctor/src/catalog.ts +55 -0
- package/node_modules/pi-agent-doctor/src/connect-plugin.ts +53 -0
- package/node_modules/pi-agent-doctor/src/executable.ts +47 -0
- package/node_modules/pi-agent-doctor/src/plugin-protocol.ts +121 -0
- package/node_modules/pi-agent-filesystem/index.ts +42 -44
- package/node_modules/pi-agent-filesystem/package.json +11 -11
- package/node_modules/pi-agent-filesystem/src/resolver.ts +112 -135
- package/node_modules/pi-agent-filesystem-image/index.ts +5 -6
- package/node_modules/pi-agent-filesystem-image/package.json +8 -8
- package/node_modules/pi-agent-filesystem-pdf/index.ts +5 -6
- package/node_modules/pi-agent-filesystem-pdf/package.json +5 -5
- package/node_modules/pi-agent-filesystem-text/index.ts +11 -12
- package/node_modules/pi-agent-filesystem-text/package.json +8 -8
- package/node_modules/pi-agent-ide-ast/index.ts +1 -1
- package/node_modules/pi-agent-ide-ast/package.json +13 -12
- package/node_modules/pi-agent-ide-ast/src/ast/collect-files.ts +11 -16
- package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +292 -322
- package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +591 -656
- package/node_modules/pi-agent-ide-ast/src/ast/read-text.ts +15 -19
- package/node_modules/pi-agent-ide-ast/src/doctor-plugin.ts +105 -0
- package/node_modules/pi-agent-ide-ast/src/extension.ts +67 -64
- package/node_modules/pi-agent-ide-ast/src/outline-resolver.ts +51 -54
- package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +168 -185
- package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +30 -36
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +118 -129
- package/node_modules/pi-agent-ide-changes/index.ts +53 -51
- package/node_modules/pi-agent-ide-changes/package.json +12 -11
- package/node_modules/pi-agent-ide-changes/src/change-anchor.ts +68 -78
- package/node_modules/pi-agent-ide-changes/src/changes/change-groups.ts +230 -245
- package/node_modules/pi-agent-ide-changes/src/changes/change-service.ts +189 -192
- package/node_modules/pi-agent-ide-changes/src/changes/change-types.ts +75 -79
- package/node_modules/pi-agent-ide-changes/src/changes/git-changes-backend.ts +258 -276
- package/node_modules/pi-agent-ide-changes/src/current-change-presenter.ts +164 -190
- package/node_modules/pi-agent-ide-changes/src/doctor-plugin.ts +29 -0
- package/node_modules/pi-agent-ide-changes/src/index-mutation-queue.ts +10 -9
- package/node_modules/pi-agent-ide-changes/src/last-text-transaction-store.ts +49 -62
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +93 -93
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +124 -126
- package/node_modules/pi-agent-ide-formatter/index.ts +22 -23
- package/node_modules/pi-agent-ide-formatter/package.json +5 -2
- package/node_modules/pi-agent-ide-formatter/src/catalog.ts +247 -0
- package/node_modules/pi-agent-ide-formatter/src/doctor-plugin.ts +104 -0
- package/node_modules/pi-agent-ide-formatter/src/formatter.ts +38 -40
- package/node_modules/pi-agent-ide-formatter/src/registry.ts +45 -21
- package/node_modules/pi-agent-ide-languages/index.ts +24 -0
- package/node_modules/pi-agent-ide-languages/package.json +16 -0
- package/node_modules/pi-agent-ide-languages/src/languages.ts +84 -0
- package/node_modules/pi-agent-ide-lint/index.ts +164 -198
- package/node_modules/pi-agent-ide-lint/package.json +8 -7
- package/node_modules/pi-agent-ide-lint/src/catalog.ts +283 -0
- package/node_modules/pi-agent-ide-lint/src/command-linter.ts +50 -152
- package/node_modules/pi-agent-ide-lint/src/diagnostics.ts +180 -0
- package/node_modules/pi-agent-ide-lint/src/doctor-plugin.ts +104 -0
- package/node_modules/pi-agent-ide-lint/src/registry.ts +43 -21
- package/node_modules/pi-agent-ide-lsp/index.ts +187 -208
- package/node_modules/pi-agent-ide-lsp/package.json +12 -11
- package/node_modules/pi-agent-ide-lsp/src/catalog.ts +248 -0
- package/node_modules/pi-agent-ide-lsp/src/code-view-resolvers.ts +109 -116
- package/node_modules/pi-agent-ide-lsp/src/doctor-plugin.ts +108 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +361 -385
- package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +420 -458
- package/node_modules/pi-agent-ide-lsp/src/lsp/diagnostics.ts +128 -137
- package/node_modules/pi-agent-ide-lsp/src/lsp/index.ts +25 -20
- package/node_modules/pi-agent-ide-lsp/src/lsp/language-map.ts +31 -33
- package/node_modules/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +48 -56
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +369 -411
- package/node_modules/pi-agent-ide-lsp/src/lsp/navigation.ts +58 -63
- package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +153 -70
- package/node_modules/pi-agent-ide-lsp/src/lsp/rename.ts +36 -36
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +117 -127
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbols.ts +108 -107
- package/node_modules/pi-agent-ide-lsp/src/lsp/types.ts +74 -57
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +36 -32
- package/node_modules/pi-agent-image/package.json +2 -2
- package/node_modules/pi-agent-image/src/image-converter.ts +210 -249
- package/node_modules/pi-agent-image/src/index.ts +4 -4
- package/node_modules/pi-agent-pdf/package.json +2 -2
- package/node_modules/pi-agent-pdf/src/index.ts +1 -5
- package/node_modules/pi-agent-pdf/src/pdf-converter.ts +130 -153
- package/node_modules/pi-agent-read/index.ts +1 -1
- package/node_modules/pi-agent-read/package.json +9 -9
- package/node_modules/pi-agent-read/src/api/connect-plugin.ts +38 -51
- package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +26 -32
- package/node_modules/pi-agent-read/src/api/rendering.ts +3 -4
- package/node_modules/pi-agent-read/src/api/tools/read.ts +124 -132
- package/node_modules/pi-agent-read/src/core/extension.ts +28 -29
- package/node_modules/pi-agent-read/src/core/read-core.ts +281 -330
- package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +153 -156
- package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +294 -316
- package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +146 -155
- package/node_modules/pi-agent-read/src/core/tools/read/temp-resource-store.ts +165 -187
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +644 -693
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/content-conversion/connect-plugin.ts +50 -62
- package/node_modules/pi-agent-resource/src/content-conversion/content-converter.ts +27 -33
- package/node_modules/pi-agent-resource/src/content-conversion/content-description.ts +16 -20
- package/node_modules/pi-agent-resource/src/content-conversion/content-host.ts +52 -57
- package/node_modules/pi-agent-resource/src/content-conversion/content-runner.ts +115 -134
- package/node_modules/pi-agent-resource/src/content-conversion/plugin-protocol.ts +38 -39
- package/node_modules/pi-agent-resource/src/content-conversion/validation.ts +117 -107
- package/node_modules/pi-agent-resource/src/content.ts +5 -9
- package/node_modules/pi-agent-resource/src/index.ts +51 -40
- package/node_modules/pi-agent-resource/src/resolver.ts +11 -13
- package/node_modules/pi-agent-resource/src/resource.ts +17 -24
- package/node_modules/pi-agent-resource/src/validation.ts +106 -92
- package/node_modules/pi-agent-search/package.json +7 -7
- package/node_modules/pi-agent-search/src/api/connect-plugin.ts +37 -47
- package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +26 -30
- package/node_modules/pi-agent-search/src/api/search.ts +61 -67
- package/node_modules/pi-agent-search/src/core/extension.ts +112 -92
- package/node_modules/pi-agent-search/src/core/search-core.ts +330 -359
- package/node_modules/pi-agent-search-semantic/index.ts +75 -83
- package/node_modules/pi-agent-search-semantic/package.json +5 -5
- package/node_modules/pi-agent-search-text/index.ts +40 -38
- package/node_modules/pi-agent-search-text/package.json +10 -9
- package/node_modules/pi-agent-search-text/src/doctor-plugin.ts +29 -0
- package/node_modules/pi-agent-search-text/src/file-search.ts +90 -86
- package/node_modules/pi-agent-search-text/src/lucene-query-parser.d.ts +17 -19
- package/node_modules/pi-agent-search-text/src/resolvers.ts +152 -157
- package/node_modules/pi-agent-search-text/src/ripgrep.ts +16 -0
- package/node_modules/pi-agent-search-text/src/search-backend.ts +215 -249
- package/node_modules/pi-agent-search-text/src/search-query.ts +85 -108
- package/node_modules/pi-agent-search-text/src/search-renderer.ts +310 -334
- package/node_modules/pi-agent-search-text/src/search-result.ts +151 -157
- package/node_modules/pi-agent-search-text/src/search-session.ts +255 -261
- package/node_modules/pi-agent-search-web/index.ts +65 -57
- package/node_modules/pi-agent-search-web/package.json +8 -7
- package/node_modules/pi-agent-search-web/src/config.ts +470 -409
- package/node_modules/pi-agent-search-web/src/doctor-plugin.ts +40 -0
- package/node_modules/pi-agent-search-web/src/providers/duckduckgo-html.ts +56 -60
- package/node_modules/pi-agent-search-web/src/providers/endpoints.ts +60 -68
- package/node_modules/pi-agent-search-web/src/providers/request.ts +359 -362
- package/node_modules/pi-agent-search-web/src/providers/response.ts +296 -345
- package/node_modules/pi-agent-search-web/src/search-format.ts +15 -20
- package/node_modules/pi-agent-search-web/src/search.ts +289 -347
- package/node_modules/pi-agent-search-web/src/types.ts +99 -111
- package/node_modules/pi-agent-text/package.json +2 -2
- package/node_modules/pi-agent-text/src/index.ts +30 -22
- package/node_modules/pi-agent-text/src/presented-text.ts +15 -17
- package/node_modules/pi-agent-text/src/source-line.ts +33 -36
- package/node_modules/pi-agent-text/src/text-anchor.ts +120 -117
- package/node_modules/pi-agent-text/src/text-converter.ts +71 -84
- package/node_modules/pi-agent-text/src/text-document.ts +99 -110
- package/node_modules/pi-agent-text-anchor-constant/index.ts +18 -20
- package/node_modules/pi-agent-text-anchor-constant/package.json +5 -5
- package/node_modules/pi-agent-text-anchor-constant/src/resolver.ts +29 -36
- package/node_modules/pi-agent-text-anchor-line-hash/index.ts +34 -36
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +11 -11
- package/node_modules/pi-agent-text-anchor-line-hash/src/anchor.ts +75 -85
- package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +35 -42
- package/node_modules/pi-agent-text-editor/index.ts +7 -9
- package/node_modules/pi-agent-text-editor/package.json +10 -10
- package/node_modules/pi-agent-text-editor/src/api/anchor-inspection.ts +16 -18
- package/node_modules/pi-agent-text-editor/src/api/connect-plugin.ts +40 -50
- package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +10 -13
- package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +31 -36
- package/node_modules/pi-agent-text-editor/src/api/last-resolved-resource.ts +25 -27
- package/node_modules/pi-agent-text-editor/src/api/mutation-guard.ts +26 -31
- package/node_modules/pi-agent-text-editor/src/api/mutation-preview.ts +18 -21
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +19 -19
- package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +117 -132
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +155 -141
- package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +93 -103
- package/node_modules/pi-agent-text-editor/src/api/stale-anchor-message.ts +17 -14
- package/node_modules/pi-agent-text-editor/src/api/text-selection-anchor.ts +84 -95
- package/node_modules/pi-agent-text-editor/src/api/tool-call-interceptor.ts +9 -9
- package/node_modules/pi-agent-text-editor/src/api/tool-renderer.ts +18 -22
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +41 -47
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +115 -120
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +273 -311
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/diff.ts +85 -95
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +232 -289
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +534 -580
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/inline-hints.ts +86 -98
- package/node_modules/pi-agent-text-editor/src/core/text-anchor-recovery.ts +12 -11
- package/node_modules/pi-agent-text-editor/src/core/text-anchor-registry.ts +282 -336
- package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +181 -214
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +476 -511
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-execution.ts +93 -105
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-recovery.ts +31 -33
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +367 -372
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +82 -88
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +1837 -2035
- package/node_modules/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +19 -22
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +629 -631
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +982 -1031
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/partial-json-resolver.ts +19 -23
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/partial-tool-recovery.ts +270 -273
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/rendering.ts +2 -2
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +353 -403
- package/node_modules/pi-agent-text-editor/src/core/tool-description.ts +9 -11
- package/node_modules/pi-agent-text-editor/src/tools/extension.ts +7 -8
- package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +69 -77
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +109 -95
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +69 -61
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +52 -39
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +121 -115
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +71 -54
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +24 -17
- package/node_modules/pi-agent-text-editor-argument-order/index.ts +16 -19
- package/node_modules/pi-agent-text-editor-argument-order/package.json +4 -4
- package/node_modules/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +79 -91
- package/node_modules/pi-agent-text-editor-overwrite/index.ts +297 -323
- package/node_modules/pi-agent-text-editor-overwrite/package.json +4 -4
- package/node_modules/pi-agent-text-editor-renderer/index.ts +11 -12
- package/node_modules/pi-agent-text-editor-renderer/package.json +7 -7
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +347 -359
- package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +203 -219
- package/node_modules/pi-agent-text-editor-renderer/src/diff-theme.ts +297 -329
- package/node_modules/pi-agent-text-editor-renderer/src/diff-viewport.ts +19 -25
- package/node_modules/pi-agent-text-editor-renderer/src/frozen-viewport.ts +160 -168
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +170 -182
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-projection.ts +330 -340
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-result.ts +115 -118
- package/node_modules/pi-agent-text-editor-renderer/src/render-resource.ts +3 -4
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +582 -629
- package/node_modules/pi-agent-text-editor-renderer/src/typing-interpolation.ts +144 -167
- package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +317 -333
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-tool-call-interception/package.json +1 -1
- package/node_modules/pi-agent-tool-call-interception/src/index.ts +334 -354
- package/node_modules/pi-agent-web/index.ts +24 -25
- package/node_modules/pi-agent-web/package.json +10 -10
- package/node_modules/pi-agent-web/src/resolver.ts +133 -155
- package/node_modules/pi-agent-web-html/index.ts +5 -6
- package/node_modules/pi-agent-web-html/package.json +6 -6
- package/node_modules/pi-agent-web-html/src/extract-readable-html.ts +58 -76
- package/node_modules/pi-agent-web-html/src/html-converter.ts +62 -75
- package/node_modules/pi-agent-web-image/index.ts +5 -6
- package/node_modules/pi-agent-web-image/package.json +5 -5
- package/node_modules/pi-agent-web-pdf/index.ts +5 -6
- package/node_modules/pi-agent-web-pdf/package.json +5 -5
- package/node_modules/pi-agent-web-text/index.ts +5 -6
- package/node_modules/pi-agent-web-text/package.json +5 -5
- package/package.json +72 -52
- package/src/api/code-view.ts +17 -17
- package/src/api/connect-doctor-plugin.ts +1 -0
- package/src/api/connect-plugin.ts +38 -48
- package/src/api/doctor.ts +1 -0
- package/src/api/plugin-protocol.ts +30 -38
- package/src/api/read.ts +6 -1
- package/src/api/resource.ts +3 -1
- package/src/api/search.ts +5 -1
- package/src/api/text-editor.ts +4 -1
- package/src/api/text.ts +3 -1
- package/src/api/tool-catalog.ts +1 -0
- package/src/api/tool-config.ts +365 -0
- package/src/api/toolchain.ts +18 -18
- package/src/code-view/diagnostic-view.ts +59 -58
- package/src/code-view/reference.ts +64 -82
- package/src/code-view/source-view.ts +159 -180
- package/src/composite/builtin-extensions.ts +39 -35
- package/src/composite/config.ts +75 -69
- package/src/composite/selection.ts +54 -52
- package/src/core/extension.ts +32 -36
- package/src/core/ide-core.ts +76 -93
- package/src/doctor/config-writer.ts +115 -0
- package/src/doctor/core.ts +174 -0
- package/src/doctor/discovery.ts +215 -0
- package/src/doctor/extension.ts +108 -0
- package/src/doctor/index.ts +1 -0
- package/src/doctor/inventory.ts +91 -0
- package/src/doctor/run.ts +196 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +42 -44
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +11 -11
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/index.ts +5 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +8 -8
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/index.ts +5 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +5 -5
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/index.ts +11 -12
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +8 -8
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/resolver.ts +112 -135
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +24 -25
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +10 -10
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/index.ts +5 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +6 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/src/extract-readable-html.ts +58 -76
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/src/html-converter.ts +62 -75
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/index.ts +5 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +5 -5
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/index.ts +5 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +5 -5
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/index.ts +5 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +5 -5
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/resolver.ts +133 -155
- package/src/extensions/pi-agent-read/index.ts +1 -1
- package/src/extensions/pi-agent-read/package.json +9 -9
- package/src/extensions/pi-agent-read/src/api/connect-plugin.ts +38 -51
- package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +26 -32
- package/src/extensions/pi-agent-read/src/api/rendering.ts +3 -4
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +124 -132
- package/src/extensions/pi-agent-read/src/core/extension.ts +28 -29
- package/src/extensions/pi-agent-read/src/core/read-core.ts +281 -330
- package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +153 -156
- package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +294 -316
- package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +146 -155
- package/src/extensions/pi-agent-read/src/core/tools/read/temp-resource-store.ts +165 -187
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +644 -693
- package/src/extensions/pi-agent-search/package.json +7 -7
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-semantic/index.ts +75 -83
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-semantic/package.json +5 -5
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +40 -38
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +10 -9
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/doctor-plugin.ts +29 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +90 -86
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/lucene-query-parser.d.ts +17 -19
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +152 -157
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/ripgrep.ts +16 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +215 -249
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-query.ts +85 -108
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +310 -334
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +151 -157
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +255 -261
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/index.ts +65 -57
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/package.json +8 -7
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/config.ts +470 -409
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/doctor-plugin.ts +40 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/duckduckgo-html.ts +56 -60
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/endpoints.ts +60 -68
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/request.ts +359 -362
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/response.ts +296 -345
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/search-format.ts +15 -20
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/search.ts +289 -347
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/types.ts +99 -111
- package/src/extensions/pi-agent-search/src/api/connect-plugin.ts +37 -47
- package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +26 -30
- package/src/extensions/pi-agent-search/src/api/search.ts +61 -67
- package/src/extensions/pi-agent-search/src/core/extension.ts +112 -92
- package/src/extensions/pi-agent-search/src/core/search-core.ts +330 -359
- package/src/extensions/pi-agent-text-editor/index.ts +7 -9
- package/src/extensions/pi-agent-text-editor/package.json +10 -10
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/index.ts +18 -20
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/src/resolver.ts +29 -36
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +34 -36
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +11 -11
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/anchor.ts +75 -85
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/read-handler.ts +35 -42
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/index.ts +16 -19
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/package.json +4 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +79 -91
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/index.ts +297 -323
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +4 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +11 -12
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +7 -7
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +347 -359
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +203 -219
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-theme.ts +297 -329
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-viewport.ts +19 -25
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/frozen-viewport.ts +160 -168
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +170 -182
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-projection.ts +330 -340
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-result.ts +115 -118
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/render-resource.ts +3 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +582 -629
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/typing-interpolation.ts +144 -167
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/index.ts +317 -333
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/src/api/anchor-inspection.ts +16 -18
- package/src/extensions/pi-agent-text-editor/src/api/connect-plugin.ts +40 -50
- package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +10 -13
- package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +31 -36
- package/src/extensions/pi-agent-text-editor/src/api/last-resolved-resource.ts +25 -27
- package/src/extensions/pi-agent-text-editor/src/api/mutation-guard.ts +26 -31
- package/src/extensions/pi-agent-text-editor/src/api/mutation-preview.ts +18 -21
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +19 -19
- package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +117 -132
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +155 -141
- package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +93 -103
- package/src/extensions/pi-agent-text-editor/src/api/stale-anchor-message.ts +17 -14
- package/src/extensions/pi-agent-text-editor/src/api/text-selection-anchor.ts +84 -95
- package/src/extensions/pi-agent-text-editor/src/api/tool-call-interceptor.ts +9 -9
- package/src/extensions/pi-agent-text-editor/src/api/tool-renderer.ts +18 -22
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +41 -47
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +115 -120
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +273 -311
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/diff.ts +85 -95
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +232 -289
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +534 -580
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/inline-hints.ts +86 -98
- package/src/extensions/pi-agent-text-editor/src/core/text-anchor-recovery.ts +12 -11
- package/src/extensions/pi-agent-text-editor/src/core/text-anchor-registry.ts +282 -336
- package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +181 -214
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +476 -511
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-execution.ts +93 -105
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-recovery.ts +31 -33
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +367 -372
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +82 -88
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +1837 -2035
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +19 -22
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +629 -631
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +982 -1031
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/partial-json-resolver.ts +19 -23
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/partial-tool-recovery.ts +270 -273
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/rendering.ts +2 -2
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +353 -403
- package/src/extensions/pi-agent-text-editor/src/core/tool-description.ts +9 -11
- package/src/extensions/pi-agent-text-editor/src/tools/extension.ts +7 -8
- package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +69 -77
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +109 -95
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +69 -61
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +52 -39
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +121 -115
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +71 -54
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +24 -17
- package/src/pi-agent-ide.ts +10 -10
- package/src/plugins/pi-agent-ide-ast/index.ts +1 -1
- package/src/plugins/pi-agent-ide-ast/package.json +13 -12
- package/src/plugins/pi-agent-ide-ast/src/ast/collect-files.ts +11 -16
- package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +292 -322
- package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +591 -656
- package/src/plugins/pi-agent-ide-ast/src/ast/read-text.ts +15 -19
- package/src/plugins/pi-agent-ide-ast/src/doctor-plugin.ts +105 -0
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +67 -64
- package/src/plugins/pi-agent-ide-ast/src/outline-resolver.ts +51 -54
- package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +168 -185
- package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +30 -36
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +118 -129
- package/src/plugins/pi-agent-ide-changes/index.ts +53 -51
- package/src/plugins/pi-agent-ide-changes/package.json +12 -11
- package/src/plugins/pi-agent-ide-changes/src/change-anchor.ts +68 -78
- package/src/plugins/pi-agent-ide-changes/src/changes/change-groups.ts +230 -245
- package/src/plugins/pi-agent-ide-changes/src/changes/change-service.ts +189 -192
- package/src/plugins/pi-agent-ide-changes/src/changes/change-types.ts +75 -79
- package/src/plugins/pi-agent-ide-changes/src/changes/git-changes-backend.ts +258 -276
- package/src/plugins/pi-agent-ide-changes/src/current-change-presenter.ts +164 -190
- package/src/plugins/pi-agent-ide-changes/src/doctor-plugin.ts +29 -0
- package/src/plugins/pi-agent-ide-changes/src/index-mutation-queue.ts +10 -9
- package/src/plugins/pi-agent-ide-changes/src/last-text-transaction-store.ts +49 -62
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +93 -93
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +124 -126
- package/src/plugins/pi-agent-ide-formatter/index.ts +22 -23
- package/src/plugins/pi-agent-ide-formatter/package.json +5 -2
- package/src/plugins/pi-agent-ide-formatter/src/catalog.ts +247 -0
- package/src/plugins/pi-agent-ide-formatter/src/doctor-plugin.ts +104 -0
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +38 -40
- package/src/plugins/pi-agent-ide-formatter/src/registry.ts +45 -21
- package/src/plugins/pi-agent-ide-languages/index.ts +24 -0
- package/src/plugins/pi-agent-ide-languages/package.json +16 -0
- package/src/plugins/pi-agent-ide-languages/src/languages.ts +84 -0
- package/src/plugins/pi-agent-ide-lint/index.ts +164 -198
- package/src/plugins/pi-agent-ide-lint/package.json +8 -7
- package/src/plugins/pi-agent-ide-lint/src/catalog.ts +283 -0
- package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +50 -152
- package/src/plugins/pi-agent-ide-lint/src/diagnostics.ts +180 -0
- package/src/plugins/pi-agent-ide-lint/src/doctor-plugin.ts +104 -0
- package/src/plugins/pi-agent-ide-lint/src/registry.ts +43 -21
- package/src/plugins/pi-agent-ide-lsp/index.ts +187 -208
- package/src/plugins/pi-agent-ide-lsp/package.json +12 -11
- package/src/plugins/pi-agent-ide-lsp/src/catalog.ts +248 -0
- package/src/plugins/pi-agent-ide-lsp/src/code-view-resolvers.ts +109 -116
- package/src/plugins/pi-agent-ide-lsp/src/doctor-plugin.ts +108 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +361 -385
- package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +420 -458
- package/src/plugins/pi-agent-ide-lsp/src/lsp/diagnostics.ts +128 -137
- package/src/plugins/pi-agent-ide-lsp/src/lsp/index.ts +25 -20
- package/src/plugins/pi-agent-ide-lsp/src/lsp/language-map.ts +31 -33
- package/src/plugins/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +48 -56
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +369 -411
- package/src/plugins/pi-agent-ide-lsp/src/lsp/navigation.ts +58 -63
- package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +153 -70
- package/src/plugins/pi-agent-ide-lsp/src/lsp/rename.ts +36 -36
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +117 -127
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbols.ts +108 -107
- package/src/plugins/pi-agent-ide-lsp/src/lsp/types.ts +74 -57
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +36 -32
- package/src/post-edit/gate.ts +114 -122
- package/src/toolchain/diagnostic.ts +3 -4
- package/src/toolchain/gate.ts +278 -295
- package/src/toolchain/registry.ts +143 -165
- package/src/toolchain/types.ts +126 -103
- package/src/utils/required-value.ts +8 -0
- package/node_modules/pi-agent-ide-formatter/src/types.ts +0 -10
- package/node_modules/pi-agent-ide-lint/src/command-runner.ts +0 -51
- package/node_modules/pi-agent-ide-lint/src/types.ts +0 -10
- package/src/plugins/pi-agent-ide-formatter/src/types.ts +0 -10
- package/src/plugins/pi-agent-ide-lint/src/command-runner.ts +0 -51
- package/src/plugins/pi-agent-ide-lint/src/types.ts +0 -10
|
@@ -1,420 +1,396 @@
|
|
|
1
|
+
import { requiredValue } from "../../../../../utils/required-value.js";
|
|
1
2
|
import path from "node:path";
|
|
2
3
|
|
|
3
4
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
type AgentToolResult,
|
|
6
|
+
keyText,
|
|
7
|
+
type Theme,
|
|
8
|
+
type ThemeColor,
|
|
9
|
+
type ToolRenderResultOptions,
|
|
9
10
|
} from "@earendil-works/pi-coding-agent";
|
|
10
11
|
import { type Component, Text, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
11
12
|
|
|
12
13
|
import { isSearchToolDetails } from "#src/search-result.js";
|
|
13
14
|
|
|
14
|
-
import type {
|
|
15
|
+
import type {
|
|
16
|
+
SearchResultFile,
|
|
17
|
+
SearchResultLine,
|
|
18
|
+
SearchResultRange,
|
|
19
|
+
SearchToolDetails,
|
|
20
|
+
} from "#src/search-result.js";
|
|
15
21
|
|
|
16
22
|
const COMPACT_SEARCH_ROWS = 12;
|
|
17
23
|
|
|
18
|
-
const FILE_BADGES: Readonly<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
const FILE_BADGES: Readonly<
|
|
25
|
+
Record<string, { readonly label: string; readonly color: ThemeColor }>
|
|
26
|
+
> = {
|
|
27
|
+
".ts": { label: "TS", color: "accent" },
|
|
28
|
+
".tsx": { label: "TX", color: "accent" },
|
|
29
|
+
".js": { label: "JS", color: "warning" },
|
|
30
|
+
".jsx": { label: "JX", color: "warning" },
|
|
31
|
+
".json": { label: "{}", color: "warning" },
|
|
32
|
+
".md": { label: "MD", color: "mdHeading" },
|
|
33
|
+
".py": { label: "PY", color: "accent" },
|
|
34
|
+
".rs": { label: "RS", color: "accent" },
|
|
35
|
+
".go": { label: "GO", color: "accent" },
|
|
36
|
+
".css": { label: "CS", color: "accent" },
|
|
37
|
+
".html": { label: "<>", color: "accent" },
|
|
30
38
|
};
|
|
31
39
|
|
|
32
|
-
interface SearchCallArguments
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
readonly path?: unknown;
|
|
40
|
+
interface SearchCallArguments {
|
|
41
|
+
readonly query?: unknown;
|
|
42
|
+
readonly path?: unknown;
|
|
36
43
|
}
|
|
37
44
|
|
|
38
|
-
interface SearchRenderContext
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
readonly isError?: boolean;
|
|
45
|
+
interface SearchRenderContext {
|
|
46
|
+
readonly lastComponent: Component | undefined;
|
|
47
|
+
readonly isError?: boolean;
|
|
42
48
|
}
|
|
43
49
|
|
|
44
50
|
type SearchPanelRow =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
interface SearchLineWindow
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
readonly trailingEllipsis: boolean;
|
|
51
|
+
| { readonly kind: "file"; readonly file: SearchResultFile }
|
|
52
|
+
| { readonly kind: "line"; readonly file: SearchResultFile; readonly line: SearchResultLine }
|
|
53
|
+
| { readonly kind: "omitted"; readonly matches: number }
|
|
54
|
+
| { readonly kind: "empty" };
|
|
55
|
+
|
|
56
|
+
interface SearchLineWindow {
|
|
57
|
+
readonly from: number;
|
|
58
|
+
readonly to: number;
|
|
59
|
+
readonly leadingEllipsis: boolean;
|
|
60
|
+
readonly trailingEllipsis: boolean;
|
|
56
61
|
}
|
|
57
62
|
|
|
58
|
-
export function renderSearchCall(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
export function renderSearchCall(arguments_: SearchCallArguments, theme: Theme): Component {
|
|
64
|
+
const query = typeof arguments_.query === "string" ? arguments_.query : "";
|
|
65
|
+
const scope =
|
|
66
|
+
typeof arguments_.path === "string" && arguments_.path.length > 0 && arguments_.path !== "."
|
|
67
|
+
? ` in ${arguments_.path}`
|
|
68
|
+
: "";
|
|
69
|
+
return new Text(
|
|
70
|
+
theme.fg("toolTitle", theme.bold("search ")) +
|
|
71
|
+
theme.fg("muted", `${JSON.stringify(query)}${scope}`),
|
|
72
|
+
0,
|
|
73
|
+
0,
|
|
74
|
+
);
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
export function renderSearchResult(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
): Component
|
|
78
|
-
{
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
78
|
+
result: AgentToolResult<SearchToolDetails>,
|
|
79
|
+
options: ToolRenderResultOptions,
|
|
80
|
+
theme: Theme,
|
|
81
|
+
context: SearchRenderContext,
|
|
82
|
+
): Component {
|
|
83
|
+
if (options.isPartial || context.isError || !isSearchToolDetails(result.details)) {
|
|
84
|
+
const content = result.content[0];
|
|
85
|
+
const text = content?.type === "text" ? content.text : "";
|
|
86
|
+
const color: ThemeColor = context.isError ? "error" : options.isPartial ? "dim" : "toolOutput";
|
|
87
|
+
return new Text(theme.fg(color, text), 0, 0);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const previous =
|
|
91
|
+
context.lastComponent instanceof SearchResultPanel ? context.lastComponent : undefined;
|
|
92
|
+
const panel = previous ?? new SearchResultPanel(result.details, theme, options.expanded);
|
|
93
|
+
panel.update(result.details, theme, options.expanded);
|
|
94
|
+
return panel;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export class SearchResultPanel implements Component {
|
|
98
|
+
private cached: { readonly width: number; readonly lines: string[] } | undefined;
|
|
99
|
+
|
|
100
|
+
public constructor(
|
|
101
|
+
private details: SearchToolDetails,
|
|
102
|
+
private theme: Theme,
|
|
103
|
+
private expanded: boolean,
|
|
104
|
+
) {}
|
|
105
|
+
|
|
106
|
+
public update(details: SearchToolDetails, theme: Theme, expanded: boolean): void {
|
|
107
|
+
if (this.details === details && this.theme === theme && this.expanded === expanded) {
|
|
108
|
+
return;
|
|
85
109
|
}
|
|
86
110
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
111
|
+
this.details = details;
|
|
112
|
+
this.theme = theme;
|
|
113
|
+
this.expanded = expanded;
|
|
114
|
+
this.invalidate();
|
|
115
|
+
}
|
|
92
116
|
|
|
93
|
-
|
|
94
|
-
{
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
public constructor(
|
|
98
|
-
private details: SearchToolDetails,
|
|
99
|
-
private theme: Theme,
|
|
100
|
-
private expanded: boolean,
|
|
101
|
-
)
|
|
102
|
-
{}
|
|
103
|
-
|
|
104
|
-
public update(details: SearchToolDetails, theme: Theme, expanded: boolean): void
|
|
105
|
-
{
|
|
106
|
-
if (this.details !== details || this.theme !== theme || this.expanded !== expanded)
|
|
107
|
-
{
|
|
108
|
-
this.details = details;
|
|
109
|
-
this.theme = theme;
|
|
110
|
-
this.expanded = expanded;
|
|
111
|
-
this.invalidate();
|
|
112
|
-
}
|
|
117
|
+
public render(width: number): string[] {
|
|
118
|
+
if (this.cached?.width === width) {
|
|
119
|
+
return this.cached.lines;
|
|
113
120
|
}
|
|
114
121
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return this.cached.lines;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (width < 4)
|
|
123
|
-
{
|
|
124
|
-
const lines = [truncateToWidth(searchSummary(this.details), Math.max(1, width))];
|
|
125
|
-
this.cached = { width, lines };
|
|
126
|
-
return lines;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const innerWidth = width - 2;
|
|
130
|
-
const rows = searchViewport(this.details, this.expanded);
|
|
131
|
-
const gutterWidth = maximumLineNumberWidth(this.details.files);
|
|
132
|
-
const lines = [renderTopBorder(this.details, innerWidth, this.theme)];
|
|
133
|
-
|
|
134
|
-
for (const row of rows)
|
|
135
|
-
{
|
|
136
|
-
lines.push(renderPanelRow(row, innerWidth, gutterWidth, this.theme));
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
lines.push(this.theme.fg("borderMuted", `╰${"─".repeat(innerWidth)}╯`));
|
|
140
|
-
const clipped = lines.map((line) => truncateToWidth(line, width));
|
|
141
|
-
this.cached = { width, lines: clipped };
|
|
142
|
-
return clipped;
|
|
122
|
+
if (width < 4) {
|
|
123
|
+
const lines = [truncateToWidth(searchSummary(this.details), Math.max(1, width))];
|
|
124
|
+
this.cached = { width, lines };
|
|
125
|
+
return lines;
|
|
143
126
|
}
|
|
144
127
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
128
|
+
const innerWidth = width - 2;
|
|
129
|
+
const rows = searchViewport(this.details, this.expanded);
|
|
130
|
+
const gutterWidth = maximumLineNumberWidth(this.details.files);
|
|
131
|
+
const lines = [renderTopBorder(this.details, innerWidth, this.theme)];
|
|
132
|
+
|
|
133
|
+
for (const row of rows) {
|
|
134
|
+
lines.push(renderPanelRow(row, innerWidth, gutterWidth, this.theme));
|
|
148
135
|
}
|
|
136
|
+
|
|
137
|
+
lines.push(this.theme.fg("borderMuted", `╰${"─".repeat(innerWidth)}╯`));
|
|
138
|
+
const clipped = lines.map((line) => truncateToWidth(line, width));
|
|
139
|
+
this.cached = { width, lines: clipped };
|
|
140
|
+
return clipped;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
public invalidate(): void {
|
|
144
|
+
this.cached = undefined;
|
|
145
|
+
}
|
|
149
146
|
}
|
|
150
147
|
|
|
151
|
-
function searchViewport(details: SearchToolDetails, expanded: boolean): readonly SearchPanelRow[]
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
148
|
+
function searchViewport(details: SearchToolDetails, expanded: boolean): readonly SearchPanelRow[] {
|
|
149
|
+
const rows =
|
|
150
|
+
details.files.length === 0
|
|
151
|
+
? [{ kind: "empty" } satisfies SearchPanelRow]
|
|
152
|
+
: details.files.flatMap((file): SearchPanelRow[] => [
|
|
153
|
+
{ kind: "file", file },
|
|
154
|
+
...file.lines.map((line): SearchPanelRow => ({ kind: "line", file, line })),
|
|
158
155
|
]);
|
|
159
156
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
157
|
+
if (expanded || rows.length <= COMPACT_SEARCH_ROWS) {
|
|
158
|
+
return rows;
|
|
159
|
+
}
|
|
164
160
|
|
|
165
|
-
|
|
161
|
+
const selected = rows.slice(0, COMPACT_SEARCH_ROWS - 1);
|
|
166
162
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
163
|
+
while (selected.at(-1)?.kind === "file") {
|
|
164
|
+
selected.pop();
|
|
165
|
+
}
|
|
171
166
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
167
|
+
const shownMatches = selected.reduce(
|
|
168
|
+
(count, row) => count + (row.kind === "line" ? row.line.matchCount : 0),
|
|
169
|
+
0,
|
|
170
|
+
);
|
|
171
|
+
return [...selected, { kind: "omitted", matches: details.matchCount - shownMatches }];
|
|
177
172
|
}
|
|
178
173
|
|
|
179
|
-
function renderPanelRow(
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
)
|
|
199
|
-
|
|
174
|
+
function renderPanelRow(
|
|
175
|
+
row: SearchPanelRow,
|
|
176
|
+
width: number,
|
|
177
|
+
gutterWidth: number,
|
|
178
|
+
theme: Theme,
|
|
179
|
+
): string {
|
|
180
|
+
if (row.kind === "file") {
|
|
181
|
+
return framed(renderFileHeader(row.file, width, theme), width, theme, true);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (row.kind === "line") {
|
|
185
|
+
return framed(renderMatchLine(row.line, width, gutterWidth, theme), width, theme);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (row.kind === "omitted") {
|
|
189
|
+
const hint = `${keyText("app.tools.expand")} to expand`;
|
|
190
|
+
return framed(
|
|
191
|
+
theme.fg(
|
|
192
|
+
"dim",
|
|
193
|
+
` … ${String(row.matches)} more ${plural(row.matches, "match", "matches")} · ${hint}`,
|
|
194
|
+
),
|
|
195
|
+
width,
|
|
196
|
+
theme,
|
|
197
|
+
);
|
|
198
|
+
}
|
|
200
199
|
|
|
201
|
-
|
|
200
|
+
return framed(theme.fg("dim", " No matches found"), width, theme);
|
|
202
201
|
}
|
|
203
202
|
|
|
204
|
-
function renderFileHeader(file: SearchResultFile, width: number, theme: Theme): string
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
return truncateToWidth(`${left}${gap}${count} `, width);
|
|
203
|
+
function renderFileHeader(file: SearchResultFile, width: number, theme: Theme): string {
|
|
204
|
+
const badge = fileBadge(file.path, theme);
|
|
205
|
+
const count = theme.fg("accent", theme.bold(String(file.matchCount)));
|
|
206
|
+
const fixedWidth = visibleWidth(badge) + visibleWidth(count) + 4;
|
|
207
|
+
const pathWidth = Math.max(1, width - fixedWidth);
|
|
208
|
+
const displayedPath = truncatePath(file.path, pathWidth);
|
|
209
|
+
const linkedPath = fileLink(displayedPath, file.link, theme);
|
|
210
|
+
const left = ` ${badge} ${linkedPath}`;
|
|
211
|
+
const gap = " ".repeat(Math.max(1, width - visibleWidth(left) - visibleWidth(count) - 1));
|
|
212
|
+
return truncateToWidth(`${left}${gap}${count} `, width);
|
|
215
213
|
}
|
|
216
214
|
|
|
217
|
-
function renderMatchLine(
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
215
|
+
function renderMatchLine(
|
|
216
|
+
line: SearchResultLine,
|
|
217
|
+
width: number,
|
|
218
|
+
gutterWidth: number,
|
|
219
|
+
theme: Theme,
|
|
220
|
+
): string {
|
|
221
|
+
const number = String(line.lineNumber).padStart(gutterWidth);
|
|
222
|
+
const gutter = ` ${theme.fg("dim", number)} ${theme.fg("borderMuted", "│")} `;
|
|
223
|
+
const contentWidth = Math.max(1, width - visibleWidth(gutter) - 1);
|
|
224
|
+
return `${gutter}${renderHighlightedLine(line, contentWidth, theme)}`;
|
|
223
225
|
}
|
|
224
226
|
|
|
225
|
-
function renderHighlightedLine(line: SearchResultLine, width: number, theme: Theme): string
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
let offset = window.from;
|
|
231
|
-
|
|
232
|
-
for (const range of ranges)
|
|
233
|
-
{
|
|
234
|
-
if (range.from > offset)
|
|
235
|
-
{
|
|
236
|
-
result += theme.fg("toolOutput", safeText(line.text.slice(offset, range.from)));
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
const match = safeText(line.text.slice(range.from, range.to));
|
|
240
|
-
result += theme.bg("selectedBg", theme.fg("accent", theme.bold(match)));
|
|
241
|
-
offset = range.to;
|
|
242
|
-
}
|
|
227
|
+
function renderHighlightedLine(line: SearchResultLine, width: number, theme: Theme): string {
|
|
228
|
+
const window = searchLineWindow(line, width);
|
|
229
|
+
const ranges = visibleRanges(line.ranges, window.from, window.to);
|
|
230
|
+
let result = window.leadingEllipsis ? theme.fg("dim", "…") : "";
|
|
231
|
+
let offset = window.from;
|
|
243
232
|
|
|
244
|
-
|
|
245
|
-
{
|
|
246
|
-
|
|
233
|
+
for (const range of ranges) {
|
|
234
|
+
if (range.from > offset) {
|
|
235
|
+
result += theme.fg("toolOutput", safeText(line.text.slice(offset, range.from)));
|
|
247
236
|
}
|
|
248
237
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
238
|
+
const match = safeText(line.text.slice(range.from, range.to));
|
|
239
|
+
result += theme.bg("selectedBg", theme.fg("accent", theme.bold(match)));
|
|
240
|
+
offset = range.to;
|
|
241
|
+
}
|
|
253
242
|
|
|
254
|
-
|
|
255
|
-
|
|
243
|
+
if (offset < window.to) {
|
|
244
|
+
result += theme.fg("toolOutput", safeText(line.text.slice(offset, window.to)));
|
|
245
|
+
}
|
|
256
246
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
{
|
|
261
|
-
return { from: 0, to: line.text.length, leadingEllipsis: false, trailingEllipsis: false };
|
|
262
|
-
}
|
|
247
|
+
if (window.trailingEllipsis) {
|
|
248
|
+
result += theme.fg("dim", "…");
|
|
249
|
+
}
|
|
263
250
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
const matchWidth = Math.min(budget, Math.max(1, focus.to - focus.from));
|
|
267
|
-
const before = Math.max(0, Math.floor((budget - matchWidth) * 0.4));
|
|
268
|
-
let from = Math.max(0, focus.from - before);
|
|
269
|
-
let to = Math.min(line.text.length, from + budget);
|
|
270
|
-
|
|
271
|
-
if (to < focus.to)
|
|
272
|
-
{
|
|
273
|
-
to = Math.min(line.text.length, focus.to);
|
|
274
|
-
from = Math.max(0, to - budget);
|
|
275
|
-
}
|
|
251
|
+
return truncateToWidth(result, width);
|
|
252
|
+
}
|
|
276
253
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
254
|
+
function searchLineWindow(line: SearchResultLine, width: number): SearchLineWindow {
|
|
255
|
+
if (visibleWidth(safeText(line.text)) <= width) {
|
|
256
|
+
return { from: 0, to: line.text.length, leadingEllipsis: false, trailingEllipsis: false };
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const focus = requiredValue(line.ranges[0]);
|
|
260
|
+
const budget = Math.max(1, width - 2);
|
|
261
|
+
const matchWidth = Math.min(budget, Math.max(1, focus.to - focus.from));
|
|
262
|
+
const before = Math.max(0, Math.floor((budget - matchWidth) * 0.4));
|
|
263
|
+
let from = Math.max(0, focus.from - before);
|
|
264
|
+
let to = Math.min(line.text.length, from + budget);
|
|
265
|
+
|
|
266
|
+
if (to < focus.to) {
|
|
267
|
+
to = Math.min(line.text.length, focus.to);
|
|
268
|
+
from = Math.max(0, to - budget);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return {
|
|
272
|
+
from,
|
|
273
|
+
to,
|
|
274
|
+
leadingEllipsis: from > 0,
|
|
275
|
+
trailingEllipsis: to < line.text.length,
|
|
276
|
+
};
|
|
283
277
|
}
|
|
284
278
|
|
|
285
279
|
function visibleRanges(
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
): readonly SearchResultRange[]
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
if (clipped.to <= clipped.from)
|
|
298
|
-
{
|
|
299
|
-
continue;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
const previous = visible.at(-1);
|
|
303
|
-
|
|
304
|
-
if (previous !== undefined && clipped.from <= previous.to)
|
|
305
|
-
{
|
|
306
|
-
visible[visible.length - 1] = { from: previous.from, to: Math.max(previous.to, clipped.to) };
|
|
307
|
-
}
|
|
308
|
-
else
|
|
309
|
-
{
|
|
310
|
-
visible.push(clipped);
|
|
311
|
-
}
|
|
280
|
+
ranges: readonly SearchResultRange[],
|
|
281
|
+
from: number,
|
|
282
|
+
to: number,
|
|
283
|
+
): readonly SearchResultRange[] {
|
|
284
|
+
const visible: SearchResultRange[] = [];
|
|
285
|
+
|
|
286
|
+
for (const range of ranges) {
|
|
287
|
+
const clipped = { from: Math.max(from, range.from), to: Math.min(to, range.to) };
|
|
288
|
+
|
|
289
|
+
if (clipped.to <= clipped.from) {
|
|
290
|
+
continue;
|
|
312
291
|
}
|
|
313
292
|
|
|
314
|
-
|
|
315
|
-
}
|
|
293
|
+
const previous = visible.at(-1);
|
|
316
294
|
|
|
317
|
-
|
|
318
|
-
{
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
295
|
+
if (previous !== undefined && clipped.from <= previous.to) {
|
|
296
|
+
visible[visible.length - 1] = { from: previous.from, to: Math.max(previous.to, clipped.to) };
|
|
297
|
+
} else {
|
|
298
|
+
visible.push(clipped);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return visible;
|
|
323
303
|
}
|
|
324
304
|
|
|
325
|
-
function
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
305
|
+
function renderTopBorder(details: SearchToolDetails, width: number, theme: Theme): string {
|
|
306
|
+
const frame = (text: string): string => theme.fg("borderMuted", text);
|
|
307
|
+
const title = truncateToWidth(` ${searchSummary(details)} `, Math.max(0, width - 1), "");
|
|
308
|
+
const fill = "─".repeat(Math.max(0, width - visibleWidth(title) - 1));
|
|
309
|
+
return `${frame("╭─")}${theme.fg("accent", title)}${frame(`${fill}╮`)}`;
|
|
310
|
+
}
|
|
331
311
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
312
|
+
function searchSummary(details: SearchToolDetails): string {
|
|
313
|
+
if (details.matchCount === 0) {
|
|
314
|
+
return "No matches";
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
const count = `${String(details.matchCount)}${details.complete ? "" : "+"}`;
|
|
318
|
+
return `${count} ${plural(details.matchCount, "match", "matches")} in ${String(details.fileCount)} ${plural(
|
|
319
|
+
details.fileCount,
|
|
320
|
+
"file",
|
|
321
|
+
"files",
|
|
322
|
+
)}`;
|
|
336
323
|
}
|
|
337
324
|
|
|
338
|
-
function framed(content: string, width: number, theme: Theme, highlighted = false): string
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
return `${border}${renderedBody}${border}`;
|
|
325
|
+
function framed(content: string, width: number, theme: Theme, highlighted = false): string {
|
|
326
|
+
const clipped = truncateToWidth(content, width);
|
|
327
|
+
const body = `${clipped}${" ".repeat(Math.max(0, width - visibleWidth(clipped)))}`;
|
|
328
|
+
const renderedBody = highlighted ? theme.bg("selectedBg", body) : body;
|
|
329
|
+
const border = theme.fg("borderMuted", "│");
|
|
330
|
+
return `${border}${renderedBody}${border}`;
|
|
345
331
|
}
|
|
346
332
|
|
|
347
|
-
function fileBadge(filePath: string, theme: Theme): string
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
333
|
+
function fileBadge(filePath: string, theme: Theme): string {
|
|
334
|
+
const extension = path.extname(filePath).toLowerCase();
|
|
335
|
+
const badge =
|
|
336
|
+
FILE_BADGES[extension] ??
|
|
337
|
+
({
|
|
338
|
+
label: "◇ ",
|
|
339
|
+
color: extension.length === 0 ? "muted" : "accent",
|
|
340
|
+
} satisfies { readonly label: string; readonly color: ThemeColor });
|
|
341
|
+
return theme.fg(badge.color, theme.bold(badge.label));
|
|
355
342
|
}
|
|
356
343
|
|
|
357
|
-
function fileLink(displayedPath: string, link: string, theme: Theme): string
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
: `\u001B]8;;${link}\u0007${label}\u001B]8;;\u0007`;
|
|
344
|
+
function fileLink(displayedPath: string, link: string, theme: Theme): string {
|
|
345
|
+
const separator = Math.max(displayedPath.lastIndexOf("/"), displayedPath.lastIndexOf("\\"));
|
|
346
|
+
const directory = separator === -1 ? "" : displayedPath.slice(0, separator + 1);
|
|
347
|
+
const basename = separator === -1 ? displayedPath : displayedPath.slice(separator + 1);
|
|
348
|
+
const label = theme.fg("muted", directory) + theme.underline(theme.fg("accent", basename));
|
|
349
|
+
return link.includes("\u{7}") || link.includes("\u{1B}")
|
|
350
|
+
? label
|
|
351
|
+
: `\u{1B}]8;;${link}\u{7}${label}\u{1B}]8;;\u{7}`;
|
|
366
352
|
}
|
|
367
353
|
|
|
368
|
-
function truncatePath(filePath: string, width: number): string
|
|
369
|
-
{
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
return filePath;
|
|
373
|
-
}
|
|
354
|
+
function truncatePath(filePath: string, width: number): string {
|
|
355
|
+
if (visibleWidth(filePath) <= width) {
|
|
356
|
+
return filePath;
|
|
357
|
+
}
|
|
374
358
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
}
|
|
359
|
+
if (width <= 1) {
|
|
360
|
+
return "…";
|
|
361
|
+
}
|
|
379
362
|
|
|
380
|
-
|
|
363
|
+
return `…${filePath.slice(-(width - 1))}`;
|
|
381
364
|
}
|
|
382
365
|
|
|
383
|
-
function safeText(value: string): string
|
|
384
|
-
|
|
385
|
-
let result = "";
|
|
366
|
+
function safeText(value: string): string {
|
|
367
|
+
let result = "";
|
|
386
368
|
|
|
387
|
-
|
|
388
|
-
{
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
result += " ";
|
|
392
|
-
continue;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
const code = character.codePointAt(0)!;
|
|
396
|
-
result += code < 0x20 || code === 0x7F ? "�" : character;
|
|
369
|
+
for (const character of value) {
|
|
370
|
+
if (character === "\t") {
|
|
371
|
+
result += " ".repeat(4);
|
|
372
|
+
continue;
|
|
397
373
|
}
|
|
398
374
|
|
|
399
|
-
|
|
375
|
+
const code = requiredValue(character.codePointAt(0));
|
|
376
|
+
result += code < 0x20 || code === 0x7f ? "�" : character;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
return result;
|
|
400
380
|
}
|
|
401
381
|
|
|
402
|
-
function maximumLineNumberWidth(files: readonly SearchResultFile[]): number
|
|
403
|
-
|
|
404
|
-
let maximum = 1;
|
|
382
|
+
function maximumLineNumberWidth(files: readonly SearchResultFile[]): number {
|
|
383
|
+
let maximum = 1;
|
|
405
384
|
|
|
406
|
-
|
|
407
|
-
{
|
|
408
|
-
|
|
409
|
-
{
|
|
410
|
-
maximum = Math.max(maximum, line.lineNumber);
|
|
411
|
-
}
|
|
385
|
+
for (const file of files) {
|
|
386
|
+
for (const line of file.lines) {
|
|
387
|
+
maximum = Math.max(maximum, line.lineNumber);
|
|
412
388
|
}
|
|
389
|
+
}
|
|
413
390
|
|
|
414
|
-
|
|
391
|
+
return Math.max(3, String(maximum).length);
|
|
415
392
|
}
|
|
416
393
|
|
|
417
|
-
function plural(count: number, singular: string, pluralForm: string): string
|
|
418
|
-
|
|
419
|
-
return count === 1 ? singular : pluralForm;
|
|
394
|
+
function plural(count: number, singular: string, pluralForm: string): string {
|
|
395
|
+
return count === 1 ? singular : pluralForm;
|
|
420
396
|
}
|