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,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,46 +5,23 @@ 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
17
|
|
|
29
|
-
const FILE_BADGES: Readonly<
|
|
30
|
-
Record<string, { readonly label: string; readonly color: ThemeColor }>
|
|
31
|
-
> = {
|
|
32
|
-
".ts": { label: "TS", color: "accent" },
|
|
33
|
-
".tsx": { label: "TX", color: "accent" },
|
|
34
|
-
".js": { label: "JS", color: "warning" },
|
|
35
|
-
".jsx": { label: "JX", color: "warning" },
|
|
36
|
-
".json": { label: "{}", color: "warning" },
|
|
37
|
-
".md": { label: "MD", color: "mdHeading" },
|
|
38
|
-
".py": { label: "PY", color: "accent" },
|
|
39
|
-
".rs": { label: "RS", color: "accent" },
|
|
40
|
-
".go": { label: "GO", color: "accent" },
|
|
41
|
-
".css": { label: "CS", color: "accent" },
|
|
42
|
-
".html": { label: "<>", color: "accent" },
|
|
43
|
-
};
|
|
44
|
-
|
|
45
18
|
interface SearchRenderContext {
|
|
46
19
|
readonly lastComponent: Component | undefined;
|
|
47
20
|
readonly isError?: boolean;
|
|
48
21
|
}
|
|
49
22
|
|
|
50
23
|
type SearchPanelRow =
|
|
24
|
+
| { readonly kind: "candidate"; readonly identifier: string }
|
|
51
25
|
| { readonly kind: "file"; readonly file: SearchResultFile }
|
|
52
26
|
| { readonly kind: "line"; readonly file: SearchResultFile; readonly line: SearchResultLine }
|
|
53
27
|
| { readonly kind: "summary"; readonly text: string }
|
|
@@ -81,65 +55,47 @@ export function renderSearchResult(
|
|
|
81
55
|
const previous =
|
|
82
56
|
context.lastComponent instanceof SearchResultPanel ? context.lastComponent : undefined;
|
|
83
57
|
const panel = previous ?? new SearchResultPanel(result.details, theme, options.expanded);
|
|
84
|
-
panel.
|
|
58
|
+
panel.updateSearch(result.details, theme, options.expanded);
|
|
85
59
|
return panel;
|
|
86
60
|
}
|
|
87
61
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if (
|
|
110
|
-
return
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const innerWidth = width - 2;
|
|
120
|
-
const rows = searchViewport(this.details, this.expanded);
|
|
121
|
-
const gutterWidth = maximumLineNumberWidth(this.details.files);
|
|
122
|
-
const renderedRows = rows.flatMap((row) =>
|
|
123
|
-
renderPanelRow(row, innerWidth, gutterWidth, this.theme),
|
|
124
|
-
);
|
|
125
|
-
const visibleRows = compactRenderedRows(renderedRows, this.expanded, innerWidth, this.theme);
|
|
126
|
-
const lines = [renderTopBorder(this.details, innerWidth, this.theme), ...visibleRows];
|
|
127
|
-
|
|
128
|
-
lines.push(this.theme.fg("borderMuted", `╰${"─".repeat(innerWidth)}╯`));
|
|
129
|
-
const clipped = lines.map((line) => truncateToWidth(line, width));
|
|
130
|
-
this.cached = { width, lines: clipped };
|
|
131
|
-
return clipped;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
public invalidate(): void {
|
|
135
|
-
this.cached = undefined;
|
|
136
|
-
}
|
|
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 };
|
|
137
91
|
}
|
|
138
|
-
|
|
139
92
|
function searchViewport(details: SearchToolDetails, expanded: boolean): readonly SearchPanelRow[] {
|
|
140
|
-
const
|
|
93
|
+
const hasCandidates = details.fuzzy?.status === "ready" && details.fuzzy.candidates.length > 0;
|
|
94
|
+
const rows: SearchPanelRow[] =
|
|
141
95
|
details.files.length === 0
|
|
142
|
-
?
|
|
96
|
+
? hasCandidates
|
|
97
|
+
? []
|
|
98
|
+
: [{ kind: "empty" } satisfies SearchPanelRow]
|
|
143
99
|
: details.files.flatMap((file): SearchPanelRow[] => [
|
|
144
100
|
{ kind: "file", file },
|
|
145
101
|
...(file.uniqueLineCount === undefined
|
|
@@ -156,7 +112,41 @@ function searchViewport(details: SearchToolDetails, expanded: boolean): readonly
|
|
|
156
112
|
]),
|
|
157
113
|
]);
|
|
158
114
|
|
|
159
|
-
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) {
|
|
160
150
|
return rows;
|
|
161
151
|
}
|
|
162
152
|
|
|
@@ -179,115 +169,25 @@ function searchViewport(details: SearchToolDetails, expanded: boolean): readonly
|
|
|
179
169
|
];
|
|
180
170
|
}
|
|
181
171
|
|
|
182
|
-
function compactRenderedRows(
|
|
183
|
-
rows: readonly string[],
|
|
184
|
-
expanded: boolean,
|
|
185
|
-
width: number,
|
|
186
|
-
theme: Theme,
|
|
187
|
-
): readonly string[] {
|
|
188
|
-
if (expanded || rows.length <= COMPACT_SEARCH_ROWS) {
|
|
189
|
-
return rows;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
const hint = `${keyText("app.tools.expand")} to expand`;
|
|
193
|
-
const notice = framed(theme.fg("dim", ` … output truncated · ${hint}`), width, theme);
|
|
194
|
-
return [...rows.slice(0, COMPACT_SEARCH_ROWS - 1), notice];
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
function renderPanelRow(
|
|
198
|
-
row: SearchPanelRow,
|
|
199
|
-
width: number,
|
|
200
|
-
gutterWidth: number,
|
|
201
|
-
theme: Theme,
|
|
202
|
-
): readonly string[] {
|
|
203
|
-
if (row.kind === "file") {
|
|
204
|
-
return [framed(renderFileHeader(row.file, width, theme), width, theme, true)];
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
if (row.kind === "line") {
|
|
208
|
-
return renderMatchLine(row.line, width, gutterWidth, theme);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
if (row.kind === "summary") {
|
|
212
|
-
return [framed(theme.fg("dim", ` ${safeText(row.text)}`), width, theme)];
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
if (row.kind === "omitted") {
|
|
216
|
-
const hint = `${keyText("app.tools.expand")} to expand`;
|
|
217
|
-
return [
|
|
218
|
-
framed(
|
|
219
|
-
theme.fg(
|
|
220
|
-
"dim",
|
|
221
|
-
` … ${String(row.matches)} more ${plural(row.matches, "match", "matches")} · ${hint}`,
|
|
222
|
-
),
|
|
223
|
-
width,
|
|
224
|
-
theme,
|
|
225
|
-
),
|
|
226
|
-
];
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
return [framed(theme.fg("dim", " No matches found"), width, theme)];
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
function renderFileHeader(file: SearchResultFile, width: number, theme: Theme): string {
|
|
233
|
-
const badge = fileBadge(file.path, theme);
|
|
234
|
-
const count = theme.fg("accent", theme.bold(String(file.matchCount)));
|
|
235
|
-
const fixedWidth = visibleWidth(badge) + visibleWidth(count) + 4;
|
|
236
|
-
const pathWidth = Math.max(1, width - fixedWidth);
|
|
237
|
-
const displayedPath = truncatePath(file.path, pathWidth);
|
|
238
|
-
const linkedPath = fileLink(displayedPath, file.link, theme);
|
|
239
|
-
const left = ` ${badge} ${linkedPath}`;
|
|
240
|
-
const gap = " ".repeat(Math.max(1, width - visibleWidth(left) - visibleWidth(count) - 1));
|
|
241
|
-
return truncateToWidth(`${left}${gap}${count} `, width);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function renderMatchLine(
|
|
245
|
-
line: SearchResultLine,
|
|
246
|
-
width: number,
|
|
247
|
-
gutterWidth: number,
|
|
248
|
-
theme: Theme,
|
|
249
|
-
): readonly string[] {
|
|
250
|
-
const number = String(line.lineNumber).padStart(gutterWidth);
|
|
251
|
-
const gutter = ` ${theme.fg("dim", number)} ${theme.fg("borderMuted", "│")} `;
|
|
252
|
-
const contentWidth = Math.max(1, width - visibleWidth(gutter) - 1);
|
|
253
|
-
const wrapped = wrapTextWithAnsi(renderHighlightedLine(line, theme), contentWidth);
|
|
254
|
-
const continuationGutter = " ".repeat(visibleWidth(gutter));
|
|
255
|
-
|
|
256
|
-
return wrapped.map((content, index) =>
|
|
257
|
-
framed(`${index === 0 ? gutter : continuationGutter}${content}`, width, theme),
|
|
258
|
-
);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
function renderHighlightedLine(line: SearchResultLine, theme: Theme): string {
|
|
262
|
-
let result = "";
|
|
263
|
-
let offset = 0;
|
|
264
|
-
|
|
265
|
-
for (const range of line.ranges) {
|
|
266
|
-
if (range.from > offset) {
|
|
267
|
-
result += theme.fg("toolOutput", safeText(line.text.slice(offset, range.from)));
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
const match = safeText(line.text.slice(range.from, range.to));
|
|
271
|
-
result += theme.bg("selectedBg", theme.fg("accent", theme.bold(match)));
|
|
272
|
-
offset = range.to;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
if (offset < line.text.length) {
|
|
276
|
-
result += theme.fg("toolOutput", safeText(line.text.slice(offset)));
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
return result;
|
|
280
|
-
}
|
|
281
|
-
function renderTopBorder(details: SearchToolDetails, width: number, theme: Theme): string {
|
|
282
|
-
const frame = (text: string): string => theme.fg("borderMuted", text);
|
|
283
|
-
const title = truncateToWidth(` ${searchSummary(details)} `, Math.max(0, width - 1), "");
|
|
284
|
-
const fill = "─".repeat(Math.max(0, width - visibleWidth(title) - 1));
|
|
285
|
-
return `${frame("╭─")}${theme.fg("accent", title)}${frame(`${fill}╮`)}`;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
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,
|
|
182
|
+
);
|
|
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")}`;
|
|
188
|
+
}
|
|
289
189
|
if (details.matchCount === 0) {
|
|
290
|
-
return "No matches";
|
|
190
|
+
return details.complete ? "No matches" : "No matches · incomplete";
|
|
291
191
|
}
|
|
292
192
|
|
|
293
193
|
const count = `${String(details.matchCount)}${details.complete ? "" : "+"}`;
|
|
@@ -298,75 +198,6 @@ function searchSummary(details: SearchToolDetails): string {
|
|
|
298
198
|
)}`;
|
|
299
199
|
}
|
|
300
200
|
|
|
301
|
-
function framed(content: string, width: number, theme: Theme, highlighted = false): string {
|
|
302
|
-
const clipped = truncateToWidth(content, width);
|
|
303
|
-
const body = `${clipped}${" ".repeat(Math.max(0, width - visibleWidth(clipped)))}`;
|
|
304
|
-
const renderedBody = highlighted ? theme.bg("selectedBg", body) : body;
|
|
305
|
-
const border = theme.fg("borderMuted", "│");
|
|
306
|
-
return `${border}${renderedBody}${border}`;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
function fileBadge(filePath: string, theme: Theme): string {
|
|
310
|
-
const extension = path.extname(filePath).toLowerCase();
|
|
311
|
-
const badge =
|
|
312
|
-
FILE_BADGES[extension] ??
|
|
313
|
-
({
|
|
314
|
-
label: "◇ ",
|
|
315
|
-
color: extension.length === 0 ? "muted" : "accent",
|
|
316
|
-
} satisfies { readonly label: string; readonly color: ThemeColor });
|
|
317
|
-
return theme.fg(badge.color, theme.bold(badge.label));
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
function fileLink(displayedPath: string, link: string, theme: Theme): string {
|
|
321
|
-
const separator = Math.max(displayedPath.lastIndexOf("/"), displayedPath.lastIndexOf("\\"));
|
|
322
|
-
const directory = separator === -1 ? "" : displayedPath.slice(0, separator + 1);
|
|
323
|
-
const basename = separator === -1 ? displayedPath : displayedPath.slice(separator + 1);
|
|
324
|
-
const label = theme.fg("muted", directory) + theme.underline(theme.fg("accent", basename));
|
|
325
|
-
return link.includes("\u{7}") || link.includes("\u{1B}")
|
|
326
|
-
? label
|
|
327
|
-
: `\u{1B}]8;;${link}\u{7}${label}\u{1B}]8;;\u{7}`;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
function truncatePath(filePath: string, width: number): string {
|
|
331
|
-
if (visibleWidth(filePath) <= width) {
|
|
332
|
-
return filePath;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
if (width <= 1) {
|
|
336
|
-
return "…";
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
return `…${filePath.slice(-(width - 1))}`;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
function safeText(value: string): string {
|
|
343
|
-
let result = "";
|
|
344
|
-
|
|
345
|
-
for (const character of value) {
|
|
346
|
-
if (character === "\t") {
|
|
347
|
-
result += " ".repeat(4);
|
|
348
|
-
continue;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
const code = requiredValue(character.codePointAt(0));
|
|
352
|
-
result += code < 0x20 || code === 0x7f ? "�" : character;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
return result;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
function maximumLineNumberWidth(files: readonly SearchResultFile[]): number {
|
|
359
|
-
let maximum = 1;
|
|
360
|
-
|
|
361
|
-
for (const file of files) {
|
|
362
|
-
for (const line of file.lines) {
|
|
363
|
-
maximum = Math.max(maximum, line.lineNumber);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
return Math.max(3, String(maximum).length);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
201
|
function plural(count: number, singular: string, pluralForm: string): string {
|
|
371
202
|
return count === 1 ? singular : pluralForm;
|
|
372
203
|
}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import {
|
|
3
|
+
fuzzyLimits,
|
|
4
|
+
isFuzzyResultData,
|
|
5
|
+
type FuzzyCandidate,
|
|
6
|
+
type FuzzyResultData,
|
|
7
|
+
} from "pi-agent-search/api/search";
|
|
2
8
|
import { pathToFileURL } from "node:url";
|
|
3
9
|
|
|
4
10
|
import type { TextSearchMatch } from "#src/search-session.js";
|
|
@@ -31,6 +37,14 @@ export interface SearchResultFile {
|
|
|
31
37
|
readonly lines: readonly SearchResultLine[];
|
|
32
38
|
}
|
|
33
39
|
|
|
40
|
+
/** Bounded user-only source previews; not part of Search's agent-facing projection. */
|
|
41
|
+
export interface FuzzySearchPresentation {
|
|
42
|
+
readonly fileCount: number;
|
|
43
|
+
readonly groups: readonly {
|
|
44
|
+
readonly identifier: string;
|
|
45
|
+
readonly files: readonly SearchResultFile[];
|
|
46
|
+
}[];
|
|
47
|
+
}
|
|
34
48
|
export interface SearchToolDetails {
|
|
35
49
|
readonly sessionId?: string;
|
|
36
50
|
readonly query: string;
|
|
@@ -38,6 +52,8 @@ export interface SearchToolDetails {
|
|
|
38
52
|
readonly fileCount: number;
|
|
39
53
|
readonly complete: boolean;
|
|
40
54
|
readonly files: readonly SearchResultFile[];
|
|
55
|
+
readonly fuzzy?: FuzzyResultData;
|
|
56
|
+
readonly fuzzyPresentation?: FuzzySearchPresentation;
|
|
41
57
|
}
|
|
42
58
|
|
|
43
59
|
interface MutableSearchResultLine {
|
|
@@ -78,6 +94,65 @@ export function createSearchToolDetails(
|
|
|
78
94
|
};
|
|
79
95
|
}
|
|
80
96
|
|
|
97
|
+
/** Keep short highlighted source windows for the TUI without changing agent results. */
|
|
98
|
+
export function createFuzzyPresentation(
|
|
99
|
+
candidates: readonly FuzzyCandidate[],
|
|
100
|
+
cwd: string,
|
|
101
|
+
): FuzzySearchPresentation {
|
|
102
|
+
return {
|
|
103
|
+
fileCount: new Set(
|
|
104
|
+
candidates.flatMap((candidate) => candidate.matches.map((match) => match.source)),
|
|
105
|
+
).size,
|
|
106
|
+
groups: candidates.map((candidate) => {
|
|
107
|
+
const preview = createSearchToolDetails(
|
|
108
|
+
candidate.identifier,
|
|
109
|
+
candidate.matches.slice(0, fuzzyLimits.previewMatches),
|
|
110
|
+
candidate.complete,
|
|
111
|
+
cwd,
|
|
112
|
+
);
|
|
113
|
+
const files = preview.files.map((file) => {
|
|
114
|
+
const lines = file.lines.map((line) => {
|
|
115
|
+
const from = Math.max(0, (line.ranges[0]?.from ?? 0) - 64);
|
|
116
|
+
const to = Math.min(line.text.length, (line.ranges[0]?.to ?? 0) + 64);
|
|
117
|
+
const prefix = from > 0 ? "…" : "";
|
|
118
|
+
const ranges = line.ranges
|
|
119
|
+
.filter((range) => range.from >= from && range.to <= to)
|
|
120
|
+
.map((range) => ({
|
|
121
|
+
from: range.from - from + prefix.length,
|
|
122
|
+
to: range.to - from + prefix.length,
|
|
123
|
+
}));
|
|
124
|
+
return {
|
|
125
|
+
...line,
|
|
126
|
+
text: prefix + line.text.slice(from, to) + (to < line.text.length ? "…" : ""),
|
|
127
|
+
ranges,
|
|
128
|
+
matchCount: ranges.length,
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
return {
|
|
132
|
+
...file,
|
|
133
|
+
lines,
|
|
134
|
+
matchCount: lines.reduce((count, line) => count + line.matchCount, 0),
|
|
135
|
+
};
|
|
136
|
+
});
|
|
137
|
+
return { identifier: candidate.identifier, files };
|
|
138
|
+
}),
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function isFuzzyPresentation(value: unknown): value is FuzzySearchPresentation {
|
|
143
|
+
return (
|
|
144
|
+
isRecord(value) &&
|
|
145
|
+
isCount(value.fileCount) &&
|
|
146
|
+
Array.isArray(value.groups) &&
|
|
147
|
+
value.groups.every(
|
|
148
|
+
(group) =>
|
|
149
|
+
isRecord(group) &&
|
|
150
|
+
typeof group.identifier === "string" &&
|
|
151
|
+
Array.isArray(group.files) &&
|
|
152
|
+
group.files.every(isSearchResultFile),
|
|
153
|
+
)
|
|
154
|
+
);
|
|
155
|
+
}
|
|
81
156
|
export function isSearchToolDetails(value: unknown): value is SearchToolDetails {
|
|
82
157
|
if (
|
|
83
158
|
!isRecord(value) ||
|
|
@@ -86,6 +161,8 @@ export function isSearchToolDetails(value: unknown): value is SearchToolDetails
|
|
|
86
161
|
!isCount(value.fileCount) ||
|
|
87
162
|
typeof value.complete !== "boolean" ||
|
|
88
163
|
(value.sessionId !== undefined && typeof value.sessionId !== "string") ||
|
|
164
|
+
(value.fuzzy !== undefined && !isFuzzyResultData(value.fuzzy)) ||
|
|
165
|
+
(value.fuzzyPresentation !== undefined && !isFuzzyPresentation(value.fuzzyPresentation)) ||
|
|
89
166
|
!Array.isArray(value.files) ||
|
|
90
167
|
!value.files.every(isSearchResultFile)
|
|
91
168
|
) {
|