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,93 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import type { ResultRange, ResultTargetStore } from "pi-agent-resource";
|
|
3
|
+
import type { ReadPostReadHandler } from "#src/api/tools/read.js";
|
|
4
|
+
|
|
5
|
+
/** Attach source authority only when the read still maps to exact filesystem text. */
|
|
6
|
+
export function createReadResultTargetHandler(store: ResultTargetStore): ReadPostReadHandler {
|
|
7
|
+
return async (context) => {
|
|
8
|
+
const state = context.state;
|
|
9
|
+
if (state?.contentKind !== "text" || state.resolvedBy !== "filesystem")
|
|
10
|
+
return { kind: "continue", context };
|
|
11
|
+
let content: string;
|
|
12
|
+
try {
|
|
13
|
+
content = await readFile(state.source, {
|
|
14
|
+
encoding: "utf8",
|
|
15
|
+
signal: context.resolverContext.signal,
|
|
16
|
+
});
|
|
17
|
+
} catch {
|
|
18
|
+
context.resolverContext.signal?.throwIfAborted();
|
|
19
|
+
return { kind: "continue", context };
|
|
20
|
+
}
|
|
21
|
+
if (content !== state.text.content) return { kind: "continue", context };
|
|
22
|
+
const input =
|
|
23
|
+
context.sourceTarget === undefined
|
|
24
|
+
? undefined
|
|
25
|
+
: store.resolve(context.sourceTarget, context.resolverContext.cwd);
|
|
26
|
+
const sources = input?.targets.filter((target) => target.source === state.source);
|
|
27
|
+
if (sources?.some((target) => target.expectedContent !== content))
|
|
28
|
+
return { kind: "continue", context };
|
|
29
|
+
return {
|
|
30
|
+
kind: "continue",
|
|
31
|
+
context,
|
|
32
|
+
transform(result) {
|
|
33
|
+
const script = result.script;
|
|
34
|
+
if (result.isError || script?.kind !== "text" || script.source !== state.source)
|
|
35
|
+
return result;
|
|
36
|
+
if (
|
|
37
|
+
!script.lines.every((line) => {
|
|
38
|
+
const original = state.text.lines[line.lineNumber - 1];
|
|
39
|
+
return original?.content === line.content && original.lineEnding === line.lineEnding;
|
|
40
|
+
})
|
|
41
|
+
)
|
|
42
|
+
return result;
|
|
43
|
+
const first = script.lines[0];
|
|
44
|
+
const last = script.lines.at(-1);
|
|
45
|
+
const window: ResultRange | undefined =
|
|
46
|
+
first === undefined || last === undefined
|
|
47
|
+
? content.length === 0
|
|
48
|
+
? {
|
|
49
|
+
start: { lineNumber: 1, column: 0 },
|
|
50
|
+
end: { lineNumber: 1, column: 0 },
|
|
51
|
+
}
|
|
52
|
+
: undefined
|
|
53
|
+
: {
|
|
54
|
+
start: { lineNumber: first.lineNumber, column: 0 },
|
|
55
|
+
end:
|
|
56
|
+
last.lineEnding.length > 0
|
|
57
|
+
? { lineNumber: last.lineNumber + 1, column: 0 }
|
|
58
|
+
: { lineNumber: last.lineNumber, column: last.content.length },
|
|
59
|
+
linewise: true,
|
|
60
|
+
};
|
|
61
|
+
const ranges =
|
|
62
|
+
window === undefined
|
|
63
|
+
? []
|
|
64
|
+
: sources === undefined
|
|
65
|
+
? [window]
|
|
66
|
+
: sources.flatMap((source) =>
|
|
67
|
+
source.ranges.flatMap((range) => intersectRange(range, window)),
|
|
68
|
+
);
|
|
69
|
+
const target = store.register(
|
|
70
|
+
ranges.length === 0 ? [] : [{ source: state.source, expectedContent: content, ranges }],
|
|
71
|
+
context.resolverContext.cwd,
|
|
72
|
+
input?.complete ?? true,
|
|
73
|
+
);
|
|
74
|
+
return { ...result, script: { ...script, target } };
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function comparePosition(left: ResultRange["start"], right: ResultRange["start"]): number {
|
|
81
|
+
return left.lineNumber - right.lineNumber || left.column - right.column;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function intersectRange(range: ResultRange, window: ResultRange): ResultRange[] {
|
|
85
|
+
const start = comparePosition(range.start, window.start) >= 0 ? range.start : window.start;
|
|
86
|
+
const end = comparePosition(range.end, window.end) <= 0 ? range.end : window.end;
|
|
87
|
+
if (
|
|
88
|
+
comparePosition(start, end) > 0 ||
|
|
89
|
+
(comparePosition(start, end) === 0 && comparePosition(range.start, range.end) !== 0)
|
|
90
|
+
)
|
|
91
|
+
return [];
|
|
92
|
+
return [{ start, end }];
|
|
93
|
+
}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import { structuredResultSchema, withStructuredResult } from "pi-agent-resource";
|
|
3
|
+
import type { ReadScriptData, ReadToolResult } from "#src/api/tools/read.js";
|
|
4
|
+
import type { TextLine } from "pi-agent-text";
|
|
5
|
+
|
|
6
|
+
const reference = Type.Object(
|
|
7
|
+
{ value: Type.String(), kind: Type.String(), state: Type.Optional(Type.String()) },
|
|
8
|
+
{ additionalProperties: false },
|
|
9
|
+
);
|
|
10
|
+
const line = Type.Object(
|
|
11
|
+
{
|
|
12
|
+
lineNumber: Type.Integer(),
|
|
13
|
+
content: Type.String(),
|
|
14
|
+
lineEnding: Type.String(),
|
|
15
|
+
anchors: Type.Optional(Type.Array(Type.String())),
|
|
16
|
+
},
|
|
17
|
+
{ additionalProperties: false },
|
|
18
|
+
);
|
|
19
|
+
const continuation = Type.Object(
|
|
20
|
+
{ path: Type.String(), offset: Type.Integer() },
|
|
21
|
+
{ additionalProperties: false },
|
|
22
|
+
);
|
|
23
|
+
const common = {
|
|
24
|
+
source: Type.String(),
|
|
25
|
+
truncated: Type.Boolean(),
|
|
26
|
+
continuation: Type.Optional(continuation),
|
|
27
|
+
fullResult: Type.Optional(Type.String()),
|
|
28
|
+
};
|
|
29
|
+
const text = Type.Object(
|
|
30
|
+
{
|
|
31
|
+
...common,
|
|
32
|
+
kind: Type.Literal("text"),
|
|
33
|
+
target: Type.Optional(Type.String()),
|
|
34
|
+
lines: Type.Array(line),
|
|
35
|
+
startLine: Type.Integer(),
|
|
36
|
+
endLine: Type.Integer(),
|
|
37
|
+
totalLines: Type.Integer(),
|
|
38
|
+
references: Type.Optional(Type.Array(reference)),
|
|
39
|
+
},
|
|
40
|
+
{ additionalProperties: false },
|
|
41
|
+
);
|
|
42
|
+
const bytes = Type.Object(
|
|
43
|
+
{
|
|
44
|
+
...common,
|
|
45
|
+
kind: Type.Literal("bytes"),
|
|
46
|
+
bytes: Type.Array(Type.Integer({ minimum: 0, maximum: 255 })),
|
|
47
|
+
byteOffset: Type.Integer(),
|
|
48
|
+
byteLength: Type.Integer(),
|
|
49
|
+
totalBytes: Type.Integer(),
|
|
50
|
+
},
|
|
51
|
+
{ additionalProperties: false },
|
|
52
|
+
);
|
|
53
|
+
const block = Type.Union([
|
|
54
|
+
Type.Object({ type: Type.Literal("text"), text: Type.String() }, { additionalProperties: false }),
|
|
55
|
+
Type.Object(
|
|
56
|
+
{ type: Type.Literal("image"), data: Type.String(), mimeType: Type.String() },
|
|
57
|
+
{ additionalProperties: false },
|
|
58
|
+
),
|
|
59
|
+
]);
|
|
60
|
+
const native = Type.Object(
|
|
61
|
+
{ ...common, kind: Type.Literal("native"), blocks: Type.Array(block) },
|
|
62
|
+
{ additionalProperties: false },
|
|
63
|
+
);
|
|
64
|
+
export const readDataSchema = Type.Union([
|
|
65
|
+
Type.Object(
|
|
66
|
+
{
|
|
67
|
+
kind: Type.Literal("recovery"),
|
|
68
|
+
source: Type.String(),
|
|
69
|
+
candidates: Type.Array(Type.Object({ path: Type.String() }, { additionalProperties: false })),
|
|
70
|
+
},
|
|
71
|
+
{ additionalProperties: false },
|
|
72
|
+
),
|
|
73
|
+
text,
|
|
74
|
+
bytes,
|
|
75
|
+
native,
|
|
76
|
+
Type.Object(
|
|
77
|
+
{
|
|
78
|
+
kind: Type.Literal("resources"),
|
|
79
|
+
source: Type.Optional(Type.String()),
|
|
80
|
+
resources: Type.Array(Type.Union([text, bytes, native])),
|
|
81
|
+
truncated: Type.Boolean(),
|
|
82
|
+
fullResult: Type.Optional(Type.String()),
|
|
83
|
+
},
|
|
84
|
+
{ additionalProperties: false },
|
|
85
|
+
),
|
|
86
|
+
]);
|
|
87
|
+
export const readOutputSchema = structuredResultSchema(readDataSchema);
|
|
88
|
+
|
|
89
|
+
function publicLine(value: TextLine) {
|
|
90
|
+
return {
|
|
91
|
+
lineNumber: value.lineNumber,
|
|
92
|
+
content: value.content,
|
|
93
|
+
lineEnding: value.lineEnding,
|
|
94
|
+
...(value.anchors === undefined ? {} : { anchors: [...value.anchors] }),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/** Bound selected data, not source snapshots or human-facing presentation. */
|
|
98
|
+
function publicData(value: ReadScriptData): unknown {
|
|
99
|
+
if (value.kind === "resources") {
|
|
100
|
+
const resources = value.resources.map((resource) => publicData(resource));
|
|
101
|
+
return {
|
|
102
|
+
kind: value.kind,
|
|
103
|
+
...(value.source === undefined ? {} : { source: value.source }),
|
|
104
|
+
resources,
|
|
105
|
+
truncated: resources.some(
|
|
106
|
+
(resource) =>
|
|
107
|
+
typeof resource === "object" &&
|
|
108
|
+
resource !== null &&
|
|
109
|
+
"truncated" in resource &&
|
|
110
|
+
resource.truncated === true,
|
|
111
|
+
),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
if (value.kind === "bytes") {
|
|
115
|
+
const bytes = value.bytes.slice(0, 32768);
|
|
116
|
+
const truncated = value.truncated === true || bytes.length < value.bytes.length;
|
|
117
|
+
return {
|
|
118
|
+
kind: value.kind,
|
|
119
|
+
source: value.source,
|
|
120
|
+
bytes,
|
|
121
|
+
byteOffset: value.byteOffset,
|
|
122
|
+
byteLength: bytes.length,
|
|
123
|
+
totalBytes: value.totalBytes,
|
|
124
|
+
truncated,
|
|
125
|
+
...(value.byteOffset + bytes.length < value.totalBytes
|
|
126
|
+
? { continuation: { path: value.source, offset: value.byteOffset + bytes.length } }
|
|
127
|
+
: {}),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
if (value.kind === "native")
|
|
131
|
+
return {
|
|
132
|
+
kind: value.kind,
|
|
133
|
+
source: value.source,
|
|
134
|
+
truncated: false,
|
|
135
|
+
blocks: value.blocks.map((block) => {
|
|
136
|
+
if (block.type === "text") return { type: block.type, text: block.text };
|
|
137
|
+
if (block.type === "image")
|
|
138
|
+
return { type: block.type, data: block.data, mimeType: block.mimeType };
|
|
139
|
+
throw new TypeError("Custom content requires a structured adapter");
|
|
140
|
+
}),
|
|
141
|
+
};
|
|
142
|
+
const lines = [];
|
|
143
|
+
let size = 0;
|
|
144
|
+
for (const line of value.lines) {
|
|
145
|
+
const projected = publicLine(line);
|
|
146
|
+
size += Buffer.byteLength(JSON.stringify(projected));
|
|
147
|
+
if (lines.length >= 2000 || size > 512 * 1024) break;
|
|
148
|
+
lines.push(projected);
|
|
149
|
+
}
|
|
150
|
+
if (lines.length === 0 && value.lines.length > 0)
|
|
151
|
+
throw new RangeError(
|
|
152
|
+
"Selected line exceeds the structured window; use a raw byte range or a source-specific view",
|
|
153
|
+
);
|
|
154
|
+
const truncated = lines.length < value.lines.length;
|
|
155
|
+
const endLine = lines.at(-1)?.lineNumber ?? value.startLine - 1;
|
|
156
|
+
// Continue against the resolved source with absolute line numbers, not a relative selector.
|
|
157
|
+
return {
|
|
158
|
+
kind: value.kind,
|
|
159
|
+
source: value.source,
|
|
160
|
+
lines,
|
|
161
|
+
startLine: lines[0]?.lineNumber ?? 0,
|
|
162
|
+
endLine: lines.at(-1)?.lineNumber ?? 0,
|
|
163
|
+
totalLines: value.totalLines,
|
|
164
|
+
truncated,
|
|
165
|
+
...(value.target === undefined ? {} : { target: value.target }),
|
|
166
|
+
...(value.references === undefined ? {} : { references: value.references }),
|
|
167
|
+
...(truncated || endLine < value.totalLines
|
|
168
|
+
? { continuation: { path: value.source, offset: endLine + 1 } }
|
|
169
|
+
: {}),
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** Require resolver-owned script data. Never reconstruct it from rendered content or renderer details. */
|
|
174
|
+
export function structuredRead(result: ReadToolResult): ReadToolResult {
|
|
175
|
+
const failure = result.details.failure;
|
|
176
|
+
if (result.isError || failure !== undefined)
|
|
177
|
+
return withStructuredResult(result, readDataSchema, {
|
|
178
|
+
status: "error",
|
|
179
|
+
...(failure?.candidates?.length && failure.source !== undefined
|
|
180
|
+
? {
|
|
181
|
+
data: { kind: "recovery", source: failure.source, candidates: failure.candidates },
|
|
182
|
+
}
|
|
183
|
+
: {}),
|
|
184
|
+
errors: [
|
|
185
|
+
{
|
|
186
|
+
code: failure?.code ?? "READ_FAILED",
|
|
187
|
+
message: failure?.message ?? "Read failed",
|
|
188
|
+
...(failure?.source === undefined ? {} : { source: failure.source }),
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
});
|
|
192
|
+
try {
|
|
193
|
+
if (result.script === undefined)
|
|
194
|
+
throw new TypeError("Read handler must return structured script data");
|
|
195
|
+
const data = publicData(result.script);
|
|
196
|
+
return withStructuredResult(result, readDataSchema, {
|
|
197
|
+
status: "success",
|
|
198
|
+
data:
|
|
199
|
+
result.details.temporarySource !== undefined && typeof data === "object" && data !== null
|
|
200
|
+
? { ...data, fullResult: result.details.temporarySource }
|
|
201
|
+
: data,
|
|
202
|
+
errors: [],
|
|
203
|
+
});
|
|
204
|
+
} catch (error) {
|
|
205
|
+
return withStructuredResult(result, readDataSchema, {
|
|
206
|
+
status: "error",
|
|
207
|
+
errors: [
|
|
208
|
+
{
|
|
209
|
+
code:
|
|
210
|
+
error instanceof RangeError
|
|
211
|
+
? "STRUCTURED_RESULT_TOO_LARGE"
|
|
212
|
+
: "STRUCTURED_ADAPTER_REQUIRED",
|
|
213
|
+
message: error instanceof Error ? error.message : String(error),
|
|
214
|
+
},
|
|
215
|
+
],
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
@@ -4,6 +4,8 @@ import { type ToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
|
4
4
|
import {
|
|
5
5
|
isAgentContent,
|
|
6
6
|
isResourceResolutionAttempt,
|
|
7
|
+
resourceScheduler,
|
|
8
|
+
resourceAccesses,
|
|
7
9
|
type ResourceResolver,
|
|
8
10
|
type ResourceResolverContext,
|
|
9
11
|
} from "pi-agent-resource";
|
|
@@ -56,6 +58,7 @@ import { TempResourceStore } from "#src/core/tools/read/temp-resource-store.js";
|
|
|
56
58
|
|
|
57
59
|
import { readParameters } from "#src/api/read-parameters.js";
|
|
58
60
|
import { readRaw } from "#src/core/tools/read/raw-read.js";
|
|
61
|
+
import { readOutputSchema, structuredRead } from "./read/structured-result.js";
|
|
59
62
|
|
|
60
63
|
const fallbackReadRenderer = createReadResultRenderer({ kind: "source" });
|
|
61
64
|
|
|
@@ -65,6 +68,7 @@ interface RegisteredResourceGuard {
|
|
|
65
68
|
}
|
|
66
69
|
|
|
67
70
|
interface RegisteredResolver {
|
|
71
|
+
readonly recoverFailure?: ResourceResolverRegistration["recoverFailure"];
|
|
68
72
|
readonly resolver: ResourceResolver;
|
|
69
73
|
readonly matchesCall?: (source: string) => boolean;
|
|
70
74
|
readonly renderCall?: NonNullable<ToolDefinition["renderCall"]>;
|
|
@@ -147,6 +151,15 @@ export function createReadTool(
|
|
|
147
151
|
saveTemporary: (text) => temporaryResources.save(text),
|
|
148
152
|
tool: {
|
|
149
153
|
name: toolId,
|
|
154
|
+
exposure: "direct",
|
|
155
|
+
namespace: { name: "ide_read", description: "Read resources and compare sources." },
|
|
156
|
+
// Resource plugins can run processes and change live session state.
|
|
157
|
+
annotations: {
|
|
158
|
+
readOnlyHint: false,
|
|
159
|
+
destructiveHint: true,
|
|
160
|
+
idempotentHint: false,
|
|
161
|
+
openWorldHint: true,
|
|
162
|
+
},
|
|
150
163
|
label: toolId,
|
|
151
164
|
|
|
152
165
|
promptSnippet: "Read supported sources as text or bytes, with optional views",
|
|
@@ -160,6 +173,7 @@ export function createReadTool(
|
|
|
160
173
|
];
|
|
161
174
|
},
|
|
162
175
|
parameters: readParameters,
|
|
176
|
+
outputSchema: readOutputSchema,
|
|
163
177
|
renderCall(arguments_, theme, context) {
|
|
164
178
|
const source = typeof arguments_.path === "string" ? arguments_.path : undefined;
|
|
165
179
|
const renderer =
|
|
@@ -194,17 +208,29 @@ export function createReadTool(
|
|
|
194
208
|
cwd: context.cwd,
|
|
195
209
|
...(signal !== undefined && { signal }),
|
|
196
210
|
};
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
211
|
+
try {
|
|
212
|
+
const result = await executeRead(
|
|
213
|
+
parameters,
|
|
214
|
+
resolverContext,
|
|
215
|
+
resolvers,
|
|
216
|
+
handlers,
|
|
217
|
+
views,
|
|
218
|
+
temporaryResources,
|
|
219
|
+
fragments,
|
|
220
|
+
targetResolvers,
|
|
221
|
+
resourceGuards,
|
|
222
|
+
);
|
|
223
|
+
return structuredRead(result);
|
|
224
|
+
} catch (error) {
|
|
225
|
+
if (signal?.aborted) throw error;
|
|
226
|
+
return structuredRead(
|
|
227
|
+
failureResult({
|
|
228
|
+
code: "READ_FAILED",
|
|
229
|
+
source: parameters.path,
|
|
230
|
+
message: error instanceof Error ? error.message : String(error),
|
|
231
|
+
}),
|
|
232
|
+
);
|
|
233
|
+
}
|
|
208
234
|
},
|
|
209
235
|
},
|
|
210
236
|
execute(request, context, audience = "agent"): Promise<ReadToolResult> {
|
|
@@ -285,6 +311,9 @@ export function createReadTool(
|
|
|
285
311
|
}),
|
|
286
312
|
priority: registration.priority ?? 0,
|
|
287
313
|
preserveTruncatedOutput: registration.preserveTruncatedOutput ?? false,
|
|
314
|
+
...(registration.recoverFailure === undefined
|
|
315
|
+
? {}
|
|
316
|
+
: { recoverFailure: registration.recoverFailure }),
|
|
288
317
|
order: resolvers.length,
|
|
289
318
|
});
|
|
290
319
|
}
|
|
@@ -572,13 +601,20 @@ async function resolveTextTargets(
|
|
|
572
601
|
const chunks: string[] = [];
|
|
573
602
|
const resources: ReadToolResult[] = [];
|
|
574
603
|
let firstDetails: ReadResultDetails | undefined;
|
|
575
|
-
|
|
604
|
+
const pending = attempt.targets.flatMap((target) => {
|
|
576
605
|
const ranges = target.ranges ?? [
|
|
577
606
|
{ start: { lineNumber: 1, column: 0 }, end: { lineNumber: 1, column: 1 } },
|
|
578
607
|
];
|
|
579
|
-
|
|
580
|
-
const
|
|
608
|
+
return ranges.map(async (range): Promise<ReadToolResult> => {
|
|
609
|
+
const sourceTarget = request.path?.startsWith("RESULT#") ? request.path : undefined;
|
|
610
|
+
const rangeLimit = Math.max(
|
|
611
|
+
1,
|
|
612
|
+
range.end.lineNumber -
|
|
613
|
+
range.start.lineNumber +
|
|
614
|
+
(sourceTarget !== undefined && range.end.column > 0 ? 1 : 0),
|
|
615
|
+
);
|
|
581
616
|
let rangePipeline: ReadPipelineContext = {
|
|
617
|
+
sourceTarget,
|
|
582
618
|
request: {
|
|
583
619
|
...request,
|
|
584
620
|
path: target.source,
|
|
@@ -592,12 +628,7 @@ async function resolveTextTargets(
|
|
|
592
628
|
if (preRead.kind === "return") {
|
|
593
629
|
if (preRead.result.isError === true)
|
|
594
630
|
return withIgnoredViews(preRead.result, ignoredViews);
|
|
595
|
-
|
|
596
|
-
if (block.type === "text") chunks.push(block.text);
|
|
597
|
-
}
|
|
598
|
-
resources.push(preRead.result);
|
|
599
|
-
firstDetails ??= preRead.result.details;
|
|
600
|
-
continue;
|
|
631
|
+
return preRead.result;
|
|
601
632
|
}
|
|
602
633
|
rangePipeline = preRead.context;
|
|
603
634
|
}
|
|
@@ -614,12 +645,7 @@ async function resolveTextTargets(
|
|
|
614
645
|
if (processed.kind === "return") {
|
|
615
646
|
if (processed.result.isError === true)
|
|
616
647
|
return withIgnoredViews(processed.result, ignoredViews);
|
|
617
|
-
|
|
618
|
-
if (block.type === "text") chunks.push(block.text);
|
|
619
|
-
}
|
|
620
|
-
resources.push(processed.result);
|
|
621
|
-
firstDetails ??= processed.result.details;
|
|
622
|
-
continue;
|
|
648
|
+
return processed.result;
|
|
623
649
|
}
|
|
624
650
|
const presented = await runTextPresenters(processed.context, views, requestedViews);
|
|
625
651
|
const projected = projectReadState(requiredValue(presented.state), presented.request, {
|
|
@@ -631,31 +657,29 @@ async function resolveTextTargets(
|
|
|
631
657
|
const result =
|
|
632
658
|
postRead.kind === "return" ? postRead.result : requiredValue(postRead.context.result);
|
|
633
659
|
if (result.isError === true) return withIgnoredViews(result, ignoredViews);
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
660
|
+
return result;
|
|
661
|
+
});
|
|
662
|
+
});
|
|
663
|
+
const completed = await Promise.allSettled(pending);
|
|
664
|
+
for (const outcome of completed) {
|
|
665
|
+
if (outcome.status === "rejected") throw outcome.reason;
|
|
666
|
+
const result = outcome.value;
|
|
667
|
+
if (result.isError === true) return withIgnoredViews(result, ignoredViews);
|
|
668
|
+
for (const block of result.content) {
|
|
669
|
+
if (block.type === "text") chunks.push(block.text);
|
|
639
670
|
}
|
|
671
|
+
resources.push(result);
|
|
672
|
+
firstDetails ??= result.details;
|
|
640
673
|
}
|
|
641
674
|
const aggregate = {
|
|
642
|
-
|
|
643
|
-
script
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
(result) =>
|
|
651
|
-
result.script ?? {
|
|
652
|
-
kind: "native" as const,
|
|
653
|
-
source: result.details.source ?? request.path ?? "",
|
|
654
|
-
blocks: result.content,
|
|
655
|
-
},
|
|
656
|
-
),
|
|
657
|
-
},
|
|
658
|
-
}),
|
|
675
|
+
script:
|
|
676
|
+
resources.length === 1 && resources[0]?.script !== undefined
|
|
677
|
+
? resources[0].script
|
|
678
|
+
: {
|
|
679
|
+
kind: "resources" as const,
|
|
680
|
+
source: request.path,
|
|
681
|
+
resources: resources.map((result) => requiredValue(result.script)),
|
|
682
|
+
},
|
|
659
683
|
content: [{ type: "text", text: chunks.join("\n") }],
|
|
660
684
|
details:
|
|
661
685
|
audience === "script"
|
|
@@ -794,6 +818,15 @@ async function resolveSource(
|
|
|
794
818
|
|
|
795
819
|
for (const registeredResolver of resolvers) {
|
|
796
820
|
const { resolver } = registeredResolver;
|
|
821
|
+
const recoveredFailure = async (failure: ReadFailure): Promise<ReadToolResult> => {
|
|
822
|
+
try {
|
|
823
|
+
const candidates = await registeredResolver.recoverFailure?.(failure, resolverContext);
|
|
824
|
+
return failureResult({ ...failure, ...(candidates?.length ? { candidates } : {}) });
|
|
825
|
+
} catch {
|
|
826
|
+
// A failed hint search must never replace the original read error.
|
|
827
|
+
return failureResult(failure);
|
|
828
|
+
}
|
|
829
|
+
};
|
|
797
830
|
let attempt: unknown;
|
|
798
831
|
|
|
799
832
|
try {
|
|
@@ -801,7 +834,7 @@ async function resolveSource(
|
|
|
801
834
|
} catch (error) {
|
|
802
835
|
return {
|
|
803
836
|
kind: "return",
|
|
804
|
-
result:
|
|
837
|
+
result: await recoveredFailure({
|
|
805
838
|
code: "RESOLVE_FAILED",
|
|
806
839
|
source,
|
|
807
840
|
resolverId: resolver.id,
|
|
@@ -831,7 +864,7 @@ async function resolveSource(
|
|
|
831
864
|
if (attempt.kind === "failed") {
|
|
832
865
|
return {
|
|
833
866
|
kind: "return",
|
|
834
|
-
result:
|
|
867
|
+
result: await recoveredFailure({
|
|
835
868
|
code: "RESOLVE_FAILED",
|
|
836
869
|
source,
|
|
837
870
|
resolverId: resolver.id,
|
|
@@ -902,13 +935,18 @@ async function resolveSource(
|
|
|
902
935
|
let content: unknown;
|
|
903
936
|
|
|
904
937
|
try {
|
|
905
|
-
content = await
|
|
906
|
-
|
|
907
|
-
|
|
938
|
+
content = await resourceScheduler.run(
|
|
939
|
+
resourceAccesses(resource.source, resolverContext.cwd, "read"),
|
|
940
|
+
() =>
|
|
941
|
+
requiredValue(resource.read)({
|
|
942
|
+
...(resolverContext.signal !== undefined && { signal: resolverContext.signal }),
|
|
943
|
+
}),
|
|
944
|
+
resolverContext.signal,
|
|
945
|
+
);
|
|
908
946
|
} catch (error) {
|
|
909
947
|
return {
|
|
910
948
|
kind: "return",
|
|
911
|
-
result:
|
|
949
|
+
result: await recoveredFailure({
|
|
912
950
|
code: "READ_FAILED",
|
|
913
951
|
source: resource.source,
|
|
914
952
|
resolverId: resolver.id,
|
|
@@ -1100,7 +1138,18 @@ function mergeViewContributions(
|
|
|
1100
1138
|
);
|
|
1101
1139
|
}
|
|
1102
1140
|
|
|
1103
|
-
|
|
1141
|
+
const references = [
|
|
1142
|
+
...new Map(
|
|
1143
|
+
[base, ...contributions.map((contribution) => contribution.document)]
|
|
1144
|
+
.flatMap((document) => document.references ?? [])
|
|
1145
|
+
.map((reference) => [reference.value, reference]),
|
|
1146
|
+
).values(),
|
|
1147
|
+
];
|
|
1148
|
+
return {
|
|
1149
|
+
...base,
|
|
1150
|
+
lines,
|
|
1151
|
+
...(references.length === 0 ? {} : { references }),
|
|
1152
|
+
};
|
|
1104
1153
|
}
|
|
1105
1154
|
|
|
1106
1155
|
function assertPresentationOnly(base: TextDocument, contribution: ViewContribution): void {
|
|
@@ -1282,28 +1331,33 @@ async function runPostReadHandlers(
|
|
|
1282
1331
|
initialContext: ReadPipelineContext,
|
|
1283
1332
|
handlers: readonly RegisteredHandler[],
|
|
1284
1333
|
): Promise<ReadStageOutcome> {
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
"post-read",
|
|
1297
|
-
);
|
|
1334
|
+
const postHandlers = handlers.filter(({ registration }) => registration.stage === "post-read");
|
|
1335
|
+
const outcomes = await Promise.all(
|
|
1336
|
+
postHandlers.map((registered) =>
|
|
1337
|
+
invokeHandler(
|
|
1338
|
+
registered.registration.handler,
|
|
1339
|
+
initialContext,
|
|
1340
|
+
registered.pluginId,
|
|
1341
|
+
"post-read",
|
|
1342
|
+
),
|
|
1343
|
+
),
|
|
1344
|
+
);
|
|
1298
1345
|
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1346
|
+
for (const outcome of outcomes) {
|
|
1347
|
+
if (outcome.kind === "return") return outcome;
|
|
1348
|
+
}
|
|
1302
1349
|
|
|
1303
|
-
|
|
1350
|
+
let result = initialContext.result;
|
|
1351
|
+
for (const outcome of outcomes) {
|
|
1352
|
+
if (outcome.kind === "return" || outcome.transform === undefined) continue;
|
|
1353
|
+
if (result === undefined) throw new Error("Post-read transform requires a read result");
|
|
1354
|
+
result = outcome.transform(result);
|
|
1304
1355
|
}
|
|
1305
1356
|
|
|
1306
|
-
return {
|
|
1357
|
+
return {
|
|
1358
|
+
kind: "continue",
|
|
1359
|
+
context: result === undefined ? initialContext : { ...initialContext, result },
|
|
1360
|
+
};
|
|
1307
1361
|
}
|
|
1308
1362
|
|
|
1309
1363
|
async function invokeHandler(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-search",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -20,9 +20,10 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"pi-agent-documentation": "0.
|
|
24
|
-
"pi-agent-
|
|
25
|
-
"pi-agent-tool-
|
|
23
|
+
"pi-agent-documentation": "0.7.0",
|
|
24
|
+
"pi-agent-resource": "0.7.0",
|
|
25
|
+
"pi-agent-tool-call-interception": "0.7.0",
|
|
26
|
+
"pi-agent-tool-ui": "0.7.0"
|
|
26
27
|
},
|
|
27
28
|
"pi": {
|
|
28
29
|
"extensions": [
|