pi-agent-ide 0.6.3 → 0.7.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/CHANGELOG.md +97 -0
- package/README.md +10 -3
- package/dist/{chunk-AWXVJ5AC.js → chunk-2RTCSZB3.js} +1 -1
- package/dist/chunk-3HYXQ4YA.js +28 -0
- package/dist/chunk-3JO7QFIL.js +1 -0
- package/dist/chunk-4NIFBFFR.js +11 -0
- package/dist/{chunk-VCTK4JSN.js → chunk-64M3SQPG.js} +1 -1
- package/dist/{chunk-5QQABP47.js → chunk-7LD2OQH3.js} +1 -1
- package/dist/chunk-7LZKOHH2.js +1 -0
- package/dist/chunk-AJRIASPQ.js +2 -0
- package/dist/chunk-EAZGN5ND.js +7 -0
- package/dist/{chunk-ZM4L5AGN.js → chunk-EDURPQAV.js} +3 -2
- package/dist/{chunk-GIRAEVUJ.js → chunk-F5YZG77W.js} +1 -1
- package/dist/chunk-FK42RSF4.js +1 -0
- package/dist/{chunk-O6LE42GK.js → chunk-FXNKMNSJ.js} +1 -1
- package/dist/chunk-GBLKIB6O.js +2 -0
- package/dist/chunk-KBP3QUDT.js +2 -0
- package/dist/chunk-KR36BT5E.js +1 -0
- package/dist/{chunk-NTYXZ3EL.js → chunk-KVHDMIZS.js} +1 -1
- package/dist/{chunk-QDST6VIU.js → chunk-KZC7TI5M.js} +1 -1
- package/dist/chunk-OE7QVAI2.js +5 -0
- package/dist/{chunk-GUTQ3PWL.js → chunk-PLKYHUNT.js} +1 -1
- package/dist/chunk-PNU3E7IO.js +3 -0
- package/dist/chunk-PS2B6THP.js +3 -0
- package/dist/chunk-PYPPV2F5.js +25 -0
- package/dist/{chunk-25CZ5ZIU.js → chunk-QFTBY67N.js} +3 -3
- package/dist/chunk-S5LXX32D.js +28 -0
- package/dist/chunk-SILJ3OL4.js +9 -0
- package/dist/chunk-SQKAXYIR.js +2 -0
- package/dist/chunk-VCGNVTXQ.js +1 -0
- package/dist/chunk-XYS4FSCC.js +12 -0
- package/dist/chunk-YGGKGZO2.js +1 -0
- package/dist/{chunk-L7JMDDSD.js → chunk-YRF7OATP.js} +1 -1
- package/dist/chunk-ZPT5D4VP.js +2 -0
- package/dist/entry-0.js +1 -1
- package/dist/entry-11.js +1 -1
- package/dist/entry-13.js +1 -1
- package/dist/entry-14.js +1 -1
- package/dist/entry-15.js +1 -1
- package/dist/entry-16.js +1 -1
- package/dist/entry-17.js +1 -1
- package/dist/entry-25.js +2 -2
- package/dist/entry-26.js +1 -1
- package/dist/entry-27.js +1 -1
- package/dist/entry-28.js +1 -1
- package/dist/entry-29.js +1 -1
- package/dist/entry-30.js +1 -1
- package/dist/entry-31.js +11 -9
- package/dist/entry-33.js +1 -1
- package/dist/entry-37.js +6 -6
- package/dist/entry-42.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +12 -11
- package/dist/entry-46.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +3 -6
- package/dist/entry-51.js +11 -9
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-54.js +1 -1
- package/dist/entry-55.js +1 -1
- package/dist/entry-56.js +1 -1
- package/dist/entry-57.js +1 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-59.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-61.js +0 -1
- package/dist/entry-62.js +1 -0
- package/dist/entry-63.js +0 -1
- package/dist/entry-64.js +1 -0
- package/dist/entry-65.js +1 -1
- package/dist/entry-66.js +1 -1
- package/dist/entry-67.js +1 -1
- package/dist/entry-68.js +1 -1
- package/dist/entry-69.js +1 -1
- package/dist/entry-70.js +1 -1
- package/dist/entry-72.js +1 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-77.js +50 -307
- package/dist/entry-78.js +14 -26
- package/dist/entry-79.js +2 -2
- package/dist/entry-80.js +1 -1
- package/dist/entry-81.js +1 -1
- package/dist/entry-82.js +5 -3
- package/dist/entry-83.js +1 -1
- package/dist/entry-84.js +1 -1
- package/dist/entry-85.js +1 -1
- package/dist/entry-86.js +1 -1
- package/dist/pi-agent-ide.js +15 -3
- package/docs/agent-guides/editing.md +31 -3
- package/docs/agent-guides/git-changes.md +1 -1
- package/docs/agent-guides/json-reading.md +19 -3
- package/docs/agent-guides/read-resources.md +15 -1
- package/docs/agent-guides/search-code.md +43 -2
- package/docs/agent-guides/select-code.md +194 -0
- package/docs/agent-guides/terminal.md +1 -1
- package/docs/code-review.md +99 -0
- package/docs/configuration.md +36 -7
- package/docs/development.md +16 -19
- package/docs/nightly.md +7 -0
- package/docs/releases.md +42 -0
- package/docs/research/apply-native-capability-matrix.md +174 -0
- package/docs/research/apply-read-latency.md +2 -0
- package/docs/research/lpt-393-fuzzy-results/file.json +152 -0
- package/docs/research/lpt-393-fuzzy-results/repo.json +122 -0
- package/docs/research/lpt-393-search-fuzzy-fallback.md +97 -0
- package/docs/research/native-codemode-batch-decision.md +29 -0
- package/docs/research/native-codemode-batching.md +65 -0
- package/docs/structured-results.md +86 -0
- package/docs/tools.md +24 -4
- package/docs/user-hooks.md +1 -1
- package/node_modules/pi-agent-doctor/package.json +1 -1
- package/node_modules/pi-agent-documentation/package.json +1 -1
- package/node_modules/pi-agent-documentation/src/index.ts +1 -1
- package/node_modules/pi-agent-filesystem/index.ts +6 -1
- package/node_modules/pi-agent-filesystem/package.json +7 -6
- package/node_modules/pi-agent-filesystem/src/path-recovery.ts +109 -0
- package/node_modules/pi-agent-filesystem-image/package.json +3 -3
- package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
- package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
- package/node_modules/pi-agent-filesystem-text/package.json +3 -3
- package/node_modules/pi-agent-ide-ast/package.json +15 -10
- package/node_modules/pi-agent-ide-ast/src/ast/constructs.ts +193 -0
- package/node_modules/pi-agent-ide-ast/src/ast/element-extent.ts +59 -0
- package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +5 -1
- package/node_modules/pi-agent-ide-ast/src/ast/selection.ts +204 -0
- package/node_modules/pi-agent-ide-ast/src/ast/syntax-tree.ts +2 -0
- package/node_modules/pi-agent-ide-ast/src/extension.ts +4 -2
- package/node_modules/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
- package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +6 -1
- package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +6 -2
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +110 -7
- package/node_modules/pi-agent-ide-ast/src/select-presentation.ts +104 -0
- package/node_modules/pi-agent-ide-ast/src/select-schema.ts +384 -0
- package/node_modules/pi-agent-ide-ast/src/selection-region.ts +41 -0
- package/node_modules/pi-agent-ide-ast/src/source-text.ts +92 -0
- package/node_modules/pi-agent-ide-ast/src/text-selection.ts +214 -0
- package/node_modules/pi-agent-ide-ast/src/tool-select.ts +251 -0
- package/node_modules/pi-agent-ide-changes/index.ts +2 -24
- package/node_modules/pi-agent-ide-changes/package.json +8 -7
- package/node_modules/pi-agent-ide-changes/src/current-change-presenter.ts +5 -0
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +126 -48
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +11 -40
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-languages/package.json +2 -2
- package/node_modules/pi-agent-ide-lint/package.json +7 -7
- package/node_modules/pi-agent-ide-lsp/index.ts +2 -2
- package/node_modules/pi-agent-ide-lsp/package.json +9 -9
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +5 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +8 -2
- package/node_modules/pi-agent-ide-lsp/src/lsp/project.ts +19 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +204 -118
- package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +2 -17
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +92 -30
- package/node_modules/pi-agent-image/package.json +2 -2
- package/node_modules/pi-agent-invariant/package.json +1 -1
- package/node_modules/pi-agent-pdf/package.json +2 -2
- package/node_modules/pi-agent-read/package.json +7 -7
- package/node_modules/pi-agent-read/src/api/read-parameters.ts +2 -2
- package/node_modules/pi-agent-read/src/api/tools/read.ts +35 -2
- package/node_modules/pi-agent-read/src/core/extension.ts +11 -0
- package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +9 -10
- package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +28 -15
- package/node_modules/pi-agent-read/src/core/tools/read/result-target.ts +93 -0
- package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +218 -0
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +127 -73
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/index.ts +22 -0
- package/node_modules/pi-agent-resource/src/resource-access.ts +55 -0
- package/node_modules/pi-agent-resource/src/resource-scheduler.ts +204 -0
- package/node_modules/pi-agent-resource/src/result-targets.ts +233 -0
- package/node_modules/pi-agent-resource/src/tool-result.ts +125 -0
- package/node_modules/pi-agent-search/package.json +5 -4
- package/node_modules/pi-agent-search/src/api/fuzzy.ts +208 -0
- package/node_modules/pi-agent-search/src/api/presentation.ts +68 -0
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +13 -6
- package/node_modules/pi-agent-search/src/api/search-scope.ts +22 -0
- package/node_modules/pi-agent-search/src/api/search.ts +39 -0
- package/node_modules/pi-agent-search/src/api/structured-result.ts +148 -0
- package/node_modules/pi-agent-search/src/core/extension.ts +90 -24
- package/node_modules/pi-agent-search/src/core/search-core.ts +145 -78
- package/node_modules/pi-agent-search-text/index.ts +6 -1
- package/node_modules/pi-agent-search-text/package.json +7 -6
- package/node_modules/pi-agent-search-text/src/fuzzy-search.ts +164 -0
- package/node_modules/pi-agent-search-text/src/resolvers.ts +174 -26
- package/node_modules/pi-agent-search-text/src/scoped-search.ts +103 -0
- package/node_modules/pi-agent-search-text/src/search-backend.ts +201 -18
- package/node_modules/pi-agent-search-text/src/search-query.ts +42 -34
- package/node_modules/pi-agent-search-text/src/search-recipe.ts +18 -4
- package/node_modules/pi-agent-search-text/src/search-renderer.ts +90 -259
- package/node_modules/pi-agent-search-text/src/search-result.ts +77 -0
- package/node_modules/pi-agent-search-text/src/search-session.ts +110 -17
- package/node_modules/pi-agent-text/package.json +2 -2
- package/node_modules/pi-agent-text/src/text-document.ts +15 -10
- package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-exact/src/anchor.ts +4 -3
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/node_modules/pi-agent-text-editor/index.ts +4 -7
- package/node_modules/pi-agent-text-editor/package.json +20 -21
- package/node_modules/pi-agent-text-editor/src/api/mutation-preview.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +6 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +3 -1
- package/node_modules/pi-agent-text-editor/src/api/native-edit-batch-event.ts +12 -0
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +1 -20
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit.ts +16 -0
- package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +78 -41
- package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +8 -0
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +12 -2
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +35 -4
- package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/file-result-targets.ts +76 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result-targets.ts +168 -0
- package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +820 -0
- package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +20 -6
- package/node_modules/pi-agent-text-editor/src/core/result-input.ts +22 -0
- package/node_modules/pi-agent-text-editor/src/core/result-target-anchors.ts +78 -0
- package/node_modules/pi-agent-text-editor/src/core/result-transfer.ts +175 -0
- package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +412 -0
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +149 -139
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +236 -185
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +253 -203
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +25 -5
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +8 -4
- package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +9 -6
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +5 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -7
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +8 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +8 -3
- package/node_modules/pi-agent-text-editor-renderer/index.ts +9 -73
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -5
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +276 -129
- package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +36 -2
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +28 -2
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-projection.ts +40 -10
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +19 -45
- package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +16 -1
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +4 -4
- package/node_modules/pi-agent-tool-call-interception/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/package.json +1 -1
- package/node_modules/pi-agent-tool-ui/src/index.ts +7 -0
- package/node_modules/pi-agent-tool-ui/src/result-panel.ts +298 -0
- package/node_modules/pi-agent-web/index.ts +23 -0
- package/node_modules/pi-agent-web/package.json +7 -6
- package/node_modules/pi-agent-web/src/search.ts +221 -0
- package/node_modules/pi-agent-web-html/package.json +2 -2
- package/node_modules/pi-agent-web-image/package.json +3 -3
- package/node_modules/pi-agent-web-pdf/package.json +3 -3
- package/node_modules/pi-agent-web-text/package.json +3 -3
- package/package.json +42 -37
- package/skills/capture-code-review-rule/SKILL.md +60 -0
- package/src/code-review/config.ts +68 -0
- package/src/code-review/extension.ts +105 -0
- package/src/code-review/fragments.ts +26 -0
- package/src/code-review/reviewer.ts +198 -0
- package/src/composite/host-version.ts +13 -0
- package/src/composite/module-labels.ts +1 -1
- package/src/composite/nested-tool-rendering.ts +298 -0
- package/src/composite/preferences.ts +0 -5
- package/src/composite/tool-availability.ts +90 -0
- package/src/core/extension.ts +2 -0
- package/src/documentation/extension.ts +81 -145
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +6 -1
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/path-recovery.ts +109 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +23 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +2 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/search.ts +221 -0
- package/src/extensions/pi-agent-read/package.json +7 -7
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +2 -2
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +35 -2
- package/src/extensions/pi-agent-read/src/core/extension.ts +11 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +9 -10
- package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +28 -15
- package/src/extensions/pi-agent-read/src/core/tools/read/result-target.ts +93 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +218 -0
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +127 -73
- package/src/extensions/pi-agent-search/package.json +5 -4
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +6 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +7 -6
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/fuzzy-search.ts +164 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +174 -26
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +103 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +201 -18
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-query.ts +42 -34
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +18 -4
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +90 -259
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +77 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +110 -17
- package/src/extensions/pi-agent-search/src/api/fuzzy.ts +208 -0
- package/src/extensions/pi-agent-search/src/api/presentation.ts +68 -0
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +13 -6
- package/src/extensions/pi-agent-search/src/api/search-scope.ts +22 -0
- package/src/extensions/pi-agent-search/src/api/search.ts +39 -0
- package/src/extensions/pi-agent-search/src/api/structured-result.ts +148 -0
- package/src/extensions/pi-agent-search/src/core/extension.ts +90 -24
- package/src/extensions/pi-agent-search/src/core/search-core.ts +145 -78
- package/src/extensions/pi-agent-text-editor/index.ts +4 -7
- package/src/extensions/pi-agent-text-editor/package.json +20 -21
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchor.ts +4 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +9 -73
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +276 -129
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +36 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +28 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-projection.ts +40 -10
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +19 -45
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/index.ts +16 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +4 -4
- package/src/extensions/pi-agent-text-editor/src/api/mutation-preview.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +6 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +3 -1
- package/src/extensions/pi-agent-text-editor/src/api/native-edit-batch-event.ts +12 -0
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +1 -20
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit.ts +16 -0
- package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +78 -41
- package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +8 -0
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +12 -2
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +35 -4
- package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/file-result-targets.ts +76 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result-targets.ts +168 -0
- package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +820 -0
- package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +20 -6
- package/src/extensions/pi-agent-text-editor/src/core/result-input.ts +22 -0
- package/src/extensions/pi-agent-text-editor/src/core/result-target-anchors.ts +78 -0
- package/src/extensions/pi-agent-text-editor/src/core/result-transfer.ts +175 -0
- package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +412 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +149 -139
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +236 -185
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +253 -203
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +25 -5
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +8 -4
- package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +9 -6
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +5 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -7
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +8 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +8 -3
- package/src/pi-agent-ide.ts +61 -8
- package/src/plugins/pi-agent-ide-ast/package.json +15 -10
- package/src/plugins/pi-agent-ide-ast/src/ast/constructs.ts +193 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/element-extent.ts +59 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +5 -1
- package/src/plugins/pi-agent-ide-ast/src/ast/selection.ts +204 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/syntax-tree.ts +2 -0
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +4 -2
- package/src/plugins/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
- package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +6 -1
- package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +6 -2
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +110 -7
- package/src/plugins/pi-agent-ide-ast/src/select-presentation.ts +104 -0
- package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +384 -0
- package/src/plugins/pi-agent-ide-ast/src/selection-region.ts +41 -0
- package/src/plugins/pi-agent-ide-ast/src/source-text.ts +92 -0
- package/src/plugins/pi-agent-ide-ast/src/text-selection.ts +214 -0
- package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +251 -0
- package/src/plugins/pi-agent-ide-changes/index.ts +2 -24
- package/src/plugins/pi-agent-ide-changes/package.json +8 -7
- package/src/plugins/pi-agent-ide-changes/src/current-change-presenter.ts +5 -0
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +126 -48
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +11 -40
- package/src/plugins/pi-agent-ide-debugger/index.ts +63 -17
- package/src/plugins/pi-agent-ide-debugger/src/catalog.ts +18 -2
- package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +24 -4
- package/src/plugins/pi-agent-ide-debugger/src/doctor-plugin.ts +68 -2
- package/src/plugins/pi-agent-ide-debugger/src/java-runtime.ts +357 -0
- package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +55 -3
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +13 -13
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-languages/package.json +2 -2
- package/src/plugins/pi-agent-ide-lint/package.json +7 -7
- package/src/plugins/pi-agent-ide-lsp/index.ts +2 -2
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +5 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +8 -2
- package/src/plugins/pi-agent-ide-lsp/src/lsp/project.ts +19 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +204 -118
- package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +2 -17
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +92 -30
- package/src/plugins/pi-agent-ide-terminal/index.ts +12 -2
- package/src/plugins/pi-agent-ide-terminal/src/output-limits.ts +1 -1
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +65 -30
- package/src/plugins/pi-agent-ide-terminal/src/search.ts +16 -37
- package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +1 -0
- package/src/plugins/pi-agent-ide-terminal/src/shell-result.ts +100 -0
- package/src/plugins/pi-agent-ide-terminal/src/steering.ts +62 -0
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +98 -46
- package/src/plugins/pi-agent-ide-terminal/src/types.ts +3 -1
- package/src/plugins/pi-agent-ide-terminal/src/ui.ts +15 -6
- package/src/plugins/pi-agent-ide-vision/index.ts +35 -1
- package/dist/chunk-3E2NTWCN.js +0 -2
- package/dist/chunk-4LUW26BX.js +0 -10
- package/dist/chunk-4U2GUKNJ.js +0 -0
- package/dist/chunk-5VSE5X5R.js +0 -2
- package/dist/chunk-6EYWFBNG.js +0 -0
- package/dist/chunk-7WCZOO5I.js +0 -1
- package/dist/chunk-CEX3VOJ7.js +0 -2
- package/dist/chunk-FA6BKC5Y.js +0 -1
- package/dist/chunk-FEDVTZJG.js +0 -1
- package/dist/chunk-HMLH43ZS.js +0 -4
- package/dist/chunk-ITSNK5YG.js +0 -7
- package/dist/chunk-KII2JQC5.js +0 -1
- package/dist/chunk-LVWMWWWF.js +0 -28
- package/dist/chunk-P7XO5CIP.js +0 -2
- package/dist/chunk-PZFOOHY2.js +0 -15
- package/dist/chunk-ROXXK6TW.js +0 -0
- package/dist/chunk-S3ZPXWX7.js +0 -2
- package/dist/chunk-T7CZIACQ.js +0 -27
- package/dist/chunk-VXD6FZP5.js +0 -5
- package/dist/chunk-YHUTTZC6.js +0 -2
- package/dist/chunk-YT42LKFV.js +0 -16
- package/docs/agent-guides/apply.md +0 -333
- package/node_modules/pi-agent-text-editor/src/api/apply-renderer.ts +0 -3
- package/node_modules/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +0 -155
- package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +0 -344
- package/node_modules/pi-agent-text-editor/src/core/apply/final-mutations.ts +0 -50
- package/node_modules/pi-agent-text-editor/src/core/apply/format-source.ts +0 -11
- package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +0 -203
- package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +0 -55
- package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +0 -276
- package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +0 -13
- package/node_modules/pi-agent-text-editor/src/core/apply/queue.ts +0 -25
- package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +0 -405
- package/node_modules/pi-agent-text-editor/src/core/apply/results.ts +0 -133
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +0 -369
- package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +0 -148
- package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +0 -920
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +0 -52
- package/src/extensions/pi-agent-text-editor/src/api/apply-renderer.ts +0 -3
- package/src/extensions/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +0 -155
- package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +0 -344
- package/src/extensions/pi-agent-text-editor/src/core/apply/final-mutations.ts +0 -50
- package/src/extensions/pi-agent-text-editor/src/core/apply/format-source.ts +0 -11
- package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +0 -203
- package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +0 -55
- package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +0 -276
- package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +0 -13
- package/src/extensions/pi-agent-text-editor/src/core/apply/queue.ts +0 -25
- package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +0 -405
- package/src/extensions/pi-agent-text-editor/src/core/apply/results.ts +0 -133
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +0 -369
- package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +0 -148
- package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +0 -920
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +0 -52
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { requiredValue } from "pi-agent-invariant";
|
|
2
2
|
import {
|
|
3
3
|
createDiffModel,
|
|
4
|
+
compareInlineText,
|
|
4
5
|
DIFF_CONTEXT_LINES,
|
|
5
6
|
type DiffModel,
|
|
6
7
|
type DiffRow,
|
|
@@ -204,7 +205,7 @@ function advanceTypingProjectionResource(
|
|
|
204
205
|
);
|
|
205
206
|
const row = model.rows[rowIndex];
|
|
206
207
|
|
|
207
|
-
if (row === undefined || row.kind === "omitted") {
|
|
208
|
+
if (row === undefined || row.kind === "omitted" || row.beforeLine !== undefined) {
|
|
208
209
|
return undefined;
|
|
209
210
|
}
|
|
210
211
|
|
|
@@ -222,7 +223,7 @@ function advanceTypingProjectionResource(
|
|
|
222
223
|
}
|
|
223
224
|
|
|
224
225
|
const rows = [...model.rows];
|
|
225
|
-
const kind =
|
|
226
|
+
const kind = "added";
|
|
226
227
|
rows[rowIndex] = {
|
|
227
228
|
...row,
|
|
228
229
|
kind,
|
|
@@ -237,8 +238,8 @@ function advanceTypingProjectionResource(
|
|
|
237
238
|
model: {
|
|
238
239
|
...model,
|
|
239
240
|
rows,
|
|
240
|
-
added: model.added +
|
|
241
|
-
modified: model.modified
|
|
241
|
+
added: model.added + 1 - (row.kind === "added" ? 1 : 0),
|
|
242
|
+
modified: model.modified - (row.kind === "modified" ? 1 : 0),
|
|
242
243
|
focusRow: rowIndex,
|
|
243
244
|
},
|
|
244
245
|
};
|
|
@@ -272,6 +273,7 @@ function advanceFullFileTypingResource(
|
|
|
272
273
|
let added = model.added;
|
|
273
274
|
let modified = model.modified;
|
|
274
275
|
const isAfterNewline = previousVisibleText.endsWith("\n");
|
|
276
|
+
const deadline = performance.now() + 100;
|
|
275
277
|
const active = rows.at(-1);
|
|
276
278
|
const suffix = [...fullFileLines(isAfterNewline ? appended : `${active?.text ?? ""}${appended}`)];
|
|
277
279
|
|
|
@@ -281,8 +283,14 @@ function advanceFullFileTypingResource(
|
|
|
281
283
|
requiredValue(suffix[0]),
|
|
282
284
|
rows.length - 1,
|
|
283
285
|
visibleText.endsWith("\n") && suffix.length === 1 && requiredValue(suffix[0]).length === 0,
|
|
286
|
+
suffix.length > 1,
|
|
287
|
+
deadline,
|
|
284
288
|
);
|
|
285
|
-
if (
|
|
289
|
+
if (
|
|
290
|
+
active.text !== next.text ||
|
|
291
|
+
active.kind !== next.kind ||
|
|
292
|
+
active.deletedOffsets?.join(",") !== next.deletedOffsets?.join(",")
|
|
293
|
+
) {
|
|
286
294
|
added += (next.kind === "added" ? 1 : 0) - (active.kind === "added" ? 1 : 0);
|
|
287
295
|
modified += (next.kind === "modified" ? 1 : 0) - (active.kind === "modified" ? 1 : 0);
|
|
288
296
|
rows[rows.length - 1] = next;
|
|
@@ -296,6 +304,8 @@ function advanceFullFileTypingResource(
|
|
|
296
304
|
text,
|
|
297
305
|
rows.length,
|
|
298
306
|
offset === suffix.length - 1 && visibleText.endsWith("\n"),
|
|
307
|
+
offset < suffix.length - 1,
|
|
308
|
+
deadline,
|
|
299
309
|
);
|
|
300
310
|
rows.push(row);
|
|
301
311
|
modified += row.kind === "modified" ? 1 : 0;
|
|
@@ -326,6 +336,8 @@ function createTypingLine(
|
|
|
326
336
|
text: string,
|
|
327
337
|
index: number,
|
|
328
338
|
isTrailingCursorRow = false,
|
|
339
|
+
complete = false,
|
|
340
|
+
deadline = performance.now() + 100,
|
|
329
341
|
): DiffRow {
|
|
330
342
|
const beforeText = beforeLines[index];
|
|
331
343
|
if (isTrailingCursorRow || beforeText?.trim() === text.trim()) {
|
|
@@ -344,7 +356,7 @@ function createTypingLine(
|
|
|
344
356
|
...(beforeText !== undefined && { beforeLine: index + 1 }),
|
|
345
357
|
afterLine: index + 1,
|
|
346
358
|
changed: true,
|
|
347
|
-
|
|
359
|
+
...typingChanges(beforeText, text, complete, deadline),
|
|
348
360
|
};
|
|
349
361
|
}
|
|
350
362
|
|
|
@@ -462,9 +474,8 @@ function createTypingModel(
|
|
|
462
474
|
project: false,
|
|
463
475
|
focusAfterLine: cursorLine,
|
|
464
476
|
} as const;
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
);
|
|
477
|
+
const visibleModel = createDiffModel(beforeWindow, afterWindow, [], modelOptions);
|
|
478
|
+
const rows = visibleModel.rows.flatMap(projectTypingRow);
|
|
468
479
|
const focusRow = typingFocusRow(rows, cursorLine);
|
|
469
480
|
const finalAfterWindow =
|
|
470
481
|
resource.beforeContent.slice(windowFrom, beforeRange.from) +
|
|
@@ -483,6 +494,9 @@ function createTypingModel(
|
|
|
483
494
|
|
|
484
495
|
return {
|
|
485
496
|
rows: canonicalRows,
|
|
497
|
+
...(visibleModel.omittedChanges !== undefined && {
|
|
498
|
+
omittedChanges: visibleModel.omittedChanges,
|
|
499
|
+
}),
|
|
486
500
|
added: canonicalRows.filter(({ kind }) => kind === "added").length,
|
|
487
501
|
modified: canonicalRows.filter(({ kind }) => kind === "modified").length,
|
|
488
502
|
removed: 0,
|
|
@@ -510,6 +524,7 @@ function createFullFileTypingModel(
|
|
|
510
524
|
): DiffModel {
|
|
511
525
|
const beforeLines = fullFileLines(beforeContent);
|
|
512
526
|
const visibleLines = fullFileLines(visibleContent);
|
|
527
|
+
const deadline = performance.now() + 100;
|
|
513
528
|
const cursorLine = lineAtOffset(visibleContent, cursorOffset);
|
|
514
529
|
const rows: DiffRow[] = visibleLines.map((text, index) => {
|
|
515
530
|
const line = index + 1;
|
|
@@ -536,7 +551,7 @@ function createFullFileTypingModel(
|
|
|
536
551
|
...(beforeText !== undefined && { beforeLine: line }),
|
|
537
552
|
afterLine: line,
|
|
538
553
|
changed: true,
|
|
539
|
-
|
|
554
|
+
...typingChanges(beforeText, text, index < visibleLines.length - 1, deadline),
|
|
540
555
|
};
|
|
541
556
|
});
|
|
542
557
|
|
|
@@ -565,6 +580,21 @@ function projectTypingRow(row: DiffRow): readonly DiffRow[] {
|
|
|
565
580
|
return row.kind === "added" ? [{ ...row, addedRanges: typingTextRanges(row.text) }] : [row];
|
|
566
581
|
}
|
|
567
582
|
|
|
583
|
+
function typingChanges(
|
|
584
|
+
before: string | undefined,
|
|
585
|
+
after: string,
|
|
586
|
+
complete: boolean,
|
|
587
|
+
deadline: number,
|
|
588
|
+
) {
|
|
589
|
+
if (before === undefined) return { addedRanges: typingTextRanges(after) };
|
|
590
|
+
const changes = compareInlineText(before, after, deadline);
|
|
591
|
+
return changes === undefined
|
|
592
|
+
? { addedRanges: [], inlineUnavailable: true }
|
|
593
|
+
: {
|
|
594
|
+
...changes,
|
|
595
|
+
deletedOffsets: complete ? changes.deletedOffsets : [],
|
|
596
|
+
};
|
|
597
|
+
}
|
|
568
598
|
function typingTextRanges(text: string): readonly DiffTextRange[] {
|
|
569
599
|
const from = text.length - text.trimStart().length;
|
|
570
600
|
const to = text.trimEnd().length;
|
|
@@ -271,21 +271,9 @@ function createRenderer(
|
|
|
271
271
|
);
|
|
272
272
|
state.panel?.setPreviewResources([]);
|
|
273
273
|
|
|
274
|
-
if (
|
|
275
|
-
|
|
276
|
-
const succeeded = restored !== undefined && !context.isError;
|
|
277
|
-
return new Text(
|
|
278
|
-
theme.fg(
|
|
279
|
-
succeeded ? "success" : "error",
|
|
280
|
-
succeeded
|
|
281
|
-
? `✓ Undo applied · ${String(restored)} ${restored === 1 ? "file" : "files"}`
|
|
282
|
-
: "✗ Undo not applied",
|
|
283
|
-
),
|
|
284
|
-
0,
|
|
285
|
-
0,
|
|
286
|
-
);
|
|
274
|
+
if (!context.isError && result.details.metadata?.emptyTargets === true) {
|
|
275
|
+
return new Text(theme.fg("muted", "No changes · empty target set"), 0, 0);
|
|
287
276
|
}
|
|
288
|
-
|
|
289
277
|
const wholeFileSucceeded = wholeFileOperationSucceeded(result.details);
|
|
290
278
|
if (wholeFileSucceeded !== undefined) {
|
|
291
279
|
return new Text(
|
|
@@ -721,7 +709,14 @@ function mutationCallDetails(
|
|
|
721
709
|
|
|
722
710
|
const generated = generatedField(tool);
|
|
723
711
|
return Object.entries(input).map(([label, value]) => {
|
|
724
|
-
const encoded =
|
|
712
|
+
const encoded =
|
|
713
|
+
["path", "file", "target"].includes(label) && value !== null && typeof value === "object"
|
|
714
|
+
? Array.isArray(value)
|
|
715
|
+
? `${value.length} returned targets`
|
|
716
|
+
: "result scope"
|
|
717
|
+
: typeof value === "string"
|
|
718
|
+
? value
|
|
719
|
+
: JSON.stringify(value);
|
|
725
720
|
const exact = typeof encoded === "string" ? encoded : String(value);
|
|
726
721
|
return {
|
|
727
722
|
label,
|
|
@@ -733,14 +728,13 @@ function mutationCallDetails(
|
|
|
733
728
|
});
|
|
734
729
|
}
|
|
735
730
|
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
): string {
|
|
742
|
-
return renderHeader(registration, input, undefined, theme, undefined, false);
|
|
731
|
+
function sourceLabel(value: unknown): string | undefined {
|
|
732
|
+
if (typeof value === "string" && value.startsWith("RESULT#")) return "result scope";
|
|
733
|
+
return (
|
|
734
|
+
stringValue(value) ?? (value !== null && typeof value === "object" ? "result scope" : undefined)
|
|
735
|
+
);
|
|
743
736
|
}
|
|
737
|
+
|
|
744
738
|
function renderHeader(
|
|
745
739
|
registration: AnyTextMutationToolRegistration,
|
|
746
740
|
input: Readonly<Record<string, unknown>>,
|
|
@@ -750,9 +744,7 @@ function renderHeader(
|
|
|
750
744
|
expanded: boolean,
|
|
751
745
|
): string {
|
|
752
746
|
const source = registration.source;
|
|
753
|
-
|
|
754
|
-
return `${theme.fg("toolTitle", theme.bold("undo"))} ${theme.fg("muted", "· Apply transaction")}`;
|
|
755
|
-
const path = stringValue(input[source.field]);
|
|
747
|
+
const path = sourceLabel(input[source.field]);
|
|
756
748
|
const previewResources = preview?.kind === "completed" ? preview.resources : [];
|
|
757
749
|
const displayedPath =
|
|
758
750
|
path ??
|
|
@@ -766,10 +758,10 @@ function renderHeader(
|
|
|
766
758
|
? requiredValue(previewResources[0]).link
|
|
767
759
|
: resourceLink(preview, path);
|
|
768
760
|
const targets = (source.targets ?? [])
|
|
769
|
-
.map(({ field }) => ({ field, path:
|
|
761
|
+
.map(({ field }) => ({ field, path: sourceLabel(input[field]) }))
|
|
770
762
|
.filter(
|
|
771
763
|
(target): target is { readonly field: string; readonly path: string } =>
|
|
772
|
-
target.path !== undefined && target.path !== path,
|
|
764
|
+
target.path !== undefined && (target.path === "result scope" || target.path !== path),
|
|
773
765
|
);
|
|
774
766
|
let header = `${theme.fg("toolTitle", theme.bold(registration.name))} ${renderPath(
|
|
775
767
|
displayedPath,
|
|
@@ -864,24 +856,6 @@ function semanticRange(start: string, end: string): string {
|
|
|
864
856
|
: `${start}–${end}`;
|
|
865
857
|
}
|
|
866
858
|
|
|
867
|
-
function restoredApplyPathCount(details: unknown): number | undefined {
|
|
868
|
-
if (details === null || typeof details !== "object" || !("metadata" in details)) return undefined;
|
|
869
|
-
const metadata = details.metadata;
|
|
870
|
-
if (metadata === null || typeof metadata !== "object" || !("semanticAction" in metadata))
|
|
871
|
-
return undefined;
|
|
872
|
-
const action = metadata.semanticAction;
|
|
873
|
-
if (
|
|
874
|
-
action === null ||
|
|
875
|
-
typeof action !== "object" ||
|
|
876
|
-
!("kind" in action) ||
|
|
877
|
-
action.kind !== "apply-undo" ||
|
|
878
|
-
!("restored" in action) ||
|
|
879
|
-
!Array.isArray(action.restored)
|
|
880
|
-
)
|
|
881
|
-
return undefined;
|
|
882
|
-
return action.restored.length;
|
|
883
|
-
}
|
|
884
|
-
|
|
885
859
|
function wholeFileOperationSucceeded(details: unknown): boolean | undefined {
|
|
886
860
|
if (details === null || typeof details !== "object" || !("metadata" in details)) return undefined;
|
|
887
861
|
const metadata = details.metadata;
|
|
@@ -77,6 +77,7 @@ function createHandler(
|
|
|
77
77
|
const toolNames: string[] = [];
|
|
78
78
|
const knownPaths = new Map<number, string>();
|
|
79
79
|
const checks = new Map<number, Map<string, TextAnchorInspectionOutcome>>();
|
|
80
|
+
const blocks = new Map<number, Map<string, InterceptResult>>();
|
|
80
81
|
|
|
81
82
|
const handler: ToolCallInterceptorHandler = {
|
|
82
83
|
name: "text-editor-stale-anchor-inspection",
|
|
@@ -110,6 +111,7 @@ function createHandler(
|
|
|
110
111
|
arguments_,
|
|
111
112
|
source,
|
|
112
113
|
checks,
|
|
114
|
+
blocks,
|
|
113
115
|
);
|
|
114
116
|
|
|
115
117
|
if (pairBlock !== undefined) {
|
|
@@ -146,6 +148,7 @@ function createHandler(
|
|
|
146
148
|
[anchor],
|
|
147
149
|
[descriptor.kinds],
|
|
148
150
|
checks,
|
|
151
|
+
blocks,
|
|
149
152
|
);
|
|
150
153
|
|
|
151
154
|
if (block !== undefined) {
|
|
@@ -157,13 +160,16 @@ function createHandler(
|
|
|
157
160
|
},
|
|
158
161
|
onContentEnd(contentIndex) {
|
|
159
162
|
checks.delete(contentIndex);
|
|
163
|
+
blocks.delete(contentIndex);
|
|
160
164
|
},
|
|
161
165
|
onAbort(contentIndex) {
|
|
162
166
|
checks.delete(contentIndex);
|
|
167
|
+
blocks.delete(contentIndex);
|
|
163
168
|
knownPaths.delete(contentIndex);
|
|
164
169
|
},
|
|
165
170
|
onAgentEnd() {
|
|
166
171
|
checks.clear();
|
|
172
|
+
blocks.clear();
|
|
167
173
|
knownPaths.clear();
|
|
168
174
|
},
|
|
169
175
|
};
|
|
@@ -225,6 +231,7 @@ async function inspectAnchorPair(
|
|
|
225
231
|
arguments_: Record<string, unknown>,
|
|
226
232
|
source: string,
|
|
227
233
|
checks: Map<number, Map<string, TextAnchorInspectionOutcome>>,
|
|
234
|
+
blocks: Map<number, Map<string, InterceptResult>>,
|
|
228
235
|
): Promise<InterceptResult | undefined> {
|
|
229
236
|
if (schema.pair === undefined) {
|
|
230
237
|
return undefined;
|
|
@@ -261,6 +268,7 @@ async function inspectAnchorPair(
|
|
|
261
268
|
[start, end],
|
|
262
269
|
[startDescriptor.kinds, endDescriptor.kinds],
|
|
263
270
|
checks,
|
|
271
|
+
blocks,
|
|
264
272
|
);
|
|
265
273
|
}
|
|
266
274
|
|
|
@@ -273,6 +281,7 @@ async function inspectAnchors(
|
|
|
273
281
|
anchors: readonly [string] | readonly [string, string],
|
|
274
282
|
kinds: readonly [readonly string[]] | readonly [readonly string[], readonly string[]],
|
|
275
283
|
checks: Map<number, Map<string, TextAnchorInspectionOutcome>>,
|
|
284
|
+
blocks: Map<number, Map<string, InterceptResult>>,
|
|
276
285
|
): Promise<InterceptResult | undefined> {
|
|
277
286
|
const contentIndex = context.contentIndex ?? -1;
|
|
278
287
|
const key = `${source}${CACHE_KEY_PART_SEPARATOR}${anchors.join(
|
|
@@ -280,6 +289,8 @@ async function inspectAnchors(
|
|
|
280
289
|
)}${CACHE_KEY_PART_SEPARATOR}${kinds
|
|
281
290
|
.map((accepted) => accepted.join(CACHE_KEY_LIST_SEPARATOR))
|
|
282
291
|
.join(CACHE_KEY_PART_SEPARATOR)}`;
|
|
292
|
+
const cachedBlock = blocks.get(contentIndex)?.get(key);
|
|
293
|
+
if (cachedBlock !== undefined) return cachedBlock;
|
|
283
294
|
let result = checks.get(contentIndex)?.get(key);
|
|
284
295
|
|
|
285
296
|
if (result === undefined) {
|
|
@@ -337,7 +348,11 @@ async function inspectAnchors(
|
|
|
337
348
|
...(!(readContext === undefined || readContext.length === 0) && { context: readContext }),
|
|
338
349
|
};
|
|
339
350
|
|
|
340
|
-
|
|
351
|
+
const block = makeBlockResult(details, result.reason);
|
|
352
|
+
const contentBlocks = blocks.get(contentIndex) ?? new Map<string, InterceptResult>();
|
|
353
|
+
contentBlocks.set(key, block);
|
|
354
|
+
blocks.set(contentIndex, contentBlocks);
|
|
355
|
+
return block;
|
|
341
356
|
}
|
|
342
357
|
|
|
343
358
|
function makeResolverBlockResult(
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-text-editor-stale-anchor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"pi-agent-invariant": "0.
|
|
7
|
-
"pi-agent-read": "0.
|
|
8
|
-
"pi-agent-text-editor": "0.
|
|
6
|
+
"pi-agent-invariant": "0.7.0",
|
|
7
|
+
"pi-agent-read": "0.7.0",
|
|
8
|
+
"pi-agent-text-editor": "0.7.0"
|
|
9
9
|
},
|
|
10
10
|
"pi": {
|
|
11
11
|
"extensions": [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-tool-call-interception",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./src/index.ts",
|
|
6
6
|
"exports": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"pi-agent-tool-ui": "0.
|
|
13
|
+
"pi-agent-tool-ui": "0.7.0"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"@earendil-works/pi-coding-agent": "*",
|
|
@@ -316,3 +316,10 @@ function truncatePart(
|
|
|
316
316
|
const tailWidth = width - 1;
|
|
317
317
|
return `…${sliceByColumn(value, visibleWidth(value) - tailWidth, tailWidth, true)}`;
|
|
318
318
|
}
|
|
319
|
+
export {
|
|
320
|
+
ResultPanel,
|
|
321
|
+
sourceRows,
|
|
322
|
+
type ResultPanelRow,
|
|
323
|
+
type ResultPanelModel,
|
|
324
|
+
type SourcePreview,
|
|
325
|
+
} from "./result-panel.js";
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import {
|
|
3
|
+
getLanguageFromPath,
|
|
4
|
+
highlightCode,
|
|
5
|
+
keyText,
|
|
6
|
+
type Theme,
|
|
7
|
+
type ThemeColor,
|
|
8
|
+
} from "@earendil-works/pi-coding-agent";
|
|
9
|
+
import {
|
|
10
|
+
type Component,
|
|
11
|
+
truncateToWidth,
|
|
12
|
+
visibleWidth,
|
|
13
|
+
wrapTextWithAnsi,
|
|
14
|
+
sliceByColumn,
|
|
15
|
+
} from "@earendil-works/pi-tui";
|
|
16
|
+
import { singleLine, preserveEnclosingBackground } from "./index.js";
|
|
17
|
+
|
|
18
|
+
/** Source identity, highlighted code, or a concise explanation inside one result frame. */
|
|
19
|
+
export type ResultPanelRow =
|
|
20
|
+
| {
|
|
21
|
+
readonly kind: "source";
|
|
22
|
+
readonly label: string;
|
|
23
|
+
readonly link?: string;
|
|
24
|
+
readonly count?: number;
|
|
25
|
+
readonly badge?: string;
|
|
26
|
+
}
|
|
27
|
+
| {
|
|
28
|
+
readonly kind: "line";
|
|
29
|
+
readonly lineNumber: number;
|
|
30
|
+
readonly text: string;
|
|
31
|
+
readonly ranges: readonly { readonly from: number; readonly to: number }[];
|
|
32
|
+
}
|
|
33
|
+
| { readonly kind: "note"; readonly text: string; readonly expandedOnly?: boolean };
|
|
34
|
+
|
|
35
|
+
/** Presentation only: these rows never grant source or edit authority. */
|
|
36
|
+
export interface ResultPanelModel {
|
|
37
|
+
readonly summary: string;
|
|
38
|
+
readonly rows: readonly ResultPanelRow[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** A shared, bounded Search-style result frame for both source and readonly records. */
|
|
42
|
+
export class ResultPanel implements Component {
|
|
43
|
+
private cache: { width: number; lines: string[] } | undefined;
|
|
44
|
+
public constructor(
|
|
45
|
+
private model: ResultPanelModel,
|
|
46
|
+
private theme: Theme,
|
|
47
|
+
private expanded: boolean,
|
|
48
|
+
) {}
|
|
49
|
+
public update(model: ResultPanelModel, theme: Theme, expanded: boolean): void {
|
|
50
|
+
this.model = model;
|
|
51
|
+
this.theme = theme;
|
|
52
|
+
this.expanded = expanded;
|
|
53
|
+
this.invalidate();
|
|
54
|
+
}
|
|
55
|
+
public invalidate(): void {
|
|
56
|
+
this.cache = undefined;
|
|
57
|
+
}
|
|
58
|
+
public render(width: number): string[] {
|
|
59
|
+
if (this.cache?.width === width) return [...this.cache.lines];
|
|
60
|
+
if (width < 4) return [truncateToWidth(singleLine(this.model.summary), Math.max(1, width))];
|
|
61
|
+
const inner = width - 2;
|
|
62
|
+
const rows = this.model.rows.filter(
|
|
63
|
+
(row) => row.kind !== "note" || !row.expandedOnly || this.expanded,
|
|
64
|
+
);
|
|
65
|
+
const gutter = Math.max(
|
|
66
|
+
3,
|
|
67
|
+
...rows.map((row) => (row.kind === "line" ? String(row.lineNumber).length : 0)),
|
|
68
|
+
);
|
|
69
|
+
// Bound layout work as well as the finished compact viewport.
|
|
70
|
+
const selected = this.expanded ? rows : rows.slice(0, 13);
|
|
71
|
+
const code = highlightSourceRows(selected, this.theme);
|
|
72
|
+
let body = selected.flatMap((row) => this.renderRow(row, inner, gutter, code.get(row)));
|
|
73
|
+
if (!this.expanded && (body.length > 12 || selected.length < rows.length)) {
|
|
74
|
+
body = [
|
|
75
|
+
...body.slice(0, 11),
|
|
76
|
+
this.frame(
|
|
77
|
+
this.theme.fg("dim", ` … output truncated · ${keyText("app.tools.expand")} to expand`),
|
|
78
|
+
inner,
|
|
79
|
+
),
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
const title = truncateToWidth(` ${singleLine(this.model.summary)} `, inner - 1, "");
|
|
83
|
+
const border = (s: string) => this.theme.fg("borderMuted", s);
|
|
84
|
+
const output = [
|
|
85
|
+
`${border("╭─")}${this.theme.fg("accent", title)}${border(`${"─".repeat(Math.max(0, inner - visibleWidth(title) - 1))}╮`)}`,
|
|
86
|
+
...body,
|
|
87
|
+
border(`╰${"─".repeat(inner)}╯`),
|
|
88
|
+
].map((line) => truncateToWidth(line, width));
|
|
89
|
+
this.cache = { width, lines: output };
|
|
90
|
+
return [...output];
|
|
91
|
+
}
|
|
92
|
+
private frame(content: string, width: number, highlighted = false): string {
|
|
93
|
+
const clipped = truncateToWidth(content, width);
|
|
94
|
+
let body = clipped + " ".repeat(Math.max(0, width - visibleWidth(clipped)));
|
|
95
|
+
if (highlighted) {
|
|
96
|
+
const background = this.theme.bg("selectedBg", "").replace(/\u001B\[(?:0|49)m/gu, "");
|
|
97
|
+
body = this.theme.bg("selectedBg", preserveEnclosingBackground(body, background));
|
|
98
|
+
}
|
|
99
|
+
const border = this.theme.fg("borderMuted", "│");
|
|
100
|
+
return `${border}${body}${border}`;
|
|
101
|
+
}
|
|
102
|
+
private renderRow(row: ResultPanelRow, width: number, gutter: number, code?: string): string[] {
|
|
103
|
+
if (row.kind === "source") {
|
|
104
|
+
const badge = this.theme.fg(
|
|
105
|
+
badgeColor(row.label),
|
|
106
|
+
this.theme.bold(row.badge ?? fileBadge(row.label)),
|
|
107
|
+
);
|
|
108
|
+
const count =
|
|
109
|
+
row.count === undefined ? "" : this.theme.fg("accent", this.theme.bold(String(row.count)));
|
|
110
|
+
const available = Math.max(1, width - visibleWidth(badge) - visibleWidth(count) - 4);
|
|
111
|
+
const safe = singleLine(row.label);
|
|
112
|
+
const label =
|
|
113
|
+
visibleWidth(safe) <= available
|
|
114
|
+
? safe
|
|
115
|
+
: `…${sliceByColumn(safe, Math.max(0, visibleWidth(safe) - available + 1), available - 1, true)}`;
|
|
116
|
+
const separator = Math.max(label.lastIndexOf("/"), label.lastIndexOf("\\"));
|
|
117
|
+
const directory = label.slice(0, separator + 1);
|
|
118
|
+
const basename = label.slice(separator + 1);
|
|
119
|
+
let linked =
|
|
120
|
+
this.theme.fg("muted", directory) + this.theme.underline(this.theme.fg("accent", basename));
|
|
121
|
+
if (row.link && !/[\u0000-\u001F\u007F]/u.test(row.link))
|
|
122
|
+
linked = `\u001B]8;;${row.link}\u0007${linked}\u001B]8;;\u0007`;
|
|
123
|
+
const left = ` ${badge} ${linked}`;
|
|
124
|
+
return [
|
|
125
|
+
this.frame(
|
|
126
|
+
`${left}${" ".repeat(Math.max(1, width - visibleWidth(left) - visibleWidth(count) - 1))}${count} `,
|
|
127
|
+
width,
|
|
128
|
+
true,
|
|
129
|
+
),
|
|
130
|
+
];
|
|
131
|
+
}
|
|
132
|
+
if (row.kind === "note")
|
|
133
|
+
return [this.frame(this.theme.fg("dim", ` ${singleLine(row.text).slice(0, 2048)}`), width)];
|
|
134
|
+
const number = this.theme.fg("dim", String(row.lineNumber).padStart(gutter));
|
|
135
|
+
const prefix = ` ${number} ${this.theme.fg("borderMuted", "│")} `;
|
|
136
|
+
const available = Math.max(1, width - visibleWidth(prefix) - 1);
|
|
137
|
+
const preview = previewLine(row);
|
|
138
|
+
const wrapped = wrapTextWithAnsi(highlight(preview, this.theme, code), available);
|
|
139
|
+
const rendered = wrapped.map((line, index) =>
|
|
140
|
+
this.frame(`${index ? " ".repeat(visibleWidth(prefix)) : prefix}${line}`, width),
|
|
141
|
+
);
|
|
142
|
+
if (preview !== row)
|
|
143
|
+
rendered.push(
|
|
144
|
+
this.frame(this.theme.fg("dim", " … line shortened · read source for full text"), width),
|
|
145
|
+
);
|
|
146
|
+
return rendered;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** One exact source-line preview; offsets are UTF-16 positions in the unstyled text. */
|
|
151
|
+
export interface SourcePreview {
|
|
152
|
+
readonly source: string;
|
|
153
|
+
readonly label: string;
|
|
154
|
+
readonly link?: string;
|
|
155
|
+
readonly badge?: string;
|
|
156
|
+
readonly lineNumber: number;
|
|
157
|
+
readonly text: string;
|
|
158
|
+
readonly ranges: readonly { readonly from: number; readonly to: number }[];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Group source lines and merge highlights without duplicating context or changing input data. */
|
|
162
|
+
export function sourceRows(previews: readonly SourcePreview[]): ResultPanelRow[] {
|
|
163
|
+
const groups = new Map<
|
|
164
|
+
string,
|
|
165
|
+
{
|
|
166
|
+
first: SourcePreview;
|
|
167
|
+
lines: Map<number, { text: string; ranges: { from: number; to: number }[] }>;
|
|
168
|
+
}
|
|
169
|
+
>();
|
|
170
|
+
for (const preview of previews) {
|
|
171
|
+
let group = groups.get(preview.source);
|
|
172
|
+
if (!group) {
|
|
173
|
+
group = { first: preview, lines: new Map() };
|
|
174
|
+
groups.set(preview.source, group);
|
|
175
|
+
}
|
|
176
|
+
const previous = group.lines.get(preview.lineNumber);
|
|
177
|
+
if (previous) previous.ranges.push(...preview.ranges);
|
|
178
|
+
else group.lines.set(preview.lineNumber, { text: preview.text, ranges: [...preview.ranges] });
|
|
179
|
+
}
|
|
180
|
+
return [...groups.values()].flatMap(({ first, lines }): ResultPanelRow[] => [
|
|
181
|
+
{
|
|
182
|
+
kind: "source",
|
|
183
|
+
label: first.label,
|
|
184
|
+
...(first.link === undefined ? {} : { link: first.link }),
|
|
185
|
+
...(first.badge === undefined ? {} : { badge: first.badge }),
|
|
186
|
+
},
|
|
187
|
+
...[...lines.entries()]
|
|
188
|
+
.sort(([a], [b]) => a - b)
|
|
189
|
+
.map(([lineNumber, line]): ResultPanelRow => ({
|
|
190
|
+
kind: "line",
|
|
191
|
+
lineNumber,
|
|
192
|
+
text: line.text,
|
|
193
|
+
ranges: line.ranges,
|
|
194
|
+
})),
|
|
195
|
+
]);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function previewLine(row: Extract<ResultPanelRow, { kind: "line" }>): typeof row {
|
|
199
|
+
if (row.text.length <= 2048) return row;
|
|
200
|
+
const start = Math.max(0, (row.ranges[0]?.from ?? 0) - 64);
|
|
201
|
+
const end = Math.min(row.text.length, start + 256);
|
|
202
|
+
const prefix = start ? "…" : "";
|
|
203
|
+
return {
|
|
204
|
+
...row,
|
|
205
|
+
text: `${prefix}${row.text.slice(start, end)}${end < row.text.length ? "…" : ""}`,
|
|
206
|
+
ranges: row.ranges
|
|
207
|
+
.filter((r) => r.from < end && r.to > start)
|
|
208
|
+
.map((r) => ({
|
|
209
|
+
from: Math.max(r.from, start) - start + prefix.length,
|
|
210
|
+
to: Math.min(r.to, end) - start + prefix.length,
|
|
211
|
+
})),
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
function highlightSourceRows(
|
|
215
|
+
rows: readonly ResultPanelRow[],
|
|
216
|
+
theme: Theme,
|
|
217
|
+
): Map<ResultPanelRow, string> {
|
|
218
|
+
const output = new Map<ResultPanelRow, string>();
|
|
219
|
+
let language: string | undefined;
|
|
220
|
+
let group: Extract<ResultPanelRow, { kind: "line" }>[] = [];
|
|
221
|
+
const flush = () => {
|
|
222
|
+
if (!group.length) return;
|
|
223
|
+
const source = group.map((row) => safeCode(previewLine(row).text));
|
|
224
|
+
const colored = language
|
|
225
|
+
? highlightCode(source.join("\n"), language)
|
|
226
|
+
: source.map((text) => theme.fg("toolOutput", text));
|
|
227
|
+
group.forEach((row, index) => output.set(row, colored[index] ?? source[index] ?? ""));
|
|
228
|
+
group = [];
|
|
229
|
+
};
|
|
230
|
+
for (const row of rows) {
|
|
231
|
+
if (row.kind === "source") {
|
|
232
|
+
flush();
|
|
233
|
+
language =
|
|
234
|
+
row.badge === "WEB" || row.badge === "SH" ? undefined : getLanguageFromPath(row.label);
|
|
235
|
+
} else if (row.kind === "line") {
|
|
236
|
+
if (group.at(-1)?.lineNumber !== row.lineNumber - 1) flush();
|
|
237
|
+
group.push(row);
|
|
238
|
+
} else flush();
|
|
239
|
+
}
|
|
240
|
+
flush();
|
|
241
|
+
return output;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function highlight(
|
|
245
|
+
row: Extract<ResultPanelRow, { kind: "line" }>,
|
|
246
|
+
theme: Theme,
|
|
247
|
+
code?: string,
|
|
248
|
+
): string {
|
|
249
|
+
const styled = code ?? theme.fg("toolOutput", safeCode(row.text));
|
|
250
|
+
if (!row.ranges.length) return styled;
|
|
251
|
+
const fragment = (from: number, to: number) =>
|
|
252
|
+
sliceByColumn(
|
|
253
|
+
styled,
|
|
254
|
+
visibleWidth(safeCode(row.text.slice(0, from))),
|
|
255
|
+
visibleWidth(safeCode(row.text.slice(from, to))),
|
|
256
|
+
true,
|
|
257
|
+
);
|
|
258
|
+
const background = theme.bg("selectedBg", "").replace(/\u001B\[(?:0|49)m/gu, "");
|
|
259
|
+
let result = "";
|
|
260
|
+
let offset = 0;
|
|
261
|
+
for (const range of [...row.ranges].sort((a, b) => a.from - b.from)) {
|
|
262
|
+
const from = Math.max(offset, Math.min(row.text.length, range.from));
|
|
263
|
+
const to = Math.max(from, Math.min(row.text.length, range.to));
|
|
264
|
+
result += fragment(offset, from);
|
|
265
|
+
if (to > from)
|
|
266
|
+
result += theme.bg(
|
|
267
|
+
"selectedBg",
|
|
268
|
+
preserveEnclosingBackground(theme.bold(fragment(from, to)), background),
|
|
269
|
+
);
|
|
270
|
+
offset = to;
|
|
271
|
+
}
|
|
272
|
+
return result + fragment(offset, row.text.length);
|
|
273
|
+
}
|
|
274
|
+
function safeCode(text: string): string {
|
|
275
|
+
return singleLine(text.replaceAll("\t", " "));
|
|
276
|
+
}
|
|
277
|
+
function fileBadge(label: string): string {
|
|
278
|
+
return (
|
|
279
|
+
(
|
|
280
|
+
{
|
|
281
|
+
".ts": "TS",
|
|
282
|
+
".tsx": "TX",
|
|
283
|
+
".js": "JS",
|
|
284
|
+
".jsx": "JX",
|
|
285
|
+
".json": "{}",
|
|
286
|
+
".md": "MD",
|
|
287
|
+
".py": "PY",
|
|
288
|
+
".rs": "RS",
|
|
289
|
+
".go": "GO",
|
|
290
|
+
".css": "CS",
|
|
291
|
+
".html": "<>",
|
|
292
|
+
} as Record<string, string>
|
|
293
|
+
)[path.extname(label).toLowerCase()] ?? "◇"
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
function badgeColor(label: string): ThemeColor {
|
|
297
|
+
return /\.(?:js|jsx|json)$/iu.test(label) ? "warning" : "accent";
|
|
298
|
+
}
|