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
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ResolvedResultTargets } from "pi-agent-resource";
|
|
2
|
+
import type { SearchSelectionMatch } from "./search.js";
|
|
3
|
+
|
|
4
|
+
/** Keep a provider match only when one declared region wholly contains its exact range. */
|
|
5
|
+
export function containsSearchMatch(
|
|
6
|
+
scope: ResolvedResultTargets,
|
|
7
|
+
match: SearchSelectionMatch,
|
|
8
|
+
): boolean {
|
|
9
|
+
return scope.targets.some(
|
|
10
|
+
(target) =>
|
|
11
|
+
target.source === match.source &&
|
|
12
|
+
target.ranges.some(
|
|
13
|
+
(range) =>
|
|
14
|
+
(range.start.lineNumber < match.lineNumber ||
|
|
15
|
+
(range.start.lineNumber === match.lineNumber &&
|
|
16
|
+
range.start.column <= match.startColumn)) &&
|
|
17
|
+
(range.end.lineNumber > (match.endLineNumber ?? match.lineNumber) ||
|
|
18
|
+
(range.end.lineNumber === (match.endLineNumber ?? match.lineNumber) &&
|
|
19
|
+
range.end.column >= match.endColumn)),
|
|
20
|
+
),
|
|
21
|
+
);
|
|
22
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AgentToolResult, ToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { ResolvedResultTargets } from "pi-agent-resource";
|
|
2
3
|
|
|
3
4
|
export interface SearchRequest {
|
|
4
5
|
readonly query: string;
|
|
@@ -8,9 +9,13 @@ export interface SearchRequest {
|
|
|
8
9
|
readonly caseSensitive?: boolean;
|
|
9
10
|
readonly wholeWord?: boolean;
|
|
10
11
|
readonly limit?: number;
|
|
12
|
+
/** Explicitly follow scoped LSP symbols to references outside the input scope. */
|
|
13
|
+
readonly navigation?: "references";
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
export interface SearchContext {
|
|
17
|
+
/** Exact backend-owned source scopes for native result composition. */
|
|
18
|
+
readonly scope?: ResolvedResultTargets;
|
|
14
19
|
readonly cwd: string;
|
|
15
20
|
readonly signal?: AbortSignal;
|
|
16
21
|
readonly onUpdate?: (result: AgentToolResult<unknown>) => void;
|
|
@@ -22,6 +27,18 @@ export type SearchResolutionAttempt =
|
|
|
22
27
|
| { readonly kind: "failed"; readonly error: unknown };
|
|
23
28
|
|
|
24
29
|
export interface SearchResolver {
|
|
30
|
+
/** Handle exact source ranges instead of widening a structured input to a path. */
|
|
31
|
+
readonly supportsResultScope?: boolean;
|
|
32
|
+
/** Complete read scope for resolving and formatting. Empty means no resource reads;
|
|
33
|
+
* undefined means unknown scope, compatible with reads but conflicting with every write.
|
|
34
|
+
* Declaring a scope must not read resource contents.
|
|
35
|
+
*/
|
|
36
|
+
readonly readResources?: (
|
|
37
|
+
request: SearchRequest,
|
|
38
|
+
context: SearchContext,
|
|
39
|
+
) => readonly string[] | undefined | Promise<readonly string[] | undefined>;
|
|
40
|
+
/** Required for native data calls; project only documented JSON domain fields. */
|
|
41
|
+
readonly toScriptData?: (payload: unknown, formattedDetails: unknown) => unknown;
|
|
25
42
|
readonly id: string;
|
|
26
43
|
tryResolve(
|
|
27
44
|
request: SearchRequest,
|
|
@@ -95,6 +112,9 @@ export interface SearchSelectionRegistration extends SearchSelectionSnapshot {
|
|
|
95
112
|
}
|
|
96
113
|
export interface RegisteredSearchSelection {
|
|
97
114
|
readonly id: string;
|
|
115
|
+
/** Shared immutable source targets, independent of legacy SEARCH refresh handles. */
|
|
116
|
+
readonly target?: string;
|
|
117
|
+
readonly matchTargets?: readonly string[];
|
|
98
118
|
readonly matches: readonly SearchSelectionMatch[];
|
|
99
119
|
readonly complete: boolean;
|
|
100
120
|
}
|
|
@@ -141,3 +161,22 @@ export interface SearchToolDetails {
|
|
|
141
161
|
}
|
|
142
162
|
|
|
143
163
|
export { searchSchema } from "#src/api/search-parameters.js";
|
|
164
|
+
export { renderSearchMatches } from "./presentation.js";
|
|
165
|
+
export { containsSearchMatch } from "./search-scope.js";
|
|
166
|
+
export {
|
|
167
|
+
fuzzyLimits,
|
|
168
|
+
isFuzzyResultData,
|
|
169
|
+
FuzzyVocabulary,
|
|
170
|
+
isFuzzyQuery,
|
|
171
|
+
rankFuzzyIdentifiers,
|
|
172
|
+
fuzzyCandidateData,
|
|
173
|
+
formatFuzzyCandidate,
|
|
174
|
+
} from "#src/api/fuzzy.js";
|
|
175
|
+
export type {
|
|
176
|
+
FuzzyIdentifier,
|
|
177
|
+
FuzzyResultData,
|
|
178
|
+
FuzzyCandidate,
|
|
179
|
+
FuzzyResult,
|
|
180
|
+
FuzzyCandidateData,
|
|
181
|
+
} from "#src/api/fuzzy.js";
|
|
182
|
+
export { searchDataSchema, searchOutputSchema, selectionData } from "./structured-result.js";
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import { structuredResultSchema } from "pi-agent-resource";
|
|
3
|
+
|
|
4
|
+
const position = Type.Object(
|
|
5
|
+
{
|
|
6
|
+
startLine: Type.Integer(),
|
|
7
|
+
startColumn: Type.Integer(),
|
|
8
|
+
endLine: Type.Integer(),
|
|
9
|
+
endColumn: Type.Integer(),
|
|
10
|
+
},
|
|
11
|
+
{ additionalProperties: false },
|
|
12
|
+
);
|
|
13
|
+
const references = Type.Object(
|
|
14
|
+
{ line: Type.Optional(Type.String()), match: Type.Optional(Type.String()) },
|
|
15
|
+
{ additionalProperties: false },
|
|
16
|
+
);
|
|
17
|
+
const sourceMatchFields = {
|
|
18
|
+
source: Type.String(),
|
|
19
|
+
target: Type.Optional(Type.String()),
|
|
20
|
+
range: position,
|
|
21
|
+
matchedText: Type.Optional(Type.String()),
|
|
22
|
+
textTruncated: Type.Optional(Type.Boolean()),
|
|
23
|
+
references: Type.Optional(references),
|
|
24
|
+
};
|
|
25
|
+
const match = Type.Object(
|
|
26
|
+
{
|
|
27
|
+
...sourceMatchFields,
|
|
28
|
+
captures: Type.Optional(
|
|
29
|
+
Type.Record(
|
|
30
|
+
Type.String(),
|
|
31
|
+
Type.Array(Type.Object(sourceMatchFields, { additionalProperties: false })),
|
|
32
|
+
),
|
|
33
|
+
),
|
|
34
|
+
role: Type.Optional(Type.Union([Type.Literal("definition"), Type.Literal("reference")])),
|
|
35
|
+
symbol: Type.Optional(
|
|
36
|
+
Type.Object(
|
|
37
|
+
{
|
|
38
|
+
id: Type.String(),
|
|
39
|
+
name: Type.String(),
|
|
40
|
+
kind: Type.String(),
|
|
41
|
+
source: Type.String(),
|
|
42
|
+
range: position,
|
|
43
|
+
},
|
|
44
|
+
{ additionalProperties: false },
|
|
45
|
+
),
|
|
46
|
+
),
|
|
47
|
+
},
|
|
48
|
+
{ additionalProperties: false },
|
|
49
|
+
);
|
|
50
|
+
const selectionProperties = {
|
|
51
|
+
target: Type.Optional(Type.String()),
|
|
52
|
+
kind: Type.Literal("matches"),
|
|
53
|
+
truncated: Type.Optional(Type.Boolean()),
|
|
54
|
+
fullResult: Type.Optional(Type.String()),
|
|
55
|
+
complete: Type.Boolean(),
|
|
56
|
+
matches: Type.Array(match),
|
|
57
|
+
all: Type.Optional(references),
|
|
58
|
+
notices: Type.Optional(Type.Array(Type.String())),
|
|
59
|
+
};
|
|
60
|
+
/** Separate possible-name groups with exact captured ranges and optional Read references. */
|
|
61
|
+
export const fuzzyDataSchema = Type.Object(
|
|
62
|
+
{
|
|
63
|
+
status: Type.Union([Type.Literal("ready"), Type.Literal("skipped")]),
|
|
64
|
+
message: Type.Optional(Type.String()),
|
|
65
|
+
candidates: Type.Array(
|
|
66
|
+
Type.Object(
|
|
67
|
+
{
|
|
68
|
+
identifier: Type.String(),
|
|
69
|
+
kind: Type.Union([
|
|
70
|
+
Type.Literal("normalized"),
|
|
71
|
+
Type.Literal("component"),
|
|
72
|
+
Type.Literal("typo"),
|
|
73
|
+
]),
|
|
74
|
+
reason: Type.String(),
|
|
75
|
+
matchCount: Type.Integer(),
|
|
76
|
+
fileCount: Type.Integer(),
|
|
77
|
+
selection: Type.Object(selectionProperties, { additionalProperties: false }),
|
|
78
|
+
},
|
|
79
|
+
{ additionalProperties: false },
|
|
80
|
+
),
|
|
81
|
+
),
|
|
82
|
+
},
|
|
83
|
+
{ additionalProperties: false },
|
|
84
|
+
);
|
|
85
|
+
/** Resolver adapters supply selected domain fields, never renderer details or raw backend objects. */
|
|
86
|
+
export const searchDataSchema = Type.Union([
|
|
87
|
+
Type.Object(
|
|
88
|
+
{ ...selectionProperties, fuzzy: Type.Optional(fuzzyDataSchema) },
|
|
89
|
+
{ additionalProperties: false },
|
|
90
|
+
),
|
|
91
|
+
Type.Object(
|
|
92
|
+
{ kind: Type.Literal("files"), complete: Type.Boolean(), files: Type.Array(Type.String()) },
|
|
93
|
+
{ additionalProperties: false },
|
|
94
|
+
),
|
|
95
|
+
Type.Object(
|
|
96
|
+
{ kind: Type.Literal("custom"), resolverId: Type.String(), value: Type.Unknown() },
|
|
97
|
+
{ additionalProperties: false },
|
|
98
|
+
),
|
|
99
|
+
]);
|
|
100
|
+
export const searchOutputSchema = structuredResultSchema(searchDataSchema);
|
|
101
|
+
|
|
102
|
+
/** Project a registered selection in its original order. Columns are zero-based UTF-16 offsets. */
|
|
103
|
+
export function selectionData(
|
|
104
|
+
matches: readonly {
|
|
105
|
+
source: string;
|
|
106
|
+
lineNumber: number;
|
|
107
|
+
endLineNumber?: number;
|
|
108
|
+
startColumn: number;
|
|
109
|
+
endColumn: number;
|
|
110
|
+
matchedText: string;
|
|
111
|
+
}[],
|
|
112
|
+
complete: boolean,
|
|
113
|
+
sessionId?: string,
|
|
114
|
+
targets?: { readonly target?: string; readonly matchTargets?: readonly string[] },
|
|
115
|
+
) {
|
|
116
|
+
return {
|
|
117
|
+
kind: "matches" as const,
|
|
118
|
+
...(targets?.target === undefined ? {} : { target: targets.target }),
|
|
119
|
+
truncated: matches.length > 100,
|
|
120
|
+
complete,
|
|
121
|
+
matches: matches.slice(0, 100).map((match, index) => ({
|
|
122
|
+
source: match.source,
|
|
123
|
+
...(targets?.matchTargets?.[index] === undefined
|
|
124
|
+
? {}
|
|
125
|
+
: { target: targets.matchTargets[index] }),
|
|
126
|
+
range: {
|
|
127
|
+
startLine: match.lineNumber,
|
|
128
|
+
startColumn: match.startColumn,
|
|
129
|
+
endLine: match.endLineNumber ?? match.lineNumber,
|
|
130
|
+
endColumn: match.endColumn,
|
|
131
|
+
},
|
|
132
|
+
...(Buffer.byteLength(match.matchedText) <= 4096
|
|
133
|
+
? { matchedText: match.matchedText }
|
|
134
|
+
: { textTruncated: true }),
|
|
135
|
+
...(sessionId === undefined
|
|
136
|
+
? {}
|
|
137
|
+
: {
|
|
138
|
+
references: {
|
|
139
|
+
line: `SEARCH#${sessionId}:${index + 1}:line`,
|
|
140
|
+
match: `SEARCH#${sessionId}:${index + 1}:match`,
|
|
141
|
+
},
|
|
142
|
+
}),
|
|
143
|
+
})),
|
|
144
|
+
...(complete && sessionId !== undefined
|
|
145
|
+
? { all: { line: `SEARCH#${sessionId}:all:line`, match: `SEARCH#${sessionId}:all:match` } }
|
|
146
|
+
: {}),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type AgentToolResult,
|
|
3
3
|
type ExtensionAPI,
|
|
4
|
-
keyText,
|
|
5
4
|
type Theme,
|
|
6
5
|
type ToolRenderResultOptions,
|
|
7
6
|
} from "@earendil-works/pi-coding-agent";
|
|
8
7
|
import { type Component, Text } from "@earendil-works/pi-tui";
|
|
9
8
|
import { connectAgentDocumentation, loadPackagedAgentGuide } from "pi-agent-documentation";
|
|
10
9
|
import {
|
|
10
|
+
ResultPanel,
|
|
11
11
|
toolCallHeader,
|
|
12
12
|
type ToolCallHeaderDetail,
|
|
13
13
|
type ToolCallHeaderModel,
|
|
@@ -35,6 +35,9 @@ import { runWithSearchTimeout } from "#src/core/search-timeout.js";
|
|
|
35
35
|
import type { SearchToolDetails } from "#src/api/search.js";
|
|
36
36
|
|
|
37
37
|
import { searchSchema } from "#src/api/search-parameters.js";
|
|
38
|
+
import { searchOutputSchema, searchDataSchema } from "#src/api/structured-result.js";
|
|
39
|
+
import { resultError, withStructuredResult } from "pi-agent-resource";
|
|
40
|
+
import { connectResultTargets } from "pi-agent-resource";
|
|
38
41
|
|
|
39
42
|
/** Arguments accepted by the search tool. */
|
|
40
43
|
export type SearchParameters = Static<typeof searchSchema>;
|
|
@@ -49,12 +52,15 @@ export function searchCallModel(
|
|
|
49
52
|
? []
|
|
50
53
|
: [
|
|
51
54
|
{
|
|
52
|
-
text: `in ${arguments_.path}
|
|
55
|
+
text: typeof arguments_.path === "string" ? `in ${arguments_.path}` : "in result scope",
|
|
53
56
|
color: "accent" as const,
|
|
54
57
|
underline: true,
|
|
55
58
|
truncate: "start" as const,
|
|
56
59
|
},
|
|
57
60
|
]),
|
|
61
|
+
...(arguments_.navigation === undefined
|
|
62
|
+
? []
|
|
63
|
+
: [{ text: "reference navigation", color: "warning" as const }]),
|
|
58
64
|
...(arguments_.include === undefined ? [] : [{ text: `include ${arguments_.include}` }]),
|
|
59
65
|
...(arguments_.exclude === undefined ? [] : [{ text: `exclude ${arguments_.exclude}` }]),
|
|
60
66
|
...(arguments_.caseSensitive === true ? [{ text: "case sensitive" }] : []),
|
|
@@ -93,6 +99,7 @@ export default async function registerSearchCore(
|
|
|
93
99
|
}),
|
|
94
100
|
]);
|
|
95
101
|
const core = createSearchCore();
|
|
102
|
+
const targets = connectResultTargets(pi);
|
|
96
103
|
const interceptionRendering = new ToolCallInterceptionRenderStore();
|
|
97
104
|
const unsubscribe = pi.events.on(SEARCH_PLUGIN_REGISTER_EVENT, (request) => {
|
|
98
105
|
if (!isSearchPluginRegistrationRequest(request)) {
|
|
@@ -106,6 +113,17 @@ export default async function registerSearchCore(
|
|
|
106
113
|
withToolCallInterceptionRendering(
|
|
107
114
|
{
|
|
108
115
|
name: "search",
|
|
116
|
+
exposure: "direct",
|
|
117
|
+
namespace: {
|
|
118
|
+
name: "ide_search",
|
|
119
|
+
description: "Find workspace text, paths and code structures.",
|
|
120
|
+
},
|
|
121
|
+
annotations: {
|
|
122
|
+
readOnlyHint: true,
|
|
123
|
+
destructiveHint: false,
|
|
124
|
+
idempotentHint: false,
|
|
125
|
+
openWorldHint: false,
|
|
126
|
+
},
|
|
109
127
|
label: "search",
|
|
110
128
|
description: "Use search to locate workspace text, file paths, and code structures.",
|
|
111
129
|
promptSnippet:
|
|
@@ -117,6 +135,7 @@ export default async function registerSearchCore(
|
|
|
117
135
|
];
|
|
118
136
|
},
|
|
119
137
|
parameters: searchSchema,
|
|
138
|
+
outputSchema: searchOutputSchema,
|
|
120
139
|
renderCall(arguments_, theme, renderContext): Component {
|
|
121
140
|
const mode = renderContext.expanded ? "full" : presentation;
|
|
122
141
|
if (mode === "disabled") return new Text(theme.fg("toolTitle", "search"), 0, 0);
|
|
@@ -135,8 +154,13 @@ export default async function registerSearchCore(
|
|
|
135
154
|
const renderer =
|
|
136
155
|
details?.resolverId === undefined ? undefined : core.renderer(details.resolverId);
|
|
137
156
|
|
|
138
|
-
if (
|
|
139
|
-
|
|
157
|
+
if (
|
|
158
|
+
renderer !== undefined &&
|
|
159
|
+
details?.payload !== undefined &&
|
|
160
|
+
!context.isError &&
|
|
161
|
+
!options.isPartial
|
|
162
|
+
) {
|
|
163
|
+
const inner = { ...result, details: details.payload };
|
|
140
164
|
return renderer(inner, options, theme, context);
|
|
141
165
|
}
|
|
142
166
|
|
|
@@ -149,21 +173,50 @@ export default async function registerSearchCore(
|
|
|
149
173
|
onUpdate,
|
|
150
174
|
context,
|
|
151
175
|
): Promise<AgentToolResult<SearchToolDetails>> {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
await
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
176
|
+
try {
|
|
177
|
+
const config = await loadSearchConfig(
|
|
178
|
+
resolveSearchConfigPaths(process.env, os.homedir(), context.cwd),
|
|
179
|
+
);
|
|
180
|
+
return await runWithSearchTimeout(config.timeoutMs, signal, async (operationSignal) => {
|
|
181
|
+
await core.waitForPendingPlugins();
|
|
182
|
+
const scoped =
|
|
183
|
+
parameters.path !== undefined &&
|
|
184
|
+
(typeof parameters.path !== "string" || parameters.path.startsWith("RESULT#"));
|
|
185
|
+
const scope = scoped ? targets.resolve(parameters.path, context.cwd) : undefined;
|
|
186
|
+
if (scope !== undefined) {
|
|
187
|
+
await targets.verify(scope, operationSignal);
|
|
188
|
+
if (/^(?:files|symbol|graph|process):/u.test(parameters.query))
|
|
189
|
+
throw new Error("This query provider does not support result scopes yet.");
|
|
190
|
+
}
|
|
191
|
+
return core.execute(
|
|
192
|
+
{
|
|
193
|
+
...parameters,
|
|
194
|
+
path:
|
|
195
|
+
typeof parameters.path === "string" && !scoped ? parameters.path : undefined,
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
cwd: context.cwd,
|
|
199
|
+
...(scope === undefined ? {} : { scope }),
|
|
200
|
+
...(operationSignal !== undefined && { signal: operationSignal }),
|
|
201
|
+
...(onUpdate !== undefined && { onUpdate }),
|
|
163
202
|
},
|
|
164
|
-
|
|
203
|
+
);
|
|
165
204
|
});
|
|
166
|
-
})
|
|
205
|
+
} catch (error) {
|
|
206
|
+
if (signal?.aborted) throw error;
|
|
207
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
208
|
+
return withStructuredResult(
|
|
209
|
+
{
|
|
210
|
+
content: [{ type: "text", text: message }],
|
|
211
|
+
details: { failure: { code: "RESOLVE_FAILED", message } },
|
|
212
|
+
},
|
|
213
|
+
searchDataSchema,
|
|
214
|
+
{
|
|
215
|
+
status: "error",
|
|
216
|
+
errors: [resultError(error, "SEARCH_FAILED")],
|
|
217
|
+
},
|
|
218
|
+
);
|
|
219
|
+
}
|
|
167
220
|
},
|
|
168
221
|
},
|
|
169
222
|
interceptionRendering,
|
|
@@ -179,7 +232,15 @@ export default async function registerSearchCore(
|
|
|
179
232
|
function searchCallDetails(arguments_: SearchParameters): ToolCallHeaderDetail[] {
|
|
180
233
|
return [
|
|
181
234
|
{ label: "query", value: JSON.stringify(arguments_.query) },
|
|
182
|
-
...optionalDetail(
|
|
235
|
+
...optionalDetail(
|
|
236
|
+
"path",
|
|
237
|
+
arguments_.path === undefined
|
|
238
|
+
? undefined
|
|
239
|
+
: typeof arguments_.path === "string"
|
|
240
|
+
? arguments_.path
|
|
241
|
+
: "result scope",
|
|
242
|
+
),
|
|
243
|
+
...optionalDetail("navigation", arguments_.navigation),
|
|
183
244
|
...optionalDetail("include", arguments_.include),
|
|
184
245
|
...optionalDetail("exclude", arguments_.exclude),
|
|
185
246
|
...optionalDetail(
|
|
@@ -209,10 +270,15 @@ function fallbackResult(
|
|
|
209
270
|
const text = result.content
|
|
210
271
|
.flatMap((part) => (part.type === "text" ? [part.text] : []))
|
|
211
272
|
.join("\n");
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
273
|
+
return new ResultPanel(
|
|
274
|
+
{
|
|
275
|
+
summary:
|
|
276
|
+
result.details && typeof result.details === "object" && "failure" in result.details
|
|
277
|
+
? "Search failed"
|
|
278
|
+
: "Search results",
|
|
279
|
+
rows: text.split("\n").map((line) => ({ kind: "note", text: line })),
|
|
280
|
+
},
|
|
281
|
+
theme,
|
|
282
|
+
options.expanded,
|
|
283
|
+
);
|
|
218
284
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { withBlockedToolResult } from "pi-agent-tool-call-interception";
|
|
2
|
+
import { resourceAccesses, resourceScheduler, withStructuredResult } from "pi-agent-resource";
|
|
3
|
+
import { searchDataSchema } from "#src/api/structured-result.js";
|
|
2
4
|
|
|
3
5
|
import type { SearchPlugin } from "#src/api/plugin-protocol.js";
|
|
4
6
|
import type {
|
|
@@ -168,6 +170,9 @@ export function createSearchCore(): SearchCore {
|
|
|
168
170
|
return failure("INVALID_REQUEST", "Search query must not be empty");
|
|
169
171
|
}
|
|
170
172
|
|
|
173
|
+
if (request.navigation !== undefined && !request.query.startsWith("symbols:"))
|
|
174
|
+
return failure("INVALID_REQUEST", "navigation is supported only for symbols: queries.");
|
|
175
|
+
|
|
171
176
|
const snapshot = [...resolvers].sort(
|
|
172
177
|
(left, right) =>
|
|
173
178
|
Number(left.registration.fallback === true) -
|
|
@@ -179,13 +184,134 @@ export function createSearchCore(): SearchCore {
|
|
|
179
184
|
const emptyProtocol = /^[a-z][\w-]*:\s*$/iu.test(request.query);
|
|
180
185
|
const protocolLike = /^[a-z][\w-]*:/iu.test(request.query);
|
|
181
186
|
for (const entry of snapshot) {
|
|
182
|
-
if (
|
|
187
|
+
if (context.scope !== undefined && entry.registration.resolver.supportsResultScope !== true)
|
|
188
|
+
continue;
|
|
189
|
+
const structuralProtocol = /^(?:ast|symbols):/u.test(request.query);
|
|
190
|
+
if (entry.registration.fallback && structuralProtocol && context.scope !== undefined)
|
|
191
|
+
continue;
|
|
192
|
+
if (emptyProtocol && !entry.registration.fallback && context.scope === undefined) continue;
|
|
183
193
|
const resolver = entry.registration.resolver;
|
|
184
|
-
let attempt: unknown;
|
|
185
|
-
|
|
186
194
|
try {
|
|
187
|
-
|
|
188
|
-
|
|
195
|
+
const scope = Promise.resolve().then(async () => {
|
|
196
|
+
const sources = await resolver.readResources?.(request, context);
|
|
197
|
+
if (sources === undefined) return [{ resource: "*", mode: "read" as const }];
|
|
198
|
+
return (
|
|
199
|
+
await Promise.all(
|
|
200
|
+
sources.map((source) => resourceAccesses(source, context.cwd, "read")),
|
|
201
|
+
)
|
|
202
|
+
).flat();
|
|
203
|
+
});
|
|
204
|
+
const result = await resourceScheduler.run(
|
|
205
|
+
scope,
|
|
206
|
+
async (): Promise<SearchToolResult | undefined> => {
|
|
207
|
+
let attempt: unknown;
|
|
208
|
+
|
|
209
|
+
try {
|
|
210
|
+
context.signal?.throwIfAborted();
|
|
211
|
+
attempt = await resolver.tryResolve(request, context);
|
|
212
|
+
} catch (error) {
|
|
213
|
+
return failure(
|
|
214
|
+
"RESOLVE_FAILED",
|
|
215
|
+
messageFor(error, `Resolver ${resolver.id} failed`),
|
|
216
|
+
resolver.id,
|
|
217
|
+
error,
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (!isAttempt(attempt)) {
|
|
222
|
+
return failure(
|
|
223
|
+
"INVALID_RESOLVER_RESULT",
|
|
224
|
+
`Resolver ${resolver.id} returned an invalid result`,
|
|
225
|
+
resolver.id,
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (attempt.kind === "not-handled") {
|
|
230
|
+
return undefined;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (attempt.kind === "failed") {
|
|
234
|
+
return failure(
|
|
235
|
+
"RESOLVE_FAILED",
|
|
236
|
+
messageFor(attempt.error, `Resolver ${resolver.id} failed`),
|
|
237
|
+
resolver.id,
|
|
238
|
+
attempt.error,
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
try {
|
|
243
|
+
const formatted = await resolver.format(attempt.payload, context);
|
|
244
|
+
|
|
245
|
+
if (!isAgentToolResult(formatted)) {
|
|
246
|
+
return failure(
|
|
247
|
+
"FORMAT_FAILED",
|
|
248
|
+
`Resolver ${resolver.id} formatter returned an invalid result`,
|
|
249
|
+
resolver.id,
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const data = resolver.toScriptData?.(attempt.payload, formatted.details);
|
|
254
|
+
const missingAdapter = data === undefined;
|
|
255
|
+
return withStructuredResult(
|
|
256
|
+
{
|
|
257
|
+
content:
|
|
258
|
+
entry.registration.fallback && protocolLike
|
|
259
|
+
? [
|
|
260
|
+
{
|
|
261
|
+
type: "text",
|
|
262
|
+
text: emptyProtocol
|
|
263
|
+
? "Search fallback: empty protocol query; searched the original text."
|
|
264
|
+
: "Search fallback: unhandled protocol query; searched the original text.",
|
|
265
|
+
},
|
|
266
|
+
...formatted.content,
|
|
267
|
+
]
|
|
268
|
+
: formatted.content,
|
|
269
|
+
details: { resolverId: resolver.id, payload: formatted.details },
|
|
270
|
+
...(audience === "script" && {
|
|
271
|
+
script: {
|
|
272
|
+
resolverId: resolver.id,
|
|
273
|
+
data: attempt.payload,
|
|
274
|
+
details: formatted.details,
|
|
275
|
+
},
|
|
276
|
+
}),
|
|
277
|
+
...(formatted.usage !== undefined && { usage: formatted.usage }),
|
|
278
|
+
},
|
|
279
|
+
searchDataSchema,
|
|
280
|
+
missingAdapter
|
|
281
|
+
? {
|
|
282
|
+
status: "error",
|
|
283
|
+
errors: [
|
|
284
|
+
{
|
|
285
|
+
code: "STRUCTURED_ADAPTER_REQUIRED",
|
|
286
|
+
message: `Search resolver ${resolver.id} must provide toScriptData`,
|
|
287
|
+
},
|
|
288
|
+
],
|
|
289
|
+
}
|
|
290
|
+
: formatted.isError
|
|
291
|
+
? {
|
|
292
|
+
status: "error",
|
|
293
|
+
data,
|
|
294
|
+
errors: [
|
|
295
|
+
{
|
|
296
|
+
code: "RESOLVE_FAILED",
|
|
297
|
+
message: `Search resolver ${resolver.id} returned an error`,
|
|
298
|
+
},
|
|
299
|
+
],
|
|
300
|
+
}
|
|
301
|
+
: { status: "success", data, errors: [] },
|
|
302
|
+
);
|
|
303
|
+
} catch (error) {
|
|
304
|
+
return failure(
|
|
305
|
+
"FORMAT_FAILED",
|
|
306
|
+
messageFor(error, `Resolver ${resolver.id} formatter failed`),
|
|
307
|
+
resolver.id,
|
|
308
|
+
error,
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
context.signal,
|
|
313
|
+
);
|
|
314
|
+
if (result !== undefined) return result;
|
|
189
315
|
} catch (error) {
|
|
190
316
|
return failure(
|
|
191
317
|
"RESOLVE_FAILED",
|
|
@@ -194,70 +320,6 @@ export function createSearchCore(): SearchCore {
|
|
|
194
320
|
error,
|
|
195
321
|
);
|
|
196
322
|
}
|
|
197
|
-
|
|
198
|
-
if (!isAttempt(attempt)) {
|
|
199
|
-
return failure(
|
|
200
|
-
"INVALID_RESOLVER_RESULT",
|
|
201
|
-
`Resolver ${resolver.id} returned an invalid result`,
|
|
202
|
-
resolver.id,
|
|
203
|
-
);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
if (attempt.kind === "not-handled") {
|
|
207
|
-
continue;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
if (attempt.kind === "failed") {
|
|
211
|
-
return failure(
|
|
212
|
-
"RESOLVE_FAILED",
|
|
213
|
-
messageFor(attempt.error, `Resolver ${resolver.id} failed`),
|
|
214
|
-
resolver.id,
|
|
215
|
-
attempt.error,
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
try {
|
|
220
|
-
const formatted = await resolver.format(attempt.payload, context);
|
|
221
|
-
|
|
222
|
-
if (!isAgentToolResult(formatted)) {
|
|
223
|
-
return failure(
|
|
224
|
-
"FORMAT_FAILED",
|
|
225
|
-
`Resolver ${resolver.id} formatter returned an invalid result`,
|
|
226
|
-
resolver.id,
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
return {
|
|
231
|
-
content:
|
|
232
|
-
entry.registration.fallback && protocolLike
|
|
233
|
-
? [
|
|
234
|
-
{
|
|
235
|
-
type: "text",
|
|
236
|
-
text: emptyProtocol
|
|
237
|
-
? "Search fallback: empty protocol query; searched the original text."
|
|
238
|
-
: "Search fallback: unhandled protocol query; searched the original text.",
|
|
239
|
-
},
|
|
240
|
-
...formatted.content,
|
|
241
|
-
]
|
|
242
|
-
: formatted.content,
|
|
243
|
-
details: { resolverId: resolver.id, payload: formatted.details },
|
|
244
|
-
...(audience === "script" && {
|
|
245
|
-
script: {
|
|
246
|
-
resolverId: resolver.id,
|
|
247
|
-
data: attempt.payload,
|
|
248
|
-
details: formatted.details,
|
|
249
|
-
},
|
|
250
|
-
}),
|
|
251
|
-
...(formatted.usage !== undefined && { usage: formatted.usage }),
|
|
252
|
-
};
|
|
253
|
-
} catch (error) {
|
|
254
|
-
return failure(
|
|
255
|
-
"FORMAT_FAILED",
|
|
256
|
-
messageFor(error, `Resolver ${resolver.id} formatter failed`),
|
|
257
|
-
resolver.id,
|
|
258
|
-
error,
|
|
259
|
-
);
|
|
260
|
-
}
|
|
261
323
|
}
|
|
262
324
|
|
|
263
325
|
const reason = `No search resolver handled ${request.query}`;
|
|
@@ -361,17 +423,22 @@ function failure(
|
|
|
361
423
|
resolverId?: string,
|
|
362
424
|
cause?: unknown,
|
|
363
425
|
): AgentToolResult<SearchToolDetails> {
|
|
364
|
-
return
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
426
|
+
return withStructuredResult(
|
|
427
|
+
{
|
|
428
|
+
isError: true,
|
|
429
|
+
content: [{ type: "text", text: message }],
|
|
430
|
+
details: {
|
|
431
|
+
failure: {
|
|
432
|
+
code,
|
|
433
|
+
message,
|
|
434
|
+
...(resolverId !== undefined && { resolverId }),
|
|
435
|
+
...(cause !== undefined && { cause }),
|
|
436
|
+
},
|
|
372
437
|
},
|
|
373
438
|
},
|
|
374
|
-
|
|
439
|
+
searchDataSchema,
|
|
440
|
+
{ status: "error", errors: [{ code, message }] },
|
|
441
|
+
);
|
|
375
442
|
}
|
|
376
443
|
|
|
377
444
|
function normalizeDescriptionSource(value: unknown): SearchDescriptionSource {
|