pi-agent-ide 0.6.4 → 0.7.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/CHANGELOG.md +45 -0
- package/README.md +2 -2
- package/dist/{chunk-AWXVJ5AC.js → chunk-2RTCSZB3.js} +1 -1
- package/dist/chunk-2TRHFMCZ.js +11 -0
- package/dist/{chunk-WJTHY6AG.js → chunk-4GCWGE2C.js} +1 -1
- package/dist/chunk-4XMY4H4V.js +1 -0
- package/dist/{chunk-BSICWXMH.js → chunk-64M3SQPG.js} +1 -1
- package/dist/{chunk-QEJGED4V.js → chunk-76ZK5ODR.js} +2 -2
- package/dist/{chunk-3BBJZSMS.js → chunk-7LD2OQH3.js} +1 -1
- package/dist/{chunk-6CZO43OH.js → chunk-BU7IZLKB.js} +1 -1
- package/dist/chunk-CWD4O5PM.js +3 -0
- package/dist/chunk-D3WTDA6V.js +2 -0
- package/dist/chunk-EAZGN5ND.js +7 -0
- package/dist/chunk-GXEGY7GV.js +1 -0
- package/dist/chunk-HZEY4GT4.js +2 -0
- package/dist/chunk-LEEQIQ7D.js +28 -0
- package/dist/chunk-NRZO5KJT.js +9 -0
- package/dist/chunk-OMVRLWMX.js +5 -0
- package/dist/{chunk-VBICI5YA.js → chunk-PGIVHICI.js} +1 -1
- package/dist/{chunk-FBOW7XOV.js → chunk-PKKDDIWW.js} +1 -1
- package/dist/chunk-PNU3E7IO.js +3 -0
- package/dist/chunk-PS2B6THP.js +3 -0
- package/dist/{chunk-FUG2TEKI.js → chunk-QFTBY67N.js} +2 -2
- package/dist/{chunk-EDURPQAV.js → chunk-QRJLIV6P.js} +6 -6
- package/dist/{chunk-OBNING2A.js → chunk-S5PL5DFQ.js} +1 -1
- package/dist/chunk-VMTR74FF.js +2 -0
- package/dist/{chunk-HPUAIWIH.js → chunk-WMO6RNE2.js} +1 -1
- package/dist/chunk-WU6ZK6YD.js +1 -0
- package/dist/{chunk-GIRAEVUJ.js → chunk-XH5WN5XA.js} +1 -1
- package/dist/chunk-XYS4FSCC.js +12 -0
- package/dist/chunk-YP46DVVP.js +2 -0
- 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-17.js +1 -1
- package/dist/entry-25.js +2 -2
- package/dist/entry-26.js +1 -1
- package/dist/entry-27.js +2 -2
- 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 +12 -9
- package/dist/entry-33.js +1 -1
- package/dist/entry-37.js +6 -6
- package/dist/entry-41.js +1 -1
- package/dist/entry-42.js +1 -1
- package/dist/entry-43.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +13 -14
- 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-56.js +1 -1
- package/dist/entry-57.js +1 -1
- package/dist/entry-58.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-71.js +0 -1
- package/dist/entry-72.js +1 -0
- package/dist/entry-73.js +0 -1
- package/dist/entry-74.js +1 -0
- package/dist/entry-75.js +1 -1
- package/dist/entry-76.js +1 -1
- package/dist/entry-77.js +66 -1
- package/dist/entry-78.js +14 -325
- package/dist/entry-79.js +2 -18
- package/dist/entry-80.js +1 -2
- package/dist/entry-81.js +1 -1
- package/dist/entry-82.js +5 -1
- package/dist/entry-83.js +3 -5
- package/dist/entry-84.js +1 -3
- package/dist/entry-85.js +1 -1
- package/dist/entry-86.js +1 -1
- package/dist/pi-agent-ide.js +14 -9
- package/docs/agent-guides/editing.md +38 -33
- package/docs/agent-guides/git-changes.md +1 -1
- package/docs/agent-guides/read-resources.md +8 -4
- package/docs/agent-guides/search-code.md +34 -2
- package/docs/agent-guides/select-code.md +115 -0
- package/docs/configuration.md +12 -17
- package/docs/development.md +2 -1
- package/docs/releases.md +1 -1
- 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 +2 -0
- package/docs/research/native-codemode-batching.md +1 -1
- package/docs/structured-results.md +30 -38
- package/docs/tools.md +11 -11
- 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-filesystem/index.ts +7 -6
- package/node_modules/pi-agent-filesystem/package.json +7 -7
- package/node_modules/pi-agent-filesystem-image/package.json +3 -3
- package/node_modules/pi-agent-filesystem-jq/index.ts +4 -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 +10 -5
- package/node_modules/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +142 -27
- 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 +268 -0
- package/node_modules/pi-agent-ide-changes/index.ts +6 -21
- package/node_modules/pi-agent-ide-changes/package.json +8 -8
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +2 -2
- 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 +5 -5
- 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 -45
- 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/plugin-protocol.ts +1 -1
- package/node_modules/pi-agent-read/src/api/read-parameters.ts +40 -3
- package/node_modules/pi-agent-read/src/api/tools/read.ts +11 -1
- package/node_modules/pi-agent-read/src/core/extension.ts +18 -1
- package/node_modules/pi-agent-read/src/core/read-core.ts +50 -35
- 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 +5 -3
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +17 -3
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/index.ts +10 -0
- package/node_modules/pi-agent-resource/src/result-targets.ts +407 -0
- package/node_modules/pi-agent-resource/src/tool-result.ts +13 -1
- package/node_modules/pi-agent-search/package.json +5 -5
- 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 +9 -3
- package/node_modules/pi-agent-search/src/api/search-scope.ts +22 -0
- package/node_modules/pi-agent-search/src/api/search.ts +28 -0
- package/node_modules/pi-agent-search/src/api/structured-result.ts +69 -14
- package/node_modules/pi-agent-search/src/core/extension.ts +56 -16
- package/node_modules/pi-agent-search/src/core/search-core.ts +9 -1
- package/node_modules/pi-agent-search-text/index.ts +3 -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 +161 -30
- package/node_modules/pi-agent-search-text/src/scoped-search.ts +103 -0
- package/node_modules/pi-agent-search-text/src/search-backend.ts +104 -17
- package/node_modules/pi-agent-search-text/src/search-renderer.ts +89 -292
- package/node_modules/pi-agent-search-text/src/search-result.ts +77 -0
- package/node_modules/pi-agent-search-text/src/search-session.ts +96 -11
- package/node_modules/pi-agent-text/package.json +2 -2
- package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-exact/index.ts +65 -4
- package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-exact/src/anchor.ts +12 -2
- package/node_modules/pi-agent-text-anchor-line-hash/index.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 +0 -5
- package/node_modules/pi-agent-text-editor/package.json +26 -31
- package/node_modules/pi-agent-text-editor/runtime/entry-77.js +1 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +3 -1
- package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +3 -1
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +1 -20
- package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +4 -23
- package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +2 -2
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +22 -5
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +29 -4
- package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +4 -14
- 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 +1 -1
- 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 +217 -30
- 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 +86 -154
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +6 -1
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +0 -75
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +238 -244
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +9 -11
- 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 +1 -72
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +19 -5
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +19 -45
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-80.js +1 -0
- package/node_modules/pi-agent-tool-call-interception/src/index.ts +3 -0
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- 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 +7 -3
- package/node_modules/pi-agent-web/package.json +8 -8
- package/node_modules/pi-agent-web/runtime/entry-82.js +2 -0
- package/node_modules/pi-agent-web/src/search.ts +111 -2
- package/node_modules/pi-agent-web-html/package.json +3 -3
- package/node_modules/pi-agent-web-image/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/package.json +35 -36
- package/src/composite/module-labels.ts +1 -1
- package/src/composite/preferences.ts +0 -5
- package/src/composite/text-results.ts +221 -0
- package/src/documentation/extension.ts +11 -9
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +7 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
- 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/index.ts +4 -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-web/index.ts +7 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -8
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-83.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-82.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/search.ts +111 -2
- package/src/extensions/pi-agent-read/package.json +7 -7
- package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +40 -3
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +11 -1
- package/src/extensions/pi-agent-read/src/core/extension.ts +18 -1
- package/src/extensions/pi-agent-read/src/core/read-core.ts +50 -35
- 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 +5 -3
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +17 -3
- package/src/extensions/pi-agent-search/package.json +5 -5
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +3 -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 +161 -30
- 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 +104 -17
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +89 -292
- 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 +96 -11
- 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 +9 -3
- package/src/extensions/pi-agent-search/src/api/search-scope.ts +22 -0
- package/src/extensions/pi-agent-search/src/api/search.ts +28 -0
- package/src/extensions/pi-agent-search/src/api/structured-result.ts +69 -14
- package/src/extensions/pi-agent-search/src/core/extension.ts +56 -16
- package/src/extensions/pi-agent-search/src/core/search-core.ts +9 -1
- package/src/extensions/pi-agent-text-editor/index.ts +0 -5
- package/src/extensions/pi-agent-text-editor/package.json +26 -31
- 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/index.ts +65 -4
- 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 +12 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.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 +1 -72
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-78.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +19 -5
- 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/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/runtime/entry-77.js +1 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +3 -1
- package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +3 -1
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +1 -20
- package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +4 -23
- package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +2 -2
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +22 -5
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +29 -4
- package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +4 -14
- 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 +1 -1
- 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 +217 -30
- 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 +86 -154
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +6 -1
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +0 -75
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +238 -244
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +9 -11
- 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 +4 -7
- 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 +10 -5
- package/src/plugins/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +142 -27
- 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 +268 -0
- package/src/plugins/pi-agent-ide-changes/index.ts +6 -21
- package/src/plugins/pi-agent-ide-changes/package.json +8 -8
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +2 -2
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +11 -40
- package/src/plugins/pi-agent-ide-debugger/index.ts +5 -3
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +5 -3
- 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 +5 -5
- 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 -45
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +8 -6
- package/src/plugins/pi-agent-ide-terminal/src/search.ts +10 -36
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +1 -1
- package/src/plugins/pi-agent-ide-vision/index.ts +31 -4
- package/dist/chunk-2P2OGO3G.js +0 -2
- package/dist/chunk-5J43L2RL.js +0 -11
- package/dist/chunk-6EYWFBNG.js +0 -0
- package/dist/chunk-7AVXUV4A.js +0 -7
- package/dist/chunk-7WCZOO5I.js +0 -1
- package/dist/chunk-BAYETTZZ.js +0 -16
- package/dist/chunk-BVK5A7ED.js +0 -28
- package/dist/chunk-F7NVAC4Q.js +0 -0
- package/dist/chunk-FZBCKIJJ.js +0 -1
- package/dist/chunk-I5JLCFUX.js +0 -1
- package/dist/chunk-KUPHNMUK.js +0 -2
- package/dist/chunk-MIZAFRDR.js +0 -1
- package/dist/chunk-PJPA5EEE.js +0 -2
- package/dist/chunk-PXWDDBBC.js +0 -0
- package/dist/chunk-SILJ3OL4.js +0 -9
- package/dist/chunk-TQZBVOTT.js +0 -5
- package/dist/chunk-VWW3RLUX.js +0 -12
- package/dist/chunk-YHUTTZC6.js +0 -2
- package/dist/chunk-ZODCBFBL.js +0 -2
- package/dist/entry-87.js +0 -1
- 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 -159
- package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +0 -405
- 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 -137
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +0 -369
- package/node_modules/pi-agent-text-editor/src/core/apply/structured-result.ts +0 -251
- package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +0 -168
- package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +0 -942
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +0 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-82.js +0 -1
- package/node_modules/pi-agent-web-text/runtime/entry-87.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-87.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-83.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +0 -2
- package/src/extensions/pi-agent-text-editor/runtime/entry-78.js +0 -2
- 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 -159
- package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +0 -405
- 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 -137
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +0 -369
- package/src/extensions/pi-agent-text-editor/src/core/apply/structured-result.ts +0 -251
- package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +0 -168
- package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +0 -942
- /package/node_modules/{pi-agent-text-editor → pi-agent-text-editor-renderer}/runtime/entry-78.js +0 -0
- /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-79.js +0 -0
- /package/node_modules/{pi-agent-tool-call-interception → pi-agent-tool-ui}/runtime/entry-81.js +0 -0
- /package/node_modules/{pi-agent-web → pi-agent-web-html}/runtime/entry-83.js +0 -0
- /package/node_modules/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-84.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-85.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-86.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-84.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-85.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-86.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-79.js +0 -0
|
@@ -43,6 +43,7 @@ export async function searchText(
|
|
|
43
43
|
request: TextSearchRequest,
|
|
44
44
|
cwd: string,
|
|
45
45
|
signal?: AbortSignal,
|
|
46
|
+
budget?: SearchCaptureBudget,
|
|
46
47
|
): Promise<TextSearchBackendResult> {
|
|
47
48
|
if (request.query.length === 0) {
|
|
48
49
|
throw new Error("Search query must not be empty.");
|
|
@@ -53,42 +54,106 @@ export async function searchText(
|
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
if (request.condition !== undefined) return searchBoolean(request, cwd, signal);
|
|
56
|
-
return searchPattern(request, cwd, signal);
|
|
57
|
+
return searchPattern(request, cwd, signal, undefined, budget);
|
|
57
58
|
}
|
|
58
59
|
|
|
60
|
+
/** Reuse ordinary text-search scope, ignores, and glob parsing for the extra scan. */
|
|
61
|
+
export async function ripgrepScope(request: TextSearchRequest, cwd: string) {
|
|
62
|
+
const target = path.resolve(cwd, stripFilePrefix(request.path ?? "."));
|
|
63
|
+
const directory = (await stat(target)).isDirectory();
|
|
64
|
+
return {
|
|
65
|
+
cwd: directory ? target : path.dirname(target),
|
|
66
|
+
target: directory ? "." : path.basename(target),
|
|
67
|
+
arguments: [
|
|
68
|
+
"--no-config",
|
|
69
|
+
"--no-ignore-parent",
|
|
70
|
+
"--color=never",
|
|
71
|
+
...splitGlobList(request.include).flatMap((glob) => ["--glob", glob]),
|
|
72
|
+
...splitGlobList(request.exclude).flatMap((glob) => ["--glob", `!${glob}`]),
|
|
73
|
+
],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/** Internal capture bounds for candidate verification; ordinary Search keeps its full capture. */
|
|
77
|
+
export interface SearchCaptureBudget {
|
|
78
|
+
readonly matches: number;
|
|
79
|
+
readonly bytes: number;
|
|
80
|
+
}
|
|
59
81
|
type MatchingLine = (source: string, lineNumber: number) => void;
|
|
60
82
|
|
|
83
|
+
/** Search exactly the supplied source text with the same ripgrep engine as file searches. */
|
|
84
|
+
export async function searchTextContent(
|
|
85
|
+
request: TextSearchRequest,
|
|
86
|
+
content: string,
|
|
87
|
+
cwd: string,
|
|
88
|
+
signal?: AbortSignal,
|
|
89
|
+
): Promise<TextSearchBackendResult> {
|
|
90
|
+
if (request.condition !== undefined)
|
|
91
|
+
throw new Error("Boolean scoped search is not available yet.");
|
|
92
|
+
if (/\r|\n/u.test(request.query)) throw new Error("Search supports one-line patterns only.");
|
|
93
|
+
const result = await runRipgrep(
|
|
94
|
+
[
|
|
95
|
+
"--json",
|
|
96
|
+
"--no-config",
|
|
97
|
+
"--color=never",
|
|
98
|
+
"--with-filename",
|
|
99
|
+
"--line-number",
|
|
100
|
+
...(request.regex === true ? ["--engine", "auto"] : ["--fixed-strings"]),
|
|
101
|
+
request.caseSensitive === true ? "--case-sensitive" : "--ignore-case",
|
|
102
|
+
...(request.wholeWord === true ? ["--word-regexp"] : []),
|
|
103
|
+
"--",
|
|
104
|
+
request.query,
|
|
105
|
+
"-",
|
|
106
|
+
],
|
|
107
|
+
cwd,
|
|
108
|
+
signal,
|
|
109
|
+
undefined,
|
|
110
|
+
undefined,
|
|
111
|
+
// An empty source still has one position. Ripgrep excludes the record delimiter from matches.
|
|
112
|
+
content.length === 0 ? "\n" : content,
|
|
113
|
+
);
|
|
114
|
+
return content.length === 0
|
|
115
|
+
? {
|
|
116
|
+
...result,
|
|
117
|
+
matches: result.matches.filter(
|
|
118
|
+
(match) => match.lineNumber === 1 && match.startColumn === 0 && match.endColumn === 0,
|
|
119
|
+
),
|
|
120
|
+
}
|
|
121
|
+
: result;
|
|
122
|
+
}
|
|
123
|
+
|
|
61
124
|
async function searchPattern(
|
|
62
125
|
request: TextSearchRequest,
|
|
63
126
|
cwd: string,
|
|
64
127
|
signal?: AbortSignal,
|
|
65
128
|
onLine?: MatchingLine,
|
|
129
|
+
budget?: SearchCaptureBudget,
|
|
66
130
|
): Promise<TextSearchBackendResult> {
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
const searchCwd = directory ? target : path.dirname(target);
|
|
131
|
+
const scope = await ripgrepScope(request, cwd);
|
|
132
|
+
const searchCwd = scope.cwd;
|
|
70
133
|
const commonArguments = [
|
|
71
134
|
"--json",
|
|
72
|
-
"--no-config",
|
|
73
|
-
"--no-ignore-parent",
|
|
74
|
-
"--color=never",
|
|
75
135
|
"--with-filename",
|
|
76
136
|
"--line-number",
|
|
77
137
|
request.caseSensitive === true ? "--case-sensitive" : "--ignore-case",
|
|
78
138
|
...(request.wholeWord === true ? ["--word-regexp"] : []),
|
|
79
|
-
...
|
|
80
|
-
...splitGlobList(request.exclude).flatMap((glob) => ["--glob", `!${glob}`]),
|
|
139
|
+
...scope.arguments,
|
|
81
140
|
"--",
|
|
82
141
|
request.query,
|
|
83
|
-
|
|
142
|
+
scope.target,
|
|
84
143
|
];
|
|
85
144
|
|
|
86
145
|
if (request.regex !== true) {
|
|
87
|
-
return runRipgrep(["--fixed-strings", ...commonArguments], searchCwd, signal, onLine);
|
|
146
|
+
return runRipgrep(["--fixed-strings", ...commonArguments], searchCwd, signal, onLine, budget);
|
|
88
147
|
}
|
|
89
148
|
|
|
90
149
|
try {
|
|
91
|
-
return await runRipgrep(
|
|
150
|
+
return await runRipgrep(
|
|
151
|
+
["--engine", "auto", ...commonArguments],
|
|
152
|
+
searchCwd,
|
|
153
|
+
signal,
|
|
154
|
+
onLine,
|
|
155
|
+
budget,
|
|
156
|
+
);
|
|
92
157
|
} catch (error) {
|
|
93
158
|
if (!isPcre2MatchLimitError(error)) {
|
|
94
159
|
if (
|
|
@@ -108,6 +173,7 @@ async function searchPattern(
|
|
|
108
173
|
searchCwd,
|
|
109
174
|
signal,
|
|
110
175
|
onLine,
|
|
176
|
+
budget,
|
|
111
177
|
);
|
|
112
178
|
} catch (fallbackError) {
|
|
113
179
|
if (signal?.aborted) throw fallbackError;
|
|
@@ -171,13 +237,29 @@ function runRipgrep(
|
|
|
171
237
|
cwd: string,
|
|
172
238
|
signal?: AbortSignal,
|
|
173
239
|
onLine?: MatchingLine,
|
|
240
|
+
budget?: SearchCaptureBudget,
|
|
241
|
+
input?: string,
|
|
174
242
|
): Promise<TextSearchBackendResult> {
|
|
175
243
|
return new Promise((resolve, reject) => {
|
|
176
244
|
const child = spawn(resolveRipgrepExecutable(), arguments_, {
|
|
177
|
-
stdio: ["
|
|
245
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
178
246
|
cwd,
|
|
179
247
|
});
|
|
248
|
+
let bytes = 0;
|
|
249
|
+
let limited = false;
|
|
250
|
+
if (budget !== undefined)
|
|
251
|
+
child.stdout.on("data", (chunk: Buffer) => {
|
|
252
|
+
bytes += chunk.length;
|
|
253
|
+
if (bytes > budget.bytes) {
|
|
254
|
+
limited = true;
|
|
255
|
+
child.kill();
|
|
256
|
+
}
|
|
257
|
+
});
|
|
180
258
|
const output = createInterface({ input: child.stdout });
|
|
259
|
+
child.stdin.on("error", () => {
|
|
260
|
+
/* The process close/error event reports failed searches. */
|
|
261
|
+
});
|
|
262
|
+
child.stdin.end(input);
|
|
181
263
|
const matches: TextSearchMatch[] = [];
|
|
182
264
|
let stderr = "";
|
|
183
265
|
let parseError: unknown;
|
|
@@ -195,7 +277,7 @@ function runRipgrep(
|
|
|
195
277
|
stderr += chunk;
|
|
196
278
|
});
|
|
197
279
|
output.on("line", (line) => {
|
|
198
|
-
if (parseError !== undefined || line.length === 0) {
|
|
280
|
+
if (limited || parseError !== undefined || line.length === 0) {
|
|
199
281
|
return;
|
|
200
282
|
}
|
|
201
283
|
|
|
@@ -214,6 +296,11 @@ function runRipgrep(
|
|
|
214
296
|
return;
|
|
215
297
|
}
|
|
216
298
|
for (const match of matchesFromEvent(event as RipgrepMatchEvent, cwd)) {
|
|
299
|
+
if (budget !== undefined && matches.length === budget.matches) {
|
|
300
|
+
limited = true;
|
|
301
|
+
child.kill();
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
217
304
|
matches.push(match);
|
|
218
305
|
}
|
|
219
306
|
} catch (error) {
|
|
@@ -240,13 +327,13 @@ function runRipgrep(
|
|
|
240
327
|
return;
|
|
241
328
|
}
|
|
242
329
|
|
|
243
|
-
if (code !== 0 && code !== 1) {
|
|
330
|
+
if (!limited && code !== 0 && code !== 1) {
|
|
244
331
|
reject(new Error(stderr.trim() || `ripgrep exited with code ${String(code)}.`));
|
|
245
332
|
return;
|
|
246
333
|
}
|
|
247
334
|
|
|
248
335
|
matches.sort(compareMatches);
|
|
249
|
-
resolve({ matches, complete:
|
|
336
|
+
resolve({ matches, complete: !limited });
|
|
250
337
|
});
|
|
251
338
|
|
|
252
339
|
signal?.addEventListener("abort", abort, { once: true });
|
|
@@ -280,7 +367,7 @@ function matchesFromEvent(event: RipgrepMatchEvent, cwd: string): TextSearchMatc
|
|
|
280
367
|
const matches: TextSearchMatch[] = [];
|
|
281
368
|
|
|
282
369
|
for (const submatch of event.data.submatches) {
|
|
283
|
-
if (submatch.start < 0 || submatch.end
|
|
370
|
+
if (submatch.start < 0 || submatch.end < submatch.start || submatch.end > lineBuffer.length) {
|
|
284
371
|
continue;
|
|
285
372
|
}
|
|
286
373
|
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { requiredValue } from "pi-agent-invariant";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
|
|
4
1
|
import {
|
|
5
2
|
type AgentToolResult,
|
|
6
3
|
keyText,
|
|
@@ -8,41 +5,15 @@ import {
|
|
|
8
5
|
type ThemeColor,
|
|
9
6
|
type ToolRenderResultOptions,
|
|
10
7
|
} from "@earendil-works/pi-coding-agent";
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
Text,
|
|
14
|
-
truncateToWidth,
|
|
15
|
-
visibleWidth,
|
|
16
|
-
wrapTextWithAnsi,
|
|
17
|
-
} from "@earendil-works/pi-tui";
|
|
18
|
-
|
|
8
|
+
import { type Component, Text } from "@earendil-works/pi-tui";
|
|
9
|
+
import { ResultPanel, type ResultPanelRow } from "pi-agent-tool-ui";
|
|
19
10
|
import { isSearchToolDetails } from "#src/search-result.js";
|
|
20
|
-
|
|
21
11
|
import { restoreSearchDetails } from "#src/persisted-result.js";
|
|
22
|
-
|
|
23
12
|
const restoredDetails = new WeakMap<object, SearchToolDetails>();
|
|
24
13
|
|
|
25
14
|
import type { SearchResultFile, SearchResultLine, SearchToolDetails } from "#src/search-result.js";
|
|
26
15
|
|
|
27
16
|
const COMPACT_SEARCH_ROWS = 12;
|
|
28
|
-
const FULL_LINE_CHARACTERS = 2048;
|
|
29
|
-
const PREVIEW_CHARACTERS = 256;
|
|
30
|
-
|
|
31
|
-
const FILE_BADGES: Readonly<
|
|
32
|
-
Record<string, { readonly label: string; readonly color: ThemeColor }>
|
|
33
|
-
> = {
|
|
34
|
-
".ts": { label: "TS", color: "accent" },
|
|
35
|
-
".tsx": { label: "TX", color: "accent" },
|
|
36
|
-
".js": { label: "JS", color: "warning" },
|
|
37
|
-
".jsx": { label: "JX", color: "warning" },
|
|
38
|
-
".json": { label: "{}", color: "warning" },
|
|
39
|
-
".md": { label: "MD", color: "mdHeading" },
|
|
40
|
-
".py": { label: "PY", color: "accent" },
|
|
41
|
-
".rs": { label: "RS", color: "accent" },
|
|
42
|
-
".go": { label: "GO", color: "accent" },
|
|
43
|
-
".css": { label: "CS", color: "accent" },
|
|
44
|
-
".html": { label: "<>", color: "accent" },
|
|
45
|
-
};
|
|
46
17
|
|
|
47
18
|
interface SearchRenderContext {
|
|
48
19
|
readonly lastComponent: Component | undefined;
|
|
@@ -50,6 +21,7 @@ interface SearchRenderContext {
|
|
|
50
21
|
}
|
|
51
22
|
|
|
52
23
|
type SearchPanelRow =
|
|
24
|
+
| { readonly kind: "candidate"; readonly identifier: string }
|
|
53
25
|
| { readonly kind: "file"; readonly file: SearchResultFile }
|
|
54
26
|
| { readonly kind: "line"; readonly file: SearchResultFile; readonly line: SearchResultLine }
|
|
55
27
|
| { readonly kind: "summary"; readonly text: string }
|
|
@@ -83,65 +55,47 @@ export function renderSearchResult(
|
|
|
83
55
|
const previous =
|
|
84
56
|
context.lastComponent instanceof SearchResultPanel ? context.lastComponent : undefined;
|
|
85
57
|
const panel = previous ?? new SearchResultPanel(result.details, theme, options.expanded);
|
|
86
|
-
panel.
|
|
58
|
+
panel.updateSearch(result.details, theme, options.expanded);
|
|
87
59
|
return panel;
|
|
88
60
|
}
|
|
89
61
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (
|
|
112
|
-
return
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const innerWidth = width - 2;
|
|
122
|
-
const rows = searchViewport(this.details, this.expanded);
|
|
123
|
-
const gutterWidth = maximumLineNumberWidth(this.details.files);
|
|
124
|
-
const renderedRows = rows.flatMap((row) =>
|
|
125
|
-
renderPanelRow(row, innerWidth, gutterWidth, this.theme),
|
|
126
|
-
);
|
|
127
|
-
const visibleRows = compactRenderedRows(renderedRows, this.expanded, innerWidth, this.theme);
|
|
128
|
-
const lines = [renderTopBorder(this.details, innerWidth, this.theme), ...visibleRows];
|
|
129
|
-
|
|
130
|
-
lines.push(this.theme.fg("borderMuted", `╰${"─".repeat(innerWidth)}╯`));
|
|
131
|
-
const clipped = lines.map((line) => truncateToWidth(line, width));
|
|
132
|
-
this.cached = { width, lines: clipped };
|
|
133
|
-
return clipped;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
public invalidate(): void {
|
|
137
|
-
this.cached = undefined;
|
|
138
|
-
}
|
|
62
|
+
/** Adapt Search counts and compacted groups to the shared result frame. */
|
|
63
|
+
export class SearchResultPanel extends ResultPanel {
|
|
64
|
+
public constructor(details: SearchToolDetails, theme: Theme, expanded: boolean) {
|
|
65
|
+
super(searchModel(details, expanded), theme, expanded);
|
|
66
|
+
}
|
|
67
|
+
public updateSearch(details: SearchToolDetails, theme: Theme, expanded: boolean): void {
|
|
68
|
+
super.update(searchModel(details, expanded), theme, expanded);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function searchModel(details: SearchToolDetails, expanded: boolean) {
|
|
72
|
+
const rows = searchViewport(details, expanded).map((row): ResultPanelRow => {
|
|
73
|
+
if (row.kind === "file")
|
|
74
|
+
return {
|
|
75
|
+
kind: "source",
|
|
76
|
+
label: row.file.path,
|
|
77
|
+
link: row.file.link,
|
|
78
|
+
count: row.file.matchCount,
|
|
79
|
+
};
|
|
80
|
+
if (row.kind === "line") return { kind: "line", ...row.line };
|
|
81
|
+
if (row.kind === "candidate") return { kind: "note", text: row.identifier };
|
|
82
|
+
if (row.kind === "summary") return { kind: "note", text: row.text };
|
|
83
|
+
if (row.kind === "omitted")
|
|
84
|
+
return {
|
|
85
|
+
kind: "note",
|
|
86
|
+
text: `… ${row.matches} more ${plural(row.matches, "match", "matches")} · ${keyText("app.tools.expand")} to expand`,
|
|
87
|
+
};
|
|
88
|
+
return { kind: "note", text: "No matches found" };
|
|
89
|
+
});
|
|
90
|
+
return { summary: searchSummary(details), rows };
|
|
139
91
|
}
|
|
140
|
-
|
|
141
92
|
function searchViewport(details: SearchToolDetails, expanded: boolean): readonly SearchPanelRow[] {
|
|
142
|
-
const
|
|
93
|
+
const hasCandidates = details.fuzzy?.status === "ready" && details.fuzzy.candidates.length > 0;
|
|
94
|
+
const rows: SearchPanelRow[] =
|
|
143
95
|
details.files.length === 0
|
|
144
|
-
?
|
|
96
|
+
? hasCandidates
|
|
97
|
+
? []
|
|
98
|
+
: [{ kind: "empty" } satisfies SearchPanelRow]
|
|
145
99
|
: details.files.flatMap((file): SearchPanelRow[] => [
|
|
146
100
|
{ kind: "file", file },
|
|
147
101
|
...(file.uniqueLineCount === undefined
|
|
@@ -158,7 +112,41 @@ function searchViewport(details: SearchToolDetails, expanded: boolean): readonly
|
|
|
158
112
|
]),
|
|
159
113
|
]);
|
|
160
114
|
|
|
161
|
-
if (
|
|
115
|
+
if (details.fuzzy !== undefined) {
|
|
116
|
+
if (details.fuzzy.status === "skipped")
|
|
117
|
+
rows.push({
|
|
118
|
+
kind: "summary",
|
|
119
|
+
text: "Fuzzy search unavailable",
|
|
120
|
+
});
|
|
121
|
+
else if (details.fuzzy.candidates.length > 0) {
|
|
122
|
+
rows.push(
|
|
123
|
+
...details.fuzzy.candidates.flatMap((candidate): SearchPanelRow[] => {
|
|
124
|
+
const files =
|
|
125
|
+
details.fuzzyPresentation?.groups.find(
|
|
126
|
+
(group) => group.identifier === candidate.identifier,
|
|
127
|
+
)?.files ?? [];
|
|
128
|
+
const previewCount = files.reduce((count, file) => count + file.matchCount, 0);
|
|
129
|
+
return [
|
|
130
|
+
{ kind: "candidate", identifier: candidate.identifier },
|
|
131
|
+
...(files.length === 0
|
|
132
|
+
? []
|
|
133
|
+
: [
|
|
134
|
+
{
|
|
135
|
+
kind: "summary",
|
|
136
|
+
text: `Shown ${String(previewCount)} of ${String(candidate.matchCount)}${candidate.selection.complete ? "" : "+"}`,
|
|
137
|
+
} as const,
|
|
138
|
+
...files.flatMap((file): SearchPanelRow[] => [
|
|
139
|
+
{ kind: "file", file },
|
|
140
|
+
...file.lines.map((line): SearchPanelRow => ({ kind: "line", file, line })),
|
|
141
|
+
]),
|
|
142
|
+
]),
|
|
143
|
+
];
|
|
144
|
+
}),
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (details.fuzzy !== undefined || expanded || rows.length <= COMPACT_SEARCH_ROWS) {
|
|
162
150
|
return rows;
|
|
163
151
|
}
|
|
164
152
|
|
|
@@ -181,147 +169,25 @@ function searchViewport(details: SearchToolDetails, expanded: boolean): readonly
|
|
|
181
169
|
];
|
|
182
170
|
}
|
|
183
171
|
|
|
184
|
-
function
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
const hint = `${keyText("app.tools.expand")} to expand`;
|
|
195
|
-
const notice = framed(theme.fg("dim", ` … output truncated · ${hint}`), width, theme);
|
|
196
|
-
return [...rows.slice(0, COMPACT_SEARCH_ROWS - 1), notice];
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
function renderPanelRow(
|
|
200
|
-
row: SearchPanelRow,
|
|
201
|
-
width: number,
|
|
202
|
-
gutterWidth: number,
|
|
203
|
-
theme: Theme,
|
|
204
|
-
): readonly string[] {
|
|
205
|
-
if (row.kind === "file") {
|
|
206
|
-
return [framed(renderFileHeader(row.file, width, theme), width, theme, true)];
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (row.kind === "line") {
|
|
210
|
-
return renderMatchLine(row.line, width, gutterWidth, theme);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
if (row.kind === "summary") {
|
|
214
|
-
return [
|
|
215
|
-
framed(
|
|
216
|
-
theme.fg(
|
|
217
|
-
"dim",
|
|
218
|
-
` ${safeText(row.text.length > FULL_LINE_CHARACTERS ? `${row.text.slice(0, PREVIEW_CHARACTERS)}…` : row.text)}`,
|
|
219
|
-
),
|
|
220
|
-
width,
|
|
221
|
-
theme,
|
|
222
|
-
),
|
|
223
|
-
];
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
if (row.kind === "omitted") {
|
|
227
|
-
const hint = `${keyText("app.tools.expand")} to expand`;
|
|
228
|
-
return [
|
|
229
|
-
framed(
|
|
230
|
-
theme.fg(
|
|
231
|
-
"dim",
|
|
232
|
-
` … ${String(row.matches)} more ${plural(row.matches, "match", "matches")} · ${hint}`,
|
|
233
|
-
),
|
|
234
|
-
width,
|
|
235
|
-
theme,
|
|
236
|
-
),
|
|
237
|
-
];
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
return [framed(theme.fg("dim", " No matches found"), width, theme)];
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
function renderFileHeader(file: SearchResultFile, width: number, theme: Theme): string {
|
|
244
|
-
const badge = fileBadge(file.path, theme);
|
|
245
|
-
const count = theme.fg("accent", theme.bold(String(file.matchCount)));
|
|
246
|
-
const fixedWidth = visibleWidth(badge) + visibleWidth(count) + 4;
|
|
247
|
-
const pathWidth = Math.max(1, width - fixedWidth);
|
|
248
|
-
const displayedPath = truncatePath(file.path, pathWidth);
|
|
249
|
-
const linkedPath = fileLink(displayedPath, file.link, theme);
|
|
250
|
-
const left = ` ${badge} ${linkedPath}`;
|
|
251
|
-
const gap = " ".repeat(Math.max(1, width - visibleWidth(left) - visibleWidth(count) - 1));
|
|
252
|
-
return truncateToWidth(`${left}${gap}${count} `, width);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
function renderMatchLine(
|
|
256
|
-
line: SearchResultLine,
|
|
257
|
-
width: number,
|
|
258
|
-
gutterWidth: number,
|
|
259
|
-
theme: Theme,
|
|
260
|
-
): readonly string[] {
|
|
261
|
-
const number = String(line.lineNumber).padStart(gutterWidth);
|
|
262
|
-
const gutter = ` ${theme.fg("dim", number)} ${theme.fg("borderMuted", "│")} `;
|
|
263
|
-
const contentWidth = Math.max(1, width - visibleWidth(gutter) - 1);
|
|
264
|
-
const preview = previewMatchLine(line);
|
|
265
|
-
const wrapped = wrapTextWithAnsi(renderHighlightedLine(preview, theme), contentWidth);
|
|
266
|
-
const continuationGutter = " ".repeat(visibleWidth(gutter));
|
|
267
|
-
|
|
268
|
-
const rows = wrapped.map((content, index) =>
|
|
269
|
-
framed(`${index === 0 ? gutter : continuationGutter}${content}`, width, theme),
|
|
270
|
-
);
|
|
271
|
-
if (preview !== line)
|
|
272
|
-
rows.push(
|
|
273
|
-
framed(theme.fg("dim", " … line shortened · read file for full text"), width, theme),
|
|
172
|
+
function searchSummary(details: SearchToolDetails): string {
|
|
173
|
+
if (
|
|
174
|
+
details.matchCount === 0 &&
|
|
175
|
+
details.fuzzy?.status === "ready" &&
|
|
176
|
+
details.fuzzy.candidates.length > 0 &&
|
|
177
|
+
details.fuzzyPresentation !== undefined
|
|
178
|
+
) {
|
|
179
|
+
const count = details.fuzzy.candidates.reduce(
|
|
180
|
+
(total, candidate) => total + candidate.matchCount,
|
|
181
|
+
0,
|
|
274
182
|
);
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
if (line.text.length <= FULL_LINE_CHARACTERS) return line;
|
|
281
|
-
const start = Math.max(0, (line.ranges[0]?.from ?? 0) - 64);
|
|
282
|
-
const end = Math.min(line.text.length, start + PREVIEW_CHARACTERS);
|
|
283
|
-
const prefix = start > 0 ? "…" : "";
|
|
284
|
-
return {
|
|
285
|
-
...line,
|
|
286
|
-
text: `${prefix}${line.text.slice(start, end)}${end < line.text.length ? "…" : ""}`,
|
|
287
|
-
ranges: line.ranges
|
|
288
|
-
.filter((range) => range.from < end && range.to > start)
|
|
289
|
-
.map((range) => ({
|
|
290
|
-
from: Math.max(range.from, start) - start + prefix.length,
|
|
291
|
-
to: Math.min(range.to, end) - start + prefix.length,
|
|
292
|
-
})),
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
function renderHighlightedLine(line: SearchResultLine, theme: Theme): string {
|
|
296
|
-
let result = "";
|
|
297
|
-
let offset = 0;
|
|
298
|
-
|
|
299
|
-
for (const range of line.ranges) {
|
|
300
|
-
if (range.from > offset) {
|
|
301
|
-
result += theme.fg("toolOutput", safeText(line.text.slice(offset, range.from)));
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
const match = safeText(line.text.slice(range.from, range.to));
|
|
305
|
-
result += theme.bg("selectedBg", theme.fg("accent", theme.bold(match)));
|
|
306
|
-
offset = range.to;
|
|
183
|
+
const suffix = details.fuzzy.candidates.every((candidate) => candidate.selection.complete)
|
|
184
|
+
? ""
|
|
185
|
+
: "+";
|
|
186
|
+
const files = details.fuzzyPresentation.fileCount;
|
|
187
|
+
return `0 exact · ${String(count)}${suffix} fuzzy ${plural(count, "match", "matches")} · ${String(files)}${suffix} ${plural(files, "file", "files")}`;
|
|
307
188
|
}
|
|
308
|
-
|
|
309
|
-
if (offset < line.text.length) {
|
|
310
|
-
result += theme.fg("toolOutput", safeText(line.text.slice(offset)));
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
return result;
|
|
314
|
-
}
|
|
315
|
-
function renderTopBorder(details: SearchToolDetails, width: number, theme: Theme): string {
|
|
316
|
-
const frame = (text: string): string => theme.fg("borderMuted", text);
|
|
317
|
-
const title = truncateToWidth(` ${searchSummary(details)} `, Math.max(0, width - 1), "");
|
|
318
|
-
const fill = "─".repeat(Math.max(0, width - visibleWidth(title) - 1));
|
|
319
|
-
return `${frame("╭─")}${theme.fg("accent", title)}${frame(`${fill}╮`)}`;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
function searchSummary(details: SearchToolDetails): string {
|
|
323
189
|
if (details.matchCount === 0) {
|
|
324
|
-
return "No matches";
|
|
190
|
+
return details.complete ? "No matches" : "No matches · incomplete";
|
|
325
191
|
}
|
|
326
192
|
|
|
327
193
|
const count = `${String(details.matchCount)}${details.complete ? "" : "+"}`;
|
|
@@ -332,75 +198,6 @@ function searchSummary(details: SearchToolDetails): string {
|
|
|
332
198
|
)}`;
|
|
333
199
|
}
|
|
334
200
|
|
|
335
|
-
function framed(content: string, width: number, theme: Theme, highlighted = false): string {
|
|
336
|
-
const clipped = truncateToWidth(content, width);
|
|
337
|
-
const body = `${clipped}${" ".repeat(Math.max(0, width - visibleWidth(clipped)))}`;
|
|
338
|
-
const renderedBody = highlighted ? theme.bg("selectedBg", body) : body;
|
|
339
|
-
const border = theme.fg("borderMuted", "│");
|
|
340
|
-
return `${border}${renderedBody}${border}`;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
function fileBadge(filePath: string, theme: Theme): string {
|
|
344
|
-
const extension = path.extname(filePath).toLowerCase();
|
|
345
|
-
const badge =
|
|
346
|
-
FILE_BADGES[extension] ??
|
|
347
|
-
({
|
|
348
|
-
label: "◇ ",
|
|
349
|
-
color: extension.length === 0 ? "muted" : "accent",
|
|
350
|
-
} satisfies { readonly label: string; readonly color: ThemeColor });
|
|
351
|
-
return theme.fg(badge.color, theme.bold(badge.label));
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
function fileLink(displayedPath: string, link: string, theme: Theme): string {
|
|
355
|
-
const separator = Math.max(displayedPath.lastIndexOf("/"), displayedPath.lastIndexOf("\\"));
|
|
356
|
-
const directory = separator === -1 ? "" : displayedPath.slice(0, separator + 1);
|
|
357
|
-
const basename = separator === -1 ? displayedPath : displayedPath.slice(separator + 1);
|
|
358
|
-
const label = theme.fg("muted", directory) + theme.underline(theme.fg("accent", basename));
|
|
359
|
-
return link.includes("\u{7}") || link.includes("\u{1B}")
|
|
360
|
-
? label
|
|
361
|
-
: `\u{1B}]8;;${link}\u{7}${label}\u{1B}]8;;\u{7}`;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
function truncatePath(filePath: string, width: number): string {
|
|
365
|
-
if (visibleWidth(filePath) <= width) {
|
|
366
|
-
return filePath;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
if (width <= 1) {
|
|
370
|
-
return "…";
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
return `…${filePath.slice(-(width - 1))}`;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
function safeText(value: string): string {
|
|
377
|
-
let result = "";
|
|
378
|
-
|
|
379
|
-
for (const character of value) {
|
|
380
|
-
if (character === "\t") {
|
|
381
|
-
result += " ".repeat(4);
|
|
382
|
-
continue;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
const code = requiredValue(character.codePointAt(0));
|
|
386
|
-
result += code < 0x20 || code === 0x7f ? "�" : character;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
return result;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
function maximumLineNumberWidth(files: readonly SearchResultFile[]): number {
|
|
393
|
-
let maximum = 1;
|
|
394
|
-
|
|
395
|
-
for (const file of files) {
|
|
396
|
-
for (const line of file.lines) {
|
|
397
|
-
maximum = Math.max(maximum, line.lineNumber);
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
return Math.max(3, String(maximum).length);
|
|
402
|
-
}
|
|
403
|
-
|
|
404
201
|
function plural(count: number, singular: string, pluralForm: string): string {
|
|
405
202
|
return count === 1 ? singular : pluralForm;
|
|
406
203
|
}
|