pi-agent-ide 0.6.3 → 0.6.4
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 +59 -0
- package/README.md +8 -1
- package/dist/chunk-2P2OGO3G.js +2 -0
- package/dist/{chunk-5QQABP47.js → chunk-3BBJZSMS.js} +1 -1
- package/dist/chunk-5J43L2RL.js +11 -0
- package/dist/{chunk-ITSNK5YG.js → chunk-7AVXUV4A.js} +2 -2
- package/dist/chunk-BAYETTZZ.js +16 -0
- package/dist/{chunk-VCTK4JSN.js → chunk-BSICWXMH.js} +1 -1
- package/dist/chunk-BVK5A7ED.js +28 -0
- package/dist/{chunk-ZM4L5AGN.js → chunk-EDURPQAV.js} +3 -2
- package/dist/{chunk-L7JMDDSD.js → chunk-FBOW7XOV.js} +1 -1
- package/dist/{chunk-25CZ5ZIU.js → chunk-FUG2TEKI.js} +1 -1
- package/dist/chunk-FZBCKIJJ.js +1 -0
- package/dist/chunk-HPUAIWIH.js +25 -0
- package/dist/chunk-I5JLCFUX.js +1 -0
- package/dist/chunk-KUPHNMUK.js +2 -0
- package/dist/{chunk-NTYXZ3EL.js → chunk-KVHDMIZS.js} +1 -1
- package/dist/{chunk-QDST6VIU.js → chunk-KZC7TI5M.js} +1 -1
- package/dist/chunk-MIZAFRDR.js +1 -0
- package/dist/chunk-PJPA5EEE.js +2 -0
- package/dist/{chunk-GUTQ3PWL.js → chunk-PLKYHUNT.js} +1 -1
- package/dist/chunk-QEJGED4V.js +28 -0
- package/dist/chunk-SILJ3OL4.js +9 -0
- package/dist/{chunk-VXD6FZP5.js → chunk-TQZBVOTT.js} +3 -3
- package/dist/chunk-VBICI5YA.js +1 -0
- package/dist/chunk-VWW3RLUX.js +12 -0
- package/dist/{chunk-O6LE42GK.js → chunk-WJTHY6AG.js} +1 -1
- package/dist/chunk-YGGKGZO2.js +1 -0
- package/dist/chunk-ZODCBFBL.js +2 -0
- 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 -11
- package/dist/entry-33.js +1 -1
- package/dist/entry-37.js +2 -2
- package/dist/entry-42.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +13 -12
- package/dist/entry-46.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +4 -4
- package/dist/entry-51.js +9 -9
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.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 +1 -1
- package/dist/entry-63.js +1 -1
- package/dist/entry-66.js +1 -1
- package/dist/entry-68.js +1 -1
- package/dist/entry-69.js +1 -1
- package/dist/entry-70.js +1 -1
- package/dist/entry-71.js +1 -0
- package/dist/entry-72.js +0 -1
- package/dist/entry-73.js +1 -0
- package/dist/entry-74.js +0 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-76.js +1 -1
- package/dist/entry-77.js +1 -324
- package/dist/entry-78.js +324 -25
- package/dist/entry-79.js +18 -2
- package/dist/entry-80.js +2 -1
- package/dist/entry-81.js +1 -1
- package/dist/entry-82.js +1 -3
- package/dist/entry-83.js +5 -3
- package/dist/entry-84.js +3 -1
- package/dist/entry-85.js +1 -1
- package/dist/entry-86.js +1 -1
- package/dist/entry-87.js +1 -0
- package/dist/pi-agent-ide.js +15 -3
- package/docs/agent-guides/editing.md +12 -0
- package/docs/agent-guides/json-reading.md +19 -3
- package/docs/agent-guides/read-resources.md +6 -0
- package/docs/agent-guides/search-code.md +5 -1
- package/docs/agent-guides/terminal.md +1 -1
- package/docs/code-review.md +99 -0
- package/docs/configuration.md +34 -0
- package/docs/development.md +15 -19
- package/docs/nightly.md +7 -0
- package/docs/releases.md +42 -0
- package/docs/research/native-codemode-batch-decision.md +27 -0
- package/docs/research/native-codemode-batching.md +65 -0
- package/docs/structured-results.md +59 -0
- package/docs/tools.md +18 -2
- 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 +10 -10
- 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 +17 -0
- package/node_modules/pi-agent-ide-changes/index.ts +3 -9
- 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 +125 -47
- 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/package.json +9 -9
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +19 -0
- 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/tools/read.ts +31 -2
- 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/structured-result.ts +216 -0
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +119 -72
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/index.ts +12 -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/tool-result.ts +125 -0
- package/node_modules/pi-agent-search/package.json +5 -4
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +6 -5
- package/node_modules/pi-agent-search/src/api/search.ts +11 -0
- package/node_modules/pi-agent-search/src/api/structured-result.ts +93 -0
- package/node_modules/pi-agent-search/src/core/extension.ts +40 -14
- package/node_modules/pi-agent-search/src/core/search-core.ts +136 -77
- package/node_modules/pi-agent-search-text/index.ts +3 -0
- package/node_modules/pi-agent-search-text/package.json +6 -6
- package/node_modules/pi-agent-search-text/src/resolvers.ts +17 -0
- package/node_modules/pi-agent-search-text/src/search-backend.ts +104 -8
- 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 +37 -3
- package/node_modules/pi-agent-search-text/src/search-session.ts +21 -13
- 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 -2
- package/node_modules/pi-agent-text-editor/package.json +21 -17
- package/node_modules/pi-agent-text-editor/runtime/entry-77.js +0 -1
- 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/native-edit-batch-event.ts +12 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +4 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +95 -34
- package/node_modules/pi-agent-text-editor/src/core/apply/results.ts +4 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/structured-result.ts +251 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +32 -12
- package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +154 -132
- 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 +74 -18
- package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +8 -0
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +6 -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/native-text-edit-batch.ts +640 -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/structured-result.ts +314 -0
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +143 -138
- 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 +242 -116
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +109 -47
- 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-renderer/index.ts +8 -1
- package/node_modules/pi-agent-text-editor-renderer/package.json +7 -6
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +262 -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-stale-anchor/index.ts +16 -1
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +2 -0
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-82.js +1 -0
- package/node_modules/pi-agent-web/index.ts +20 -0
- package/node_modules/pi-agent-web/package.json +8 -7
- package/node_modules/pi-agent-web/src/search.ts +112 -0
- package/node_modules/pi-agent-web-html/package.json +3 -3
- package/node_modules/pi-agent-web-image/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/node_modules/pi-agent-web-text/runtime/entry-87.js +2 -0
- package/package.json +42 -36
- 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/nested-tool-rendering.ts +298 -0
- 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 +20 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-87.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-83.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/search.ts +112 -0
- package/src/extensions/pi-agent-read/package.json +7 -7
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +31 -2
- 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/structured-result.ts +216 -0
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +119 -72
- package/src/extensions/pi-agent-search/package.json +5 -4
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +3 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +6 -6
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +17 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +104 -8
- 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 +37 -3
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +21 -13
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +6 -5
- package/src/extensions/pi-agent-search/src/api/search.ts +11 -0
- package/src/extensions/pi-agent-search/src/api/structured-result.ts +93 -0
- package/src/extensions/pi-agent-search/src/core/extension.ts +40 -14
- package/src/extensions/pi-agent-search/src/core/search-core.ts +136 -77
- package/src/extensions/pi-agent-text-editor/index.ts +4 -2
- package/src/extensions/pi-agent-text-editor/package.json +21 -17
- 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 +8 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +7 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +262 -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-stale-anchor/index.ts +16 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +2 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-77.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-78.js +2 -0
- 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/native-edit-batch-event.ts +12 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +4 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +95 -34
- package/src/extensions/pi-agent-text-editor/src/core/apply/results.ts +4 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/structured-result.ts +251 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +32 -12
- package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +154 -132
- 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 +74 -18
- package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +8 -0
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +6 -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/native-text-edit-batch.ts +640 -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/structured-result.ts +314 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +143 -138
- 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 +242 -116
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +109 -47
- 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/pi-agent-ide.ts +61 -2
- package/src/plugins/pi-agent-ide-ast/package.json +10 -10
- 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 +17 -0
- package/src/plugins/pi-agent-ide-changes/index.ts +3 -9
- 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 +125 -47
- 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/package.json +9 -9
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +19 -0
- 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 +13 -8
- 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 +97 -45
- 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 +16 -1
- package/dist/chunk-3E2NTWCN.js +0 -2
- package/dist/chunk-4LUW26BX.js +0 -10
- package/dist/chunk-5VSE5X5R.js +0 -2
- 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-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-S3ZPXWX7.js +0 -2
- package/dist/chunk-T7CZIACQ.js +0 -27
- package/dist/chunk-YT42LKFV.js +0 -16
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +0 -52
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-80.js +0 -1
- package/node_modules/pi-agent-web/runtime/entry-82.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-83.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-82.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-78.js +0 -2
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +0 -52
- /package/dist/{chunk-4U2GUKNJ.js → chunk-F7NVAC4Q.js} +0 -0
- /package/dist/{chunk-ROXXK6TW.js → chunk-PXWDDBBC.js} +0 -0
- /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor}/runtime/entry-78.js +0 -0
- /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-79.js +0 -0
- /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-81.js +0 -0
- /package/node_modules/{pi-agent-web-html → pi-agent-web}/runtime/entry-83.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-84.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-85.js +0 -0
- /package/node_modules/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-86.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-84.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-85.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-86.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-79.js +0 -0
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-ide-lsp",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"cross-spawn": "^7.0.6",
|
|
7
|
-
"pi-agent-doctor": "0.6.
|
|
8
|
-
"pi-agent-invariant": "0.6.
|
|
9
|
-
"pi-agent-read": "0.6.
|
|
10
|
-
"pi-agent-resource": "0.6.
|
|
11
|
-
"pi-agent-search": "0.6.
|
|
12
|
-
"pi-agent-text": "0.6.
|
|
13
|
-
"pi-agent-text-editor": "0.6.
|
|
7
|
+
"pi-agent-doctor": "0.6.4",
|
|
8
|
+
"pi-agent-invariant": "0.6.4",
|
|
9
|
+
"pi-agent-read": "0.6.4",
|
|
10
|
+
"pi-agent-resource": "0.6.4",
|
|
11
|
+
"pi-agent-search": "0.6.4",
|
|
12
|
+
"pi-agent-text": "0.6.4",
|
|
13
|
+
"pi-agent-text-editor": "0.6.4",
|
|
14
14
|
"vscode-jsonrpc": "^9.0.0",
|
|
15
15
|
"vscode-uri": "^3.1.0"
|
|
16
16
|
},
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"@earendil-works/pi-coding-agent": "*",
|
|
24
|
-
"pi-agent-ide": "0.6.
|
|
24
|
+
"pi-agent-ide": "0.6.4"
|
|
25
25
|
},
|
|
26
26
|
"peerDependenciesMeta": {
|
|
27
27
|
"pi-agent-ide": {
|
|
@@ -9,6 +9,25 @@ export function createLspSearchResolver(
|
|
|
9
9
|
): SearchResolver {
|
|
10
10
|
return {
|
|
11
11
|
id: "symbols",
|
|
12
|
+
// Workspace symbol backends may read beyond the requested path.
|
|
13
|
+
readResources: (request) => (request.query.startsWith("symbols:") ? undefined : []),
|
|
14
|
+
toScriptData(payload) {
|
|
15
|
+
const { query, hits } = payload as { query: string; hits: readonly SymbolHit[] };
|
|
16
|
+
return {
|
|
17
|
+
kind: "custom",
|
|
18
|
+
resolverId: "symbols",
|
|
19
|
+
value: {
|
|
20
|
+
query,
|
|
21
|
+
hits: hits.map((hit) => ({
|
|
22
|
+
source: hit.filePath,
|
|
23
|
+
lineNumber: hit.lineNumber,
|
|
24
|
+
column: hit.column,
|
|
25
|
+
kind: hit.kind,
|
|
26
|
+
name: hit.name,
|
|
27
|
+
})),
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
},
|
|
12
31
|
async tryResolve(request, context) {
|
|
13
32
|
if (!request.query.startsWith("symbols:")) {
|
|
14
33
|
return { kind: "not-handled" };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-image",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./src/index.ts",
|
|
6
6
|
"exports": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"pi-agent-resource": "0.6.
|
|
13
|
+
"pi-agent-resource": "0.6.4"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"@earendil-works/pi-coding-agent": "*"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-pdf",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./src/index.ts",
|
|
6
6
|
"exports": {
|
|
@@ -11,6 +11,6 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"pdfjs-dist": "^6.2.108",
|
|
14
|
-
"pi-agent-resource": "0.6.
|
|
14
|
+
"pi-agent-resource": "0.6.4"
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-read",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"pi-agent-documentation": "0.6.
|
|
28
|
-
"pi-agent-invariant": "0.6.
|
|
29
|
-
"pi-agent-resource": "0.6.
|
|
30
|
-
"pi-agent-text": "0.6.
|
|
31
|
-
"pi-agent-tool-call-interception": "0.6.
|
|
32
|
-
"pi-agent-tool-ui": "0.6.
|
|
27
|
+
"pi-agent-documentation": "0.6.4",
|
|
28
|
+
"pi-agent-invariant": "0.6.4",
|
|
29
|
+
"pi-agent-resource": "0.6.4",
|
|
30
|
+
"pi-agent-text": "0.6.4",
|
|
31
|
+
"pi-agent-tool-call-interception": "0.6.4",
|
|
32
|
+
"pi-agent-tool-ui": "0.6.4"
|
|
33
33
|
},
|
|
34
34
|
"pi": {
|
|
35
35
|
"extensions": [
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
type TextContent,
|
|
8
8
|
} from "pi-agent-resource";
|
|
9
9
|
import { Type } from "typebox";
|
|
10
|
+
import type { AgentToolResult } from "@earendil-works/pi-coding-agent";
|
|
10
11
|
import { Value } from "typebox/value";
|
|
11
12
|
|
|
12
13
|
import type { ToolDefinition, TruncationResult } from "@earendil-works/pi-coding-agent";
|
|
@@ -50,12 +51,19 @@ export interface ReadFailure {
|
|
|
50
51
|
readonly stage?: ReadPipelineStage;
|
|
51
52
|
readonly message: string;
|
|
52
53
|
readonly cause?: unknown;
|
|
54
|
+
/** Ranked exact paths offered as hints, never read automatically. */
|
|
55
|
+
readonly candidates?: readonly { readonly path: string }[];
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
export type ReadResultRenderer = NonNullable<ToolDefinition["renderResult"]>;
|
|
56
59
|
export type ReadCallRenderer = NonNullable<ToolDefinition["renderCall"]>;
|
|
57
60
|
|
|
58
61
|
export interface ResourceResolverRegistration {
|
|
62
|
+
/** Offers recovery hints after this resolver fails to resolve or read a source. */
|
|
63
|
+
readonly recoverFailure?: (
|
|
64
|
+
failure: ReadFailure,
|
|
65
|
+
context: ResourceResolverContext,
|
|
66
|
+
) => Promise<ReadFailure["candidates"]>;
|
|
59
67
|
readonly resolver: ResourceResolver;
|
|
60
68
|
/** Selects a resolver-specific call header before resource resolution. */
|
|
61
69
|
readonly matchesCall?: (source: string) => boolean;
|
|
@@ -187,6 +195,7 @@ export type ReadScriptData =
|
|
|
187
195
|
readonly byteLength: number;
|
|
188
196
|
readonly totalBytes: number;
|
|
189
197
|
readonly bytes: readonly number[];
|
|
198
|
+
readonly truncated?: boolean;
|
|
190
199
|
}
|
|
191
200
|
| {
|
|
192
201
|
readonly kind: "text";
|
|
@@ -195,6 +204,11 @@ export type ReadScriptData =
|
|
|
195
204
|
readonly lines: readonly ReadTextLine[];
|
|
196
205
|
readonly startLine: number;
|
|
197
206
|
readonly endLine: number;
|
|
207
|
+
readonly references?: readonly {
|
|
208
|
+
readonly value: string;
|
|
209
|
+
readonly kind: string;
|
|
210
|
+
readonly state?: string;
|
|
211
|
+
}[];
|
|
198
212
|
readonly totalLines: number;
|
|
199
213
|
}
|
|
200
214
|
| {
|
|
@@ -208,7 +222,8 @@ export type ReadScriptData =
|
|
|
208
222
|
readonly resources: readonly ReadScriptData[];
|
|
209
223
|
};
|
|
210
224
|
export interface ReadToolResult {
|
|
211
|
-
|
|
225
|
+
readonly structuredContent?: AgentToolResult<ReadResultDetails>["structuredContent"];
|
|
226
|
+
/** Canonical adapter data; never reconstructed from rendered text or stored in renderer details. */
|
|
212
227
|
readonly script?: ReadScriptData;
|
|
213
228
|
readonly content: (TextContent | ImageContent)[];
|
|
214
229
|
readonly details: ReadResultDetails;
|
|
@@ -216,7 +231,16 @@ export interface ReadToolResult {
|
|
|
216
231
|
}
|
|
217
232
|
|
|
218
233
|
export type ReadStageOutcome =
|
|
219
|
-
| {
|
|
234
|
+
| {
|
|
235
|
+
readonly kind: "continue";
|
|
236
|
+
readonly context: ReadPipelineContext;
|
|
237
|
+
/**
|
|
238
|
+
* Post-read handlers inspect the same base result concurrently. Return a pure
|
|
239
|
+
* decoration here; transforms apply in registration order, unless a handler
|
|
240
|
+
* returns a final result. Context changes are ignored during post-read.
|
|
241
|
+
*/
|
|
242
|
+
readonly transform?: (result: ReadToolResult) => ReadToolResult;
|
|
243
|
+
}
|
|
220
244
|
| { readonly kind: "return"; readonly result: ReadToolResult };
|
|
221
245
|
|
|
222
246
|
export type ReadPreReadHandler = ReadPipelineHandler;
|
|
@@ -413,3 +437,8 @@ function isRecord(value: unknown): value is Record<string, unknown> {
|
|
|
413
437
|
}
|
|
414
438
|
|
|
415
439
|
export { readParameters } from "#src/api/read-parameters.js";
|
|
440
|
+
export {
|
|
441
|
+
readDataSchema,
|
|
442
|
+
readOutputSchema,
|
|
443
|
+
structuredRead,
|
|
444
|
+
} from "#src/core/tools/read/structured-result.js";
|
|
@@ -107,16 +107,15 @@ export async function readRaw(
|
|
|
107
107
|
byteLength: count,
|
|
108
108
|
totalBytes: stat.size,
|
|
109
109
|
},
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}),
|
|
110
|
+
script: {
|
|
111
|
+
kind: "bytes",
|
|
112
|
+
source,
|
|
113
|
+
byteOffset: start,
|
|
114
|
+
byteLength: count,
|
|
115
|
+
totalBytes: stat.size,
|
|
116
|
+
bytes: Array.from(bytes),
|
|
117
|
+
truncated: count < requestedLength,
|
|
118
|
+
},
|
|
120
119
|
};
|
|
121
120
|
} finally {
|
|
122
121
|
await handle.close();
|
|
@@ -65,9 +65,7 @@ export function projectReadState(
|
|
|
65
65
|
const projected = projectAgentContent(state.content);
|
|
66
66
|
|
|
67
67
|
return {
|
|
68
|
-
|
|
69
|
-
script: { kind: "native" as const, source: state.source, blocks: state.content },
|
|
70
|
-
}),
|
|
68
|
+
script: { kind: "native", source: state.source, blocks: state.content },
|
|
71
69
|
content: projected.content,
|
|
72
70
|
details: {
|
|
73
71
|
...readDetails(state),
|
|
@@ -104,17 +102,16 @@ export function projectReadState(
|
|
|
104
102
|
];
|
|
105
103
|
|
|
106
104
|
return {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}),
|
|
105
|
+
script: {
|
|
106
|
+
kind: "text",
|
|
107
|
+
...(state.text.references === undefined ? {} : { references: state.text.references }),
|
|
108
|
+
source: state.source,
|
|
109
|
+
content: lines.map((line) => line.content + line.lineEnding).join(""),
|
|
110
|
+
lines,
|
|
111
|
+
startLine: lines[0]?.lineNumber ?? 0,
|
|
112
|
+
endLine: lines.at(-1)?.lineNumber ?? 0,
|
|
113
|
+
totalLines,
|
|
114
|
+
},
|
|
118
115
|
content,
|
|
119
116
|
details: {
|
|
120
117
|
...readDetails(state),
|
|
@@ -140,7 +137,23 @@ function renderFinalTextLines(
|
|
|
140
137
|
|
|
141
138
|
export function failureResult(failure: ReadFailure): ReadToolResult {
|
|
142
139
|
return {
|
|
143
|
-
content: [
|
|
140
|
+
content: [
|
|
141
|
+
{
|
|
142
|
+
type: "text",
|
|
143
|
+
text: [
|
|
144
|
+
`${failure.code}: ${failure.message}`,
|
|
145
|
+
...(failure.candidates?.length
|
|
146
|
+
? [
|
|
147
|
+
"",
|
|
148
|
+
"Possible matches:",
|
|
149
|
+
...failure.candidates.map((candidate) => `- ${JSON.stringify(candidate.path)}`),
|
|
150
|
+
"",
|
|
151
|
+
"Retry read with an exact candidate path.",
|
|
152
|
+
]
|
|
153
|
+
: []),
|
|
154
|
+
].join("\n"),
|
|
155
|
+
},
|
|
156
|
+
],
|
|
144
157
|
details: { failure },
|
|
145
158
|
isError: true,
|
|
146
159
|
};
|
|
@@ -0,0 +1,216 @@
|
|
|
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
|
+
lines: Type.Array(line),
|
|
34
|
+
startLine: Type.Integer(),
|
|
35
|
+
endLine: Type.Integer(),
|
|
36
|
+
totalLines: Type.Integer(),
|
|
37
|
+
references: Type.Optional(Type.Array(reference)),
|
|
38
|
+
},
|
|
39
|
+
{ additionalProperties: false },
|
|
40
|
+
);
|
|
41
|
+
const bytes = Type.Object(
|
|
42
|
+
{
|
|
43
|
+
...common,
|
|
44
|
+
kind: Type.Literal("bytes"),
|
|
45
|
+
bytes: Type.Array(Type.Integer({ minimum: 0, maximum: 255 })),
|
|
46
|
+
byteOffset: Type.Integer(),
|
|
47
|
+
byteLength: Type.Integer(),
|
|
48
|
+
totalBytes: Type.Integer(),
|
|
49
|
+
},
|
|
50
|
+
{ additionalProperties: false },
|
|
51
|
+
);
|
|
52
|
+
const block = Type.Union([
|
|
53
|
+
Type.Object({ type: Type.Literal("text"), text: Type.String() }, { additionalProperties: false }),
|
|
54
|
+
Type.Object(
|
|
55
|
+
{ type: Type.Literal("image"), data: Type.String(), mimeType: Type.String() },
|
|
56
|
+
{ additionalProperties: false },
|
|
57
|
+
),
|
|
58
|
+
]);
|
|
59
|
+
const native = Type.Object(
|
|
60
|
+
{ ...common, kind: Type.Literal("native"), blocks: Type.Array(block) },
|
|
61
|
+
{ additionalProperties: false },
|
|
62
|
+
);
|
|
63
|
+
export const readDataSchema = Type.Union([
|
|
64
|
+
Type.Object(
|
|
65
|
+
{
|
|
66
|
+
kind: Type.Literal("recovery"),
|
|
67
|
+
source: Type.String(),
|
|
68
|
+
candidates: Type.Array(Type.Object({ path: Type.String() }, { additionalProperties: false })),
|
|
69
|
+
},
|
|
70
|
+
{ additionalProperties: false },
|
|
71
|
+
),
|
|
72
|
+
text,
|
|
73
|
+
bytes,
|
|
74
|
+
native,
|
|
75
|
+
Type.Object(
|
|
76
|
+
{
|
|
77
|
+
kind: Type.Literal("resources"),
|
|
78
|
+
source: Type.Optional(Type.String()),
|
|
79
|
+
resources: Type.Array(Type.Union([text, bytes, native])),
|
|
80
|
+
truncated: Type.Boolean(),
|
|
81
|
+
fullResult: Type.Optional(Type.String()),
|
|
82
|
+
},
|
|
83
|
+
{ additionalProperties: false },
|
|
84
|
+
),
|
|
85
|
+
]);
|
|
86
|
+
export const readOutputSchema = structuredResultSchema(readDataSchema);
|
|
87
|
+
|
|
88
|
+
function publicLine(value: TextLine) {
|
|
89
|
+
return {
|
|
90
|
+
lineNumber: value.lineNumber,
|
|
91
|
+
content: value.content,
|
|
92
|
+
lineEnding: value.lineEnding,
|
|
93
|
+
...(value.anchors === undefined ? {} : { anchors: [...value.anchors] }),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/** Bound selected data, not source snapshots or human-facing presentation. */
|
|
97
|
+
function publicData(value: ReadScriptData): unknown {
|
|
98
|
+
if (value.kind === "resources") {
|
|
99
|
+
const resources = value.resources.map((resource) => publicData(resource));
|
|
100
|
+
return {
|
|
101
|
+
kind: value.kind,
|
|
102
|
+
...(value.source === undefined ? {} : { source: value.source }),
|
|
103
|
+
resources,
|
|
104
|
+
truncated: resources.some(
|
|
105
|
+
(resource) =>
|
|
106
|
+
typeof resource === "object" &&
|
|
107
|
+
resource !== null &&
|
|
108
|
+
"truncated" in resource &&
|
|
109
|
+
resource.truncated === true,
|
|
110
|
+
),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
if (value.kind === "bytes") {
|
|
114
|
+
const bytes = value.bytes.slice(0, 32768);
|
|
115
|
+
const truncated = value.truncated === true || bytes.length < value.bytes.length;
|
|
116
|
+
return {
|
|
117
|
+
kind: value.kind,
|
|
118
|
+
source: value.source,
|
|
119
|
+
bytes,
|
|
120
|
+
byteOffset: value.byteOffset,
|
|
121
|
+
byteLength: bytes.length,
|
|
122
|
+
totalBytes: value.totalBytes,
|
|
123
|
+
truncated,
|
|
124
|
+
...(value.byteOffset + bytes.length < value.totalBytes
|
|
125
|
+
? { continuation: { path: value.source, offset: value.byteOffset + bytes.length } }
|
|
126
|
+
: {}),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
if (value.kind === "native")
|
|
130
|
+
return {
|
|
131
|
+
kind: value.kind,
|
|
132
|
+
source: value.source,
|
|
133
|
+
truncated: false,
|
|
134
|
+
blocks: value.blocks.map((block) => {
|
|
135
|
+
if (block.type === "text") return { type: block.type, text: block.text };
|
|
136
|
+
if (block.type === "image")
|
|
137
|
+
return { type: block.type, data: block.data, mimeType: block.mimeType };
|
|
138
|
+
throw new TypeError("Custom content requires a structured adapter");
|
|
139
|
+
}),
|
|
140
|
+
};
|
|
141
|
+
const lines = [];
|
|
142
|
+
let size = 0;
|
|
143
|
+
for (const line of value.lines) {
|
|
144
|
+
const projected = publicLine(line);
|
|
145
|
+
size += Buffer.byteLength(JSON.stringify(projected));
|
|
146
|
+
if (lines.length >= 2000 || size > 512 * 1024) break;
|
|
147
|
+
lines.push(projected);
|
|
148
|
+
}
|
|
149
|
+
if (lines.length === 0 && value.lines.length > 0)
|
|
150
|
+
throw new RangeError(
|
|
151
|
+
"Selected line exceeds the structured window; use a raw byte range or a source-specific view",
|
|
152
|
+
);
|
|
153
|
+
const truncated = lines.length < value.lines.length;
|
|
154
|
+
const endLine = lines.at(-1)?.lineNumber ?? value.startLine - 1;
|
|
155
|
+
// Continue against the resolved source with absolute line numbers, not a relative selector.
|
|
156
|
+
return {
|
|
157
|
+
kind: value.kind,
|
|
158
|
+
source: value.source,
|
|
159
|
+
lines,
|
|
160
|
+
startLine: lines[0]?.lineNumber ?? 0,
|
|
161
|
+
endLine: lines.at(-1)?.lineNumber ?? 0,
|
|
162
|
+
totalLines: value.totalLines,
|
|
163
|
+
truncated,
|
|
164
|
+
...(value.references === undefined ? {} : { references: value.references }),
|
|
165
|
+
...(truncated || endLine < value.totalLines
|
|
166
|
+
? { continuation: { path: value.source, offset: endLine + 1 } }
|
|
167
|
+
: {}),
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** Require resolver-owned script data. Never reconstruct it from rendered content or renderer details. */
|
|
172
|
+
export function structuredRead(result: ReadToolResult): ReadToolResult {
|
|
173
|
+
const failure = result.details.failure;
|
|
174
|
+
if (result.isError || failure !== undefined)
|
|
175
|
+
return withStructuredResult(result, readDataSchema, {
|
|
176
|
+
status: "error",
|
|
177
|
+
...(failure?.candidates?.length && failure.source !== undefined
|
|
178
|
+
? {
|
|
179
|
+
data: { kind: "recovery", source: failure.source, candidates: failure.candidates },
|
|
180
|
+
}
|
|
181
|
+
: {}),
|
|
182
|
+
errors: [
|
|
183
|
+
{
|
|
184
|
+
code: failure?.code ?? "READ_FAILED",
|
|
185
|
+
message: failure?.message ?? "Read failed",
|
|
186
|
+
...(failure?.source === undefined ? {} : { source: failure.source }),
|
|
187
|
+
},
|
|
188
|
+
],
|
|
189
|
+
});
|
|
190
|
+
try {
|
|
191
|
+
if (result.script === undefined)
|
|
192
|
+
throw new TypeError("Read handler must return structured script data");
|
|
193
|
+
const data = publicData(result.script);
|
|
194
|
+
return withStructuredResult(result, readDataSchema, {
|
|
195
|
+
status: "success",
|
|
196
|
+
data:
|
|
197
|
+
result.details.temporarySource !== undefined && typeof data === "object" && data !== null
|
|
198
|
+
? { ...data, fullResult: result.details.temporarySource }
|
|
199
|
+
: data,
|
|
200
|
+
errors: [],
|
|
201
|
+
});
|
|
202
|
+
} catch (error) {
|
|
203
|
+
return withStructuredResult(result, readDataSchema, {
|
|
204
|
+
status: "error",
|
|
205
|
+
errors: [
|
|
206
|
+
{
|
|
207
|
+
code:
|
|
208
|
+
error instanceof RangeError
|
|
209
|
+
? "STRUCTURED_RESULT_TOO_LARGE"
|
|
210
|
+
: "STRUCTURED_ADAPTER_REQUIRED",
|
|
211
|
+
message: error instanceof Error ? error.message : String(error),
|
|
212
|
+
},
|
|
213
|
+
],
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|