pi-agent-ide 0.2.1 → 0.3.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 +56 -0
- package/README.md +12 -8
- package/dist/{chunk-XNXQYPVT.js → chunk-4LUW26BX.js} +1 -1
- package/dist/chunk-5MSNYFDE.js +1 -0
- package/dist/chunk-5VSE5X5R.js +2 -0
- package/dist/chunk-6EYWFBNG.js +0 -0
- package/dist/{chunk-ORAPGW7W.js → chunk-72EEL2DW.js} +1 -1
- package/dist/{chunk-T2RPMEM2.js → chunk-7UGNGK7Y.js} +1 -1
- package/dist/{chunk-STUZZM5B.js → chunk-AADJ2KIB.js} +1 -1
- package/dist/{chunk-SMSIT3CE.js → chunk-B5KB2I7J.js} +1 -1
- package/dist/chunk-BHSO2MDK.js +6 -0
- package/dist/chunk-BMOJTJJJ.js +3 -0
- package/dist/{chunk-EEH4WYI7.js → chunk-CEKXBS55.js} +1 -1
- package/dist/chunk-CW53ZTU3.js +2 -0
- package/dist/chunk-EWNWKDMP.js +4 -0
- package/dist/{chunk-VSP2QQPQ.js → chunk-GIRAEVUJ.js} +1 -1
- package/dist/{chunk-MTTKFJV6.js → chunk-GUTQ3PWL.js} +1 -1
- package/dist/chunk-HGPUI7F3.js +1 -0
- package/dist/{chunk-OBWZ5RYN.js → chunk-HKMBQLEK.js} +1 -1
- package/dist/chunk-ITSNK5YG.js +7 -0
- package/dist/chunk-KAB3AYA2.js +1 -0
- package/dist/{chunk-266RH77Z.js → chunk-LRYE2WCN.js} +1 -1
- package/dist/chunk-M5L42DWE.js +7 -0
- package/dist/chunk-M5MJP7Z2.js +1 -0
- package/dist/chunk-NMFQGKPE.js +2 -0
- package/dist/chunk-NTYXZ3EL.js +3 -0
- package/dist/{chunk-PETQCA7G.js → chunk-QDST6VIU.js} +1 -1
- package/dist/chunk-QIJMV2P2.js +2 -0
- package/dist/chunk-RHV5STR3.js +3 -0
- package/dist/chunk-ROXXK6TW.js +0 -0
- package/dist/chunk-S3ZPXWX7.js +2 -0
- package/dist/chunk-SSHZEWWV.js +1 -0
- package/dist/chunk-TPIHQYK2.js +14 -0
- package/dist/chunk-VZJIZXSH.js +14 -0
- package/dist/chunk-YHADTHQM.js +1 -0
- package/dist/{chunk-KZBAJFCV.js → chunk-Z3VC3S2T.js} +1 -1
- package/dist/{chunk-SJYDLHEF.js → chunk-ZM4L5AGN.js} +1 -1
- package/dist/{chunk-E2RESHYR.js → chunk-ZTYWHL2F.js} +1 -1
- package/dist/entry-0.js +1 -1
- package/dist/entry-1.js +1 -1
- package/dist/entry-10.js +1 -1
- package/dist/entry-11.js +1 -1
- package/dist/entry-12.js +1 -1
- package/dist/entry-13.js +1 -1
- package/dist/entry-14.js +1 -1
- package/dist/entry-2.js +1 -1
- package/dist/entry-21.js +2 -1
- package/dist/entry-22.js +1 -1
- package/dist/entry-23.js +1 -1
- package/dist/entry-24.js +1 -1
- package/dist/entry-25.js +1 -1
- package/dist/entry-26.js +12 -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 +4 -1
- package/dist/entry-32.js +9 -1
- package/dist/entry-33.js +1 -1
- package/dist/entry-35.js +1 -1
- package/dist/entry-36.js +1 -1
- package/dist/entry-37.js +1 -1
- package/dist/entry-38.js +1 -1
- package/dist/entry-39.js +1 -1
- package/dist/entry-4.js +1 -1
- package/dist/entry-40.js +18 -1
- package/dist/entry-41.js +1 -1
- package/dist/entry-42.js +1 -1
- package/dist/entry-43.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +7 -1
- package/dist/entry-46.js +11 -1
- package/dist/entry-47.js +1 -1
- package/dist/entry-48.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +1 -1
- package/dist/entry-51.js +1 -1
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-54.js +1 -0
- package/dist/entry-55.js +0 -1
- package/dist/entry-56.js +1 -0
- package/dist/entry-57.js +0 -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-62.js +1 -1
- package/dist/entry-63.js +1 -0
- package/dist/entry-64.js +0 -1
- package/dist/entry-65.js +1 -0
- package/dist/entry-66.js +0 -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 +123 -1
- package/dist/entry-71.js +30 -1
- package/dist/entry-72.js +2 -1
- package/dist/entry-73.js +1 -1
- package/dist/entry-74.js +1 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-76.js +3 -1
- package/dist/entry-77.js +1 -1
- package/dist/entry-78.js +1 -1
- package/dist/entry-79.js +1 -1
- package/dist/pi-agent-ide.js +3 -13
- package/docs/configuration.md +57 -11
- package/docs/extensions.md +4 -2
- package/docs/tools.md +7 -1
- package/node_modules/pi-agent-doctor/package.json +1 -1
- package/node_modules/pi-agent-filesystem/index.ts +2 -2
- package/node_modules/pi-agent-filesystem/package.json +6 -6
- package/node_modules/pi-agent-filesystem-image/package.json +3 -3
- 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 +9 -9
- package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +89 -19
- package/node_modules/pi-agent-ide-ast/src/extension.ts +11 -15
- package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +83 -0
- package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +8 -1
- package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +83 -5
- package/node_modules/pi-agent-ide-changes/index.ts +22 -10
- package/node_modules/pi-agent-ide-changes/package.json +6 -6
- package/node_modules/pi-agent-ide-changes/src/last-text-transaction-store.ts +10 -0
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +5 -9
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +1 -5
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-formatter/src/formatter.ts +36 -13
- package/node_modules/pi-agent-ide-formatter/src/registry.ts +9 -1
- package/node_modules/pi-agent-ide-languages/package.json +2 -2
- package/node_modules/pi-agent-ide-lint/index.ts +49 -17
- package/node_modules/pi-agent-ide-lint/package.json +7 -7
- package/node_modules/pi-agent-ide-lint/src/registry.ts +9 -1
- package/node_modules/pi-agent-ide-lsp/index.ts +127 -20
- package/node_modules/pi-agent-ide-lsp/package.json +9 -8
- package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +61 -0
- package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +25 -7
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +12 -1
- package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +40 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +21 -32
- package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +15 -2
- package/node_modules/pi-agent-ide-lsp/src/lsp/rename.ts +1 -1
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +32 -5
- package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +138 -0
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +9 -2
- package/node_modules/pi-agent-image/package.json +2 -2
- package/node_modules/pi-agent-image/src/image-converter.ts +1 -1
- 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-pdf/src/pdf-converter.ts +1 -1
- package/node_modules/pi-agent-read/package.json +6 -6
- package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +1 -1
- package/node_modules/pi-agent-read/src/api/read-parameters.ts +29 -0
- package/node_modules/pi-agent-read/src/api/rendering.ts +3 -0
- package/node_modules/pi-agent-read/src/api/tools/read.ts +73 -1
- package/node_modules/pi-agent-read/src/core/read-core.ts +32 -28
- package/node_modules/pi-agent-read/src/core/tools/read/native-resource-renderer.ts +74 -0
- package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +1 -1
- package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +113 -0
- package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +87 -19
- package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +15 -0
- package/node_modules/pi-agent-read/src/core/tools/read/temp-resource-store.ts +35 -126
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +87 -53
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/content-conversion/content-description.ts +1 -8
- package/node_modules/pi-agent-resource/src/resolver.ts +2 -0
- package/node_modules/pi-agent-search/package.json +3 -3
- package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +1 -1
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +25 -0
- package/node_modules/pi-agent-search/src/api/search.ts +55 -1
- package/node_modules/pi-agent-search/src/core/extension.ts +8 -27
- package/node_modules/pi-agent-search/src/core/search-core.ts +38 -3
- package/node_modules/pi-agent-search-text/index.ts +82 -33
- package/node_modules/pi-agent-search-text/package.json +6 -6
- package/node_modules/pi-agent-search-text/src/file-search.ts +9 -1
- package/node_modules/pi-agent-search-text/src/resolvers.ts +1 -1
- package/node_modules/pi-agent-search-text/src/search-recipe.ts +2 -0
- package/node_modules/pi-agent-search-text/src/search-session.ts +112 -24
- package/node_modules/pi-agent-text/package.json +2 -2
- package/node_modules/pi-agent-text/src/text-converter.ts +1 -1
- package/node_modules/pi-agent-text/src/text-document.ts +5 -0
- package/node_modules/pi-agent-text/src/text-target.ts +4 -0
- 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-line-hash/index.ts +2 -6
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +1 -0
- package/node_modules/pi-agent-text-editor/index.ts +1 -3
- package/node_modules/pi-agent-text-editor/package.json +34 -24
- package/node_modules/pi-agent-text-editor/runtime/entry-69.js +0 -1
- package/node_modules/pi-agent-text-editor/src/api/apply-renderer.ts +3 -0
- package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +15 -0
- package/node_modules/pi-agent-text-editor/src/api/last-resolved-resource.ts +5 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +3 -0
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +15 -1
- package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +74 -1
- package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +237 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/final-mutations.ts +50 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/format-source.ts +11 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +208 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +39 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +216 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +45 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/queue.ts +25 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +324 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/results.ts +133 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +112 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +132 -0
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +4 -12
- package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +205 -0
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +13 -9
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +76 -0
- package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +153 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/diff.ts +5 -2
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +28 -2
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +43 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +81 -0
- package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +73 -0
- package/node_modules/pi-agent-text-editor/src/core/text-anchor-registry.ts +5 -2
- package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +10 -2
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +40 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +178 -58
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +313 -21
- package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +45 -43
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +18 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +7 -4
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +13 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +18 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -1
- package/node_modules/pi-agent-text-editor-renderer/index.ts +93 -2
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +7 -0
- package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +1 -1
- package/node_modules/pi-agent-text-editor-renderer/src/diff-viewport.ts +11 -2
- package/node_modules/pi-agent-text-editor-renderer/src/frozen-viewport.ts +140 -52
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +69 -4
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-result.ts +53 -1
- package/node_modules/pi-agent-text-editor-renderer/src/persisted-result.ts +8 -2
- package/node_modules/pi-agent-text-editor-renderer/src/render-resource.ts +10 -0
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +24 -13
- package/node_modules/pi-agent-text-editor-renderer/src/status-summary.ts +33 -0
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-73.js +1 -0
- package/node_modules/pi-agent-tool-call-interception/src/index.ts +3 -0
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-web/index.ts +1 -6
- package/node_modules/pi-agent-web/package.json +7 -7
- package/node_modules/pi-agent-web/runtime/entry-75.js +2 -0
- package/node_modules/pi-agent-web/src/browser-loader.ts +1 -0
- package/node_modules/pi-agent-web-html/package.json +3 -3
- package/node_modules/pi-agent-web-html/src/html-converter.ts +1 -1
- package/node_modules/pi-agent-web-image/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/package.json +38 -38
- package/src/api/plugin-protocol.ts +12 -2
- package/src/api/text-editor.ts +7 -0
- package/src/api/tool-config.ts +77 -2
- package/src/code-view/diagnostic-view.ts +22 -3
- package/src/composite/builtin-extensions.ts +138 -67
- package/src/composite/extensions-config.ts +59 -0
- package/src/composite/feature-flags.ts +32 -0
- package/src/composite/module-labels.ts +55 -0
- package/src/composite/module-settings-store.ts +44 -0
- package/src/composite/module-settings.ts +132 -0
- package/src/composite/selection.ts +4 -4
- package/src/composite/settings-panel.ts +71 -0
- package/src/core/diagnostic-delivery.ts +29 -0
- package/src/core/diagnostic-entry.ts +142 -0
- package/src/core/diagnostic-store.ts +96 -23
- package/src/core/extension.ts +45 -22
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +2 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +6 -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-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +1 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -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-html/runtime/entry-76.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/src/html-converter.ts +1 -1
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-75.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/browser-loader.ts +1 -0
- package/src/extensions/pi-agent-read/package.json +6 -6
- package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +29 -0
- package/src/extensions/pi-agent-read/src/api/rendering.ts +3 -0
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +73 -1
- package/src/extensions/pi-agent-read/src/core/read-core.ts +32 -28
- package/src/extensions/pi-agent-read/src/core/tools/read/native-resource-renderer.ts +74 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +1 -1
- package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +113 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +87 -19
- package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +15 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/temp-resource-store.ts +35 -126
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +87 -53
- package/src/extensions/pi-agent-search/package.json +3 -3
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +82 -33
- 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/file-search.ts +9 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +1 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +2 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +112 -24
- package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +1 -1
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +25 -0
- package/src/extensions/pi-agent-search/src/api/search.ts +55 -1
- package/src/extensions/pi-agent-search/src/core/extension.ts +8 -27
- package/src/extensions/pi-agent-search/src/core/search-core.ts +38 -3
- package/src/extensions/pi-agent-text-editor/index.ts +1 -3
- package/src/extensions/pi-agent-text-editor/package.json +34 -24
- 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-line-hash/index.ts +2 -6
- 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-anchor-line-hash/src/read-handler.ts +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +93 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +7 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +1 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-viewport.ts +11 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/frozen-viewport.ts +140 -52
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +69 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-result.ts +53 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/persisted-result.ts +8 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/render-resource.ts +10 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +24 -13
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/status-summary.ts +33 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/runtime/entry-69.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-70.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/apply-renderer.ts +3 -0
- package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +15 -0
- package/src/extensions/pi-agent-text-editor/src/api/last-resolved-resource.ts +5 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +3 -0
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +15 -1
- package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +74 -1
- package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +237 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/final-mutations.ts +50 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/format-source.ts +11 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +208 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +39 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +216 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +45 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/queue.ts +25 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +324 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/results.ts +133 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +112 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +132 -0
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +4 -12
- package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +205 -0
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +13 -9
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +76 -0
- package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +153 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/diff.ts +5 -2
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +28 -2
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +43 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +81 -0
- package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +73 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-anchor-registry.ts +5 -2
- package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +10 -2
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +40 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +178 -58
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +313 -21
- package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +45 -43
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +18 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +7 -4
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +13 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +18 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -1
- package/src/pi-agent-ide.ts +45 -0
- package/src/plugins/pi-agent-ide-ast/package.json +9 -9
- package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +89 -19
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +11 -15
- package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +83 -0
- package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +8 -1
- package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +83 -5
- package/src/plugins/pi-agent-ide-changes/index.ts +22 -10
- package/src/plugins/pi-agent-ide-changes/package.json +6 -6
- package/src/plugins/pi-agent-ide-changes/src/last-text-transaction-store.ts +10 -0
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +5 -9
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +1 -5
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +62 -26
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +36 -13
- package/src/plugins/pi-agent-ide-formatter/src/registry.ts +9 -1
- package/src/plugins/pi-agent-ide-languages/package.json +2 -2
- package/src/plugins/pi-agent-ide-lint/index.ts +49 -17
- package/src/plugins/pi-agent-ide-lint/package.json +7 -7
- package/src/plugins/pi-agent-ide-lint/src/registry.ts +9 -1
- package/src/plugins/pi-agent-ide-lsp/index.ts +127 -20
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -8
- package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +61 -0
- package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +25 -7
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +12 -1
- package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +40 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +21 -32
- package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +15 -2
- package/src/plugins/pi-agent-ide-lsp/src/lsp/rename.ts +1 -1
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +32 -5
- package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +138 -0
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +9 -2
- package/src/post-edit/gate.ts +57 -15
- package/src/toolchain/types.ts +2 -0
- package/dist/chunk-2SKAED2I.js +0 -2
- package/dist/chunk-2XYXV5HS.js +0 -4
- package/dist/chunk-2ZMYT6ZC.js +0 -1
- package/dist/chunk-34ZQTTU2.js +0 -2
- package/dist/chunk-4SQQKEVD.js +0 -16
- package/dist/chunk-5BWUVAR4.js +0 -1
- package/dist/chunk-6DN7NO7L.js +0 -1
- package/dist/chunk-6SMFVLTY.js +0 -1
- package/dist/chunk-6XQQBKPE.js +0 -58
- package/dist/chunk-BYWAG6X3.js +0 -6
- package/dist/chunk-EW2KVKCN.js +0 -2
- package/dist/chunk-F6SESI3P.js +0 -4
- package/dist/chunk-GTK5AREE.js +0 -2
- package/dist/chunk-HOBTFFQR.js +0 -1
- package/dist/chunk-IMVCVPMP.js +0 -3
- package/dist/chunk-IOCABSRL.js +0 -1
- package/dist/chunk-JASLOB2X.js +0 -1
- package/dist/chunk-KH5KPBCR.js +0 -10
- package/dist/chunk-KNMWCDDK.js +0 -7
- package/dist/chunk-KYVOMBO5.js +0 -1
- package/dist/chunk-L4FA6OD4.js +0 -1
- package/dist/chunk-LFV6G5Z3.js +0 -1
- package/dist/chunk-LGN7EJYR.js +0 -13
- package/dist/chunk-MB6VVVAF.js +0 -2
- package/dist/chunk-MTQSGWZJ.js +0 -1
- package/dist/chunk-NI2NK4JU.js +0 -1
- package/dist/chunk-NXHPO7ER.js +0 -6
- package/dist/chunk-OFHVDY4Q.js +0 -2
- package/dist/chunk-OIL6BB2S.js +0 -33
- package/dist/chunk-ONWUJXUR.js +0 -1
- package/dist/chunk-PODWLGNO.js +0 -6
- package/dist/chunk-QZANC2IG.js +0 -1
- package/dist/chunk-SSZB66C3.js +0 -3
- package/dist/chunk-TG6H6EOI.js +0 -1
- package/dist/chunk-UTTW55S2.js +0 -1
- package/dist/chunk-VEJGSURY.js +0 -8
- package/dist/chunk-W3XYKJ5H.js +0 -1
- package/dist/chunk-XGUAL3CA.js +0 -1
- package/dist/chunk-YPHXLAQF.js +0 -1
- package/dist/chunk-ZIHEF6K3.js +0 -3
- package/dist/entry-80.js +0 -1
- package/node_modules/pi-agent-read/src/core/tools/read/views.ts +0 -29
- package/node_modules/pi-agent-text-editor/src/core/tool-description.ts +0 -14
- package/node_modules/pi-agent-text-editor-argument-order/index.ts +0 -26
- package/node_modules/pi-agent-text-editor-argument-order/package.json +0 -16
- package/node_modules/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +0 -100
- package/node_modules/pi-agent-text-editor-overwrite/index.ts +0 -365
- package/node_modules/pi-agent-text-editor-overwrite/package.json +0 -17
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +0 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-75.js +0 -1
- package/node_modules/pi-agent-web-text/runtime/entry-80.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-80.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-76.js +0 -2
- package/src/extensions/pi-agent-read/src/core/tools/read/views.ts +0 -29
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/index.ts +0 -26
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/package.json +0 -16
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/runtime/entry-70.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +0 -100
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/index.ts +0 -365
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +0 -17
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +0 -2
- package/src/extensions/pi-agent-text-editor/src/core/tool-description.ts +0 -14
- /package/dist/{chunk-3H2EU7VQ.js → chunk-4U2GUKNJ.js} +0 -0
- /package/node_modules/{pi-agent-text-editor-argument-order → pi-agent-text-editor}/runtime/entry-70.js +0 -0
- /package/node_modules/{pi-agent-text-editor-overwrite → pi-agent-text-editor-renderer}/runtime/entry-71.js +0 -0
- /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-72.js +0 -0
- /package/node_modules/{pi-agent-tool-call-interception → pi-agent-tool-ui}/runtime/entry-74.js +0 -0
- /package/node_modules/{pi-agent-web → pi-agent-web-html}/runtime/entry-76.js +0 -0
- /package/node_modules/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-77.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-78.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-79.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-77.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-78.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-79.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-overwrite → pi-agent-text-editor-renderer}/runtime/entry-71.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-72.js +0 -0
|
@@ -128,6 +128,8 @@ export interface ReadNativeState extends ReadStateBase {
|
|
|
128
128
|
export type ReadState = ReadTextState | ReadNativeState;
|
|
129
129
|
|
|
130
130
|
export interface ReadPipelineContext {
|
|
131
|
+
/** Data execution keeps full requested content; presentation handlers must not compact it. */
|
|
132
|
+
readonly audience?: "agent" | "script";
|
|
131
133
|
readonly request: ReadRequest;
|
|
132
134
|
readonly resolverContext: ResourceResolverContext;
|
|
133
135
|
readonly state?: ReadState;
|
|
@@ -147,6 +149,17 @@ export interface UnsupportedContentDetails {
|
|
|
147
149
|
}
|
|
148
150
|
|
|
149
151
|
export interface ReadResultDetails extends UnsupportedContentDetails {
|
|
152
|
+
/** Explicit diagnostic checks; completed empty reports need no content panel. */
|
|
153
|
+
readonly diagnosticCheck?: {
|
|
154
|
+
readonly complete: boolean;
|
|
155
|
+
readonly count: number;
|
|
156
|
+
readonly sources: readonly string[];
|
|
157
|
+
};
|
|
158
|
+
readonly byteOffset?: number;
|
|
159
|
+
readonly byteLength?: number;
|
|
160
|
+
readonly totalBytes?: number;
|
|
161
|
+
/** Every selected target result for script reads spanning multiple resources or ranges. */
|
|
162
|
+
readonly resources?: readonly ReadToolResult[];
|
|
150
163
|
readonly source?: string;
|
|
151
164
|
readonly resolvedBy?: string;
|
|
152
165
|
readonly startLine?: number;
|
|
@@ -160,7 +173,38 @@ export interface ReadResultDetails extends UnsupportedContentDetails {
|
|
|
160
173
|
readonly failure?: ReadFailure;
|
|
161
174
|
}
|
|
162
175
|
|
|
176
|
+
/** Plain selected source data for computation, separate from formatted tool content. */
|
|
177
|
+
export type ReadScriptData =
|
|
178
|
+
| {
|
|
179
|
+
readonly kind: "bytes";
|
|
180
|
+
readonly source: string;
|
|
181
|
+
readonly byteOffset: number;
|
|
182
|
+
readonly byteLength: number;
|
|
183
|
+
readonly totalBytes: number;
|
|
184
|
+
readonly bytes: readonly number[];
|
|
185
|
+
}
|
|
186
|
+
| {
|
|
187
|
+
readonly kind: "text";
|
|
188
|
+
readonly source: string;
|
|
189
|
+
readonly content: string;
|
|
190
|
+
readonly lines: readonly ReadTextLine[];
|
|
191
|
+
readonly startLine: number;
|
|
192
|
+
readonly endLine: number;
|
|
193
|
+
readonly totalLines: number;
|
|
194
|
+
}
|
|
195
|
+
| {
|
|
196
|
+
readonly kind: "native";
|
|
197
|
+
readonly source: string;
|
|
198
|
+
readonly blocks: readonly AgentContent[number][];
|
|
199
|
+
}
|
|
200
|
+
| {
|
|
201
|
+
readonly kind: "resources";
|
|
202
|
+
readonly source?: string;
|
|
203
|
+
readonly resources: readonly ReadScriptData[];
|
|
204
|
+
};
|
|
163
205
|
export interface ReadToolResult {
|
|
206
|
+
/** Present only for script execution; never reconstructed from rendered text. */
|
|
207
|
+
readonly script?: ReadScriptData;
|
|
164
208
|
readonly content: (TextContent | ImageContent)[];
|
|
165
209
|
readonly details: ReadResultDetails;
|
|
166
210
|
readonly isError?: boolean;
|
|
@@ -192,8 +236,34 @@ export type ReadHandlerRegistration =
|
|
|
192
236
|
|
|
193
237
|
export type PromptDescriptionSource = string | (() => string | undefined);
|
|
194
238
|
|
|
239
|
+
/** Remaining text budget for a format-aware view of already-read data. */
|
|
240
|
+
export interface ReadOutputBudget {
|
|
241
|
+
readonly maxBytes: number;
|
|
242
|
+
readonly maxLines: number;
|
|
243
|
+
}
|
|
244
|
+
/** Reduces presentation without reading a newer snapshot or changing script data. */
|
|
245
|
+
export type ReadOutputReducer = (
|
|
246
|
+
result: ReadToolResult,
|
|
247
|
+
context: ResourceResolverContext,
|
|
248
|
+
budget: ReadOutputBudget,
|
|
249
|
+
) => Promise<ReadToolResult | undefined>;
|
|
195
250
|
export interface ReadToolPluginApi {
|
|
196
|
-
read
|
|
251
|
+
/** Registers a format-aware reducer shared by read and composed output. */
|
|
252
|
+
addOutputReducer(reducer: ReadOutputReducer): void;
|
|
253
|
+
/** Attempts a compact presentation from the recorded snapshot without rereading its source. */
|
|
254
|
+
reduceOutput(
|
|
255
|
+
result: ReadToolResult,
|
|
256
|
+
context: ResourceResolverContext,
|
|
257
|
+
budget: ReadOutputBudget,
|
|
258
|
+
): Promise<ReadToolResult | undefined>;
|
|
259
|
+
/** Stores complete output for follow-up read access until this runtime is disposed. */
|
|
260
|
+
saveTemporary(text: string): Promise<string>;
|
|
261
|
+
/** Executes the shared pipeline; script results are not clipped to the agent output budget. */
|
|
262
|
+
read(
|
|
263
|
+
request: ReadRequest,
|
|
264
|
+
context: ResourceResolverContext,
|
|
265
|
+
audience?: "agent" | "script",
|
|
266
|
+
): Promise<ReadToolResult>;
|
|
197
267
|
addResolver(registration: ResourceResolverRegistration): void;
|
|
198
268
|
addTargetResolver(registration: TextTargetResolverRegistration): void;
|
|
199
269
|
addHandler(registration: ReadHandlerRegistration): void;
|
|
@@ -309,3 +379,5 @@ export function isReadFragmentResolution(value: unknown): value is ReadFragmentR
|
|
|
309
379
|
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
310
380
|
return typeof value === "object" && value !== null;
|
|
311
381
|
}
|
|
382
|
+
|
|
383
|
+
export { readParameters } from "#src/api/read-parameters.js";
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
type FragmentResolverRegistration,
|
|
14
14
|
type PromptDescriptionSource,
|
|
15
15
|
type ReadHandlerRegistration,
|
|
16
|
+
type ReadOutputReducer,
|
|
16
17
|
type ReadViewRegistration,
|
|
17
18
|
type ResourceResolverRegistration,
|
|
18
19
|
type TextTargetResolverRegistration,
|
|
@@ -48,9 +49,13 @@ export interface ReadCore {
|
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
export function createReadCore(): ReadCore {
|
|
52
|
+
const outputReducers: ReadOutputReducer[] = [];
|
|
51
53
|
const pendingPlugins = new Set<Promise<void>>();
|
|
52
54
|
const plugins = new Map<string, RegisteredPlugin>();
|
|
53
|
-
const read = createReadTool(
|
|
55
|
+
const read = createReadTool(
|
|
56
|
+
() => renderPromptGuidelines(plugins),
|
|
57
|
+
() => renderPluginPromptGuideline(plugins),
|
|
58
|
+
);
|
|
54
59
|
let registrationQueue = Promise.resolve();
|
|
55
60
|
|
|
56
61
|
return {
|
|
@@ -81,6 +86,7 @@ export function createReadCore(): ReadCore {
|
|
|
81
86
|
read,
|
|
82
87
|
promptGuidelines,
|
|
83
88
|
promptContributions,
|
|
89
|
+
outputReducers,
|
|
84
90
|
);
|
|
85
91
|
const ready = registrationQueue.then(async () => {
|
|
86
92
|
try {
|
|
@@ -154,7 +160,9 @@ function createPluginContributionController(
|
|
|
154
160
|
read: ReadTool,
|
|
155
161
|
promptGuidelines: PromptDescriptionSource[],
|
|
156
162
|
promptContributions: PromptDescriptionSource[],
|
|
163
|
+
outputReducers: ReadOutputReducer[],
|
|
157
164
|
): PluginContributionController {
|
|
165
|
+
const setupOutputReducers: ReadOutputReducer[] = [];
|
|
158
166
|
const setupPromptContributions: PromptDescriptionSource[] = [];
|
|
159
167
|
|
|
160
168
|
const setupPromptGuidelines: PromptDescriptionSource[] = [];
|
|
@@ -170,9 +178,27 @@ function createPluginContributionController(
|
|
|
170
178
|
}
|
|
171
179
|
};
|
|
172
180
|
const api: ReadPluginApi = {
|
|
173
|
-
|
|
181
|
+
addOutputReducer(reducer) {
|
|
174
182
|
assertAvailable();
|
|
175
|
-
|
|
183
|
+
if (typeof reducer !== "function") throw new TypeError("Expected an output reducer");
|
|
184
|
+
(state === "setup" ? setupOutputReducers : outputReducers).push(reducer);
|
|
185
|
+
},
|
|
186
|
+
async reduceOutput(result, context, budget) {
|
|
187
|
+
assertAvailable();
|
|
188
|
+
for (const reducer of outputReducers) {
|
|
189
|
+
context.signal?.throwIfAborted();
|
|
190
|
+
const reduced = await reducer(result, context, budget);
|
|
191
|
+
if (reduced !== undefined) return reduced;
|
|
192
|
+
}
|
|
193
|
+
return undefined;
|
|
194
|
+
},
|
|
195
|
+
saveTemporary(text) {
|
|
196
|
+
assertAvailable();
|
|
197
|
+
return read.saveTemporary(text);
|
|
198
|
+
},
|
|
199
|
+
read(request, context, audience) {
|
|
200
|
+
assertAvailable();
|
|
201
|
+
return read.execute(request, context, audience);
|
|
176
202
|
},
|
|
177
203
|
addResolver(registration): void {
|
|
178
204
|
assertAvailable();
|
|
@@ -286,6 +312,7 @@ function createPluginContributionController(
|
|
|
286
312
|
fragments: setupFragmentResolvers,
|
|
287
313
|
});
|
|
288
314
|
promptContributions.push(...setupPromptContributions);
|
|
315
|
+
outputReducers.push(...setupOutputReducers);
|
|
289
316
|
|
|
290
317
|
promptGuidelines.push(...setupPromptGuidelines);
|
|
291
318
|
state = "active";
|
|
@@ -331,15 +358,13 @@ function renderPluginPromptGuideline(
|
|
|
331
358
|
const description = renderDescriptionSource(source);
|
|
332
359
|
|
|
333
360
|
if (description !== undefined) {
|
|
334
|
-
entries.push(
|
|
361
|
+
entries.push(description);
|
|
335
362
|
}
|
|
336
363
|
}
|
|
337
364
|
|
|
338
365
|
return entries.length === 0
|
|
339
366
|
? undefined
|
|
340
|
-
:
|
|
341
|
-
["Read supports these installed protocols:", ...entries].join("\n"),
|
|
342
|
-
);
|
|
367
|
+
: [...new Set(entries.flatMap((entry) => entry.split("\n")))].join("\n");
|
|
343
368
|
}
|
|
344
369
|
|
|
345
370
|
function normalizeDescriptionSource(value: unknown): PromptDescriptionSource {
|
|
@@ -390,24 +415,3 @@ function normalizeDescription(value: unknown): string {
|
|
|
390
415
|
|
|
391
416
|
return description;
|
|
392
417
|
}
|
|
393
|
-
|
|
394
|
-
function renderPromptEntry(pluginId: string, description: string): string {
|
|
395
|
-
const [firstLine, ...continuationLines] = description.split("\n");
|
|
396
|
-
|
|
397
|
-
return [
|
|
398
|
-
`- \`${escapeInlineCode(pluginId)}\` — ${firstLine ?? ""}`,
|
|
399
|
-
...continuationLines.map((line) => ` ${line}`),
|
|
400
|
-
].join("\n");
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
function indentGuidelineContinuation(guideline: string): string {
|
|
404
|
-
const [firstLine, ...continuationLines] = guideline.split("\n");
|
|
405
|
-
return [
|
|
406
|
-
firstLine ?? "",
|
|
407
|
-
...continuationLines.map((line) => (line.length === 0 ? line : ` ${line}`)),
|
|
408
|
-
].join("\n");
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
function escapeInlineCode(value: string): string {
|
|
412
|
-
return value.replaceAll("`", "\\`");
|
|
413
|
-
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import {
|
|
4
|
+
createReadToolDefinition,
|
|
5
|
+
getReadmePath,
|
|
6
|
+
type ToolDefinition,
|
|
7
|
+
} from "@earendil-works/pi-coding-agent";
|
|
8
|
+
import { Text } from "@earendil-works/pi-tui";
|
|
9
|
+
|
|
10
|
+
/** The native implementation owns labels, colors, key hints, and expanded text rendering. */
|
|
11
|
+
export const nativeReadPresentation = createReadToolDefinition(process.cwd());
|
|
12
|
+
|
|
13
|
+
/** Shared call/result context from Pi's public tool contract. */
|
|
14
|
+
export type ReadRenderContext = Parameters<NonNullable<ToolDefinition["renderCall"]>>[2];
|
|
15
|
+
type NativeArguments = Parameters<NonNullable<typeof nativeReadPresentation.renderCall>>[0];
|
|
16
|
+
|
|
17
|
+
const contextFiles = new Set([
|
|
18
|
+
"AGENTS.override.md",
|
|
19
|
+
"AGENTS.md",
|
|
20
|
+
"AGENTS.MD",
|
|
21
|
+
"CLAUDE.md",
|
|
22
|
+
"CLAUDE.MD",
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
/** Selects native special-file presentation only for native-compatible local read arguments. */
|
|
26
|
+
export function nativeReadArguments(
|
|
27
|
+
input: unknown,
|
|
28
|
+
cwd = process.cwd(),
|
|
29
|
+
): NativeArguments | undefined {
|
|
30
|
+
if (typeof input !== "object" || input === null) return undefined;
|
|
31
|
+
const args = input as { path?: unknown; offset?: unknown; limit?: unknown; views?: unknown };
|
|
32
|
+
const source = args.path;
|
|
33
|
+
if (typeof source !== "string" || source.length === 0 || source.includes("#")) return undefined;
|
|
34
|
+
if (!path.isAbsolute(source) && /^[a-z][a-z\d+.-]*:/iu.test(source)) return undefined;
|
|
35
|
+
if (args.views !== undefined && (!Array.isArray(args.views) || args.views.length > 0))
|
|
36
|
+
return undefined;
|
|
37
|
+
if (
|
|
38
|
+
args.offset !== undefined &&
|
|
39
|
+
(typeof args.offset !== "number" || !Number.isInteger(args.offset) || args.offset < 1)
|
|
40
|
+
)
|
|
41
|
+
return undefined;
|
|
42
|
+
if (
|
|
43
|
+
args.limit !== undefined &&
|
|
44
|
+
(typeof args.limit !== "number" || !Number.isInteger(args.limit) || args.limit < 1)
|
|
45
|
+
)
|
|
46
|
+
return undefined;
|
|
47
|
+
const expanded = source.startsWith("~/") ? path.join(homedir(), source.slice(2)) : source;
|
|
48
|
+
const absolute = path.resolve(cwd, expanded);
|
|
49
|
+
const name = path.basename(absolute);
|
|
50
|
+
const relative = path.relative(path.dirname(getReadmePath()), absolute);
|
|
51
|
+
const docs =
|
|
52
|
+
!path.isAbsolute(relative) &&
|
|
53
|
+
(relative === "README.md" ||
|
|
54
|
+
relative.startsWith(`docs${path.sep}`) ||
|
|
55
|
+
relative.startsWith(`examples${path.sep}`));
|
|
56
|
+
if (name !== "SKILL.md" && !contextFiles.has(name) && !docs) return undefined;
|
|
57
|
+
return {
|
|
58
|
+
path: source,
|
|
59
|
+
...(args.offset === undefined ? {} : { offset: args.offset }),
|
|
60
|
+
...(args.limit === undefined ? {} : { limit: args.limit }),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Native renderers reuse Text only; a previous IDE card is a different component type. */
|
|
65
|
+
export function nativeReadContext(
|
|
66
|
+
context: ReadRenderContext,
|
|
67
|
+
args: NativeArguments,
|
|
68
|
+
): Parameters<NonNullable<typeof nativeReadPresentation.renderCall>>[2] {
|
|
69
|
+
return {
|
|
70
|
+
...context,
|
|
71
|
+
args,
|
|
72
|
+
lastComponent: context.lastComponent instanceof Text ? context.lastComponent : undefined,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -69,7 +69,7 @@ export async function limitReadOutput(
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
function appendTemporarySource(notice: string, source: string): string {
|
|
72
|
-
return `${notice.slice(0, -1)} Full output: ${source}.
|
|
72
|
+
return `${notice.slice(0, -1)} Full output: ${source}. Available until this runtime is disposed.]`;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
function oversizedFirstLineNotice(
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { open, stat } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
|
|
5
|
+
import type { ReadRequest, ReadToolResult } from "#src/api/tools/read.js";
|
|
6
|
+
import { failureResult } from "#src/core/tools/read/read-result.js";
|
|
7
|
+
import {
|
|
8
|
+
READ_OUTPUT_MAX_BYTES,
|
|
9
|
+
READ_OUTPUT_MAX_LINES,
|
|
10
|
+
} from "#src/core/tools/read/output-truncation.js";
|
|
11
|
+
|
|
12
|
+
/** Read original local file bytes, without text conversion or source annotations. */
|
|
13
|
+
export async function readRaw(
|
|
14
|
+
request: ReadRequest,
|
|
15
|
+
context: { cwd: string; signal?: AbortSignal },
|
|
16
|
+
audience: "agent" | "script",
|
|
17
|
+
): Promise<ReadToolResult> {
|
|
18
|
+
const requested = request.path ?? "";
|
|
19
|
+
try {
|
|
20
|
+
if ((request.views?.length ?? 0) > 0)
|
|
21
|
+
throw new Error("Raw byte reads do not accept text views");
|
|
22
|
+
const offset = request.offset ?? 0;
|
|
23
|
+
const limit = request.limit;
|
|
24
|
+
if (
|
|
25
|
+
!Number.isSafeInteger(offset) ||
|
|
26
|
+
(limit !== undefined && (!Number.isSafeInteger(limit) || limit < 0))
|
|
27
|
+
)
|
|
28
|
+
throw new Error("Use an integer byte offset and a non-negative integer byte limit");
|
|
29
|
+
const input = requested.slice(4);
|
|
30
|
+
if (input.length === 0) throw new Error("Supply a local file after raw:");
|
|
31
|
+
const file = input.startsWith("file://")
|
|
32
|
+
? fileURLToPath(input)
|
|
33
|
+
: path.resolve(context.cwd, input);
|
|
34
|
+
context.signal?.throwIfAborted();
|
|
35
|
+
if (!(await stat(file)).isFile()) throw new Error("Raw reads require a regular file");
|
|
36
|
+
const handle = await open(file, "r");
|
|
37
|
+
try {
|
|
38
|
+
const stat = await handle.stat();
|
|
39
|
+
if (!stat.isFile()) throw new Error("Raw reads require a regular file");
|
|
40
|
+
const start = Math.min(stat.size, Math.max(0, offset < 0 ? stat.size + offset : offset));
|
|
41
|
+
const requestedLength = Math.min(limit ?? stat.size, stat.size - start);
|
|
42
|
+
// A row contains 16 bytes and at most 90 ASCII characters, including large offsets.
|
|
43
|
+
const displayBudget =
|
|
44
|
+
16 *
|
|
45
|
+
Math.max(
|
|
46
|
+
1,
|
|
47
|
+
Math.min(READ_OUTPUT_MAX_LINES - 4, Math.floor((READ_OUTPUT_MAX_BYTES - 1024) / 90)),
|
|
48
|
+
);
|
|
49
|
+
const length =
|
|
50
|
+
audience === "script" ? requestedLength : Math.min(requestedLength, displayBudget);
|
|
51
|
+
const buffer = Buffer.alloc(length);
|
|
52
|
+
let count = 0;
|
|
53
|
+
while (count < length) {
|
|
54
|
+
context.signal?.throwIfAborted();
|
|
55
|
+
const chunk = await handle.read(buffer, count, length - count, start + count);
|
|
56
|
+
if (chunk.bytesRead === 0) break;
|
|
57
|
+
count += chunk.bytesRead;
|
|
58
|
+
}
|
|
59
|
+
context.signal?.throwIfAborted();
|
|
60
|
+
const bytes = buffer.subarray(0, count);
|
|
61
|
+
const source = `raw:${file}`;
|
|
62
|
+
const nextOffset = start + count;
|
|
63
|
+
const hasMore = nextOffset < stat.size;
|
|
64
|
+
const header = `${source}\nBytes ${start}..${nextOffset} (end exclusive), ${stat.size} bytes total`;
|
|
65
|
+
const rows = formatRawBytes(bytes, start);
|
|
66
|
+
const continuation = hasMore ? `\nUse offset=${nextOffset} to continue in bytes.` : "";
|
|
67
|
+
return {
|
|
68
|
+
content: [{ type: "text", text: `${header}\n${rows}${continuation}` }],
|
|
69
|
+
details: {
|
|
70
|
+
source,
|
|
71
|
+
resolvedBy: "raw",
|
|
72
|
+
byteOffset: start,
|
|
73
|
+
byteLength: count,
|
|
74
|
+
totalBytes: stat.size,
|
|
75
|
+
},
|
|
76
|
+
...(audience === "script" && {
|
|
77
|
+
script: {
|
|
78
|
+
kind: "bytes" as const,
|
|
79
|
+
source,
|
|
80
|
+
byteOffset: start,
|
|
81
|
+
byteLength: count,
|
|
82
|
+
totalBytes: stat.size,
|
|
83
|
+
bytes: Array.from(bytes),
|
|
84
|
+
},
|
|
85
|
+
}),
|
|
86
|
+
};
|
|
87
|
+
} finally {
|
|
88
|
+
await handle.close();
|
|
89
|
+
}
|
|
90
|
+
} catch (error) {
|
|
91
|
+
if (context.signal?.aborted) throw error;
|
|
92
|
+
return failureResult({
|
|
93
|
+
code: "READ_FAILED",
|
|
94
|
+
source: requested,
|
|
95
|
+
message: error instanceof Error ? error.message : String(error),
|
|
96
|
+
cause: error,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Render exact byte values with absolute hexadecimal offsets and a printable ASCII preview. */
|
|
102
|
+
export function formatRawBytes(bytes: Uint8Array, offset: number): string {
|
|
103
|
+
const rows: string[] = [];
|
|
104
|
+
for (let index = 0; index < bytes.length; index += 16) {
|
|
105
|
+
const row = bytes.subarray(index, index + 16);
|
|
106
|
+
const hex = Array.from(row, (byte) => byte.toString(16).padStart(2, "0")).join(" ");
|
|
107
|
+
const ascii = Array.from(row, (byte) =>
|
|
108
|
+
byte >= 32 && byte <= 126 ? String.fromCharCode(byte) : ".",
|
|
109
|
+
).join("");
|
|
110
|
+
rows.push(`${(offset + index).toString(16).padStart(8, "0")} ${hex.padEnd(47)} |${ascii}|`);
|
|
111
|
+
}
|
|
112
|
+
return rows.join("\n");
|
|
113
|
+
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { restoreReadDetails } from "./persisted-result.js";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
nativeReadArguments,
|
|
5
|
+
nativeReadContext,
|
|
6
|
+
nativeReadPresentation,
|
|
7
|
+
type ReadRenderContext,
|
|
8
|
+
} from "./native-resource-renderer.js";
|
|
2
9
|
import { requiredValue } from "pi-agent-invariant";
|
|
3
10
|
import {
|
|
4
11
|
type AgentToolResult,
|
|
@@ -32,38 +39,83 @@ interface ReadCallArguments {
|
|
|
32
39
|
readonly views?: unknown;
|
|
33
40
|
}
|
|
34
41
|
|
|
35
|
-
interface
|
|
36
|
-
readonly
|
|
37
|
-
readonly
|
|
42
|
+
interface ReadWindowPresentation {
|
|
43
|
+
readonly pathSuffix: string;
|
|
44
|
+
readonly qualifiers: readonly { readonly text: string }[];
|
|
45
|
+
readonly details: readonly { readonly label: string; readonly value: string }[];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function readWindowPresentation(
|
|
49
|
+
path: string,
|
|
50
|
+
rawOffset: unknown,
|
|
51
|
+
rawLimit: unknown,
|
|
52
|
+
): ReadWindowPresentation {
|
|
53
|
+
const offset = typeof rawOffset === "number" ? rawOffset : undefined;
|
|
54
|
+
const limit = typeof rawLimit === "number" ? rawLimit : undefined;
|
|
55
|
+
if (offset === undefined && limit === undefined) {
|
|
56
|
+
return { pathSuffix: "", qualifiers: [], details: [] };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const relative = path === "inherited source" || path.includes("#");
|
|
60
|
+
if (relative) {
|
|
61
|
+
const start = offset ?? 1;
|
|
62
|
+
const range = limit === undefined ? String(start) : `${start}-${start + limit - 1}`;
|
|
63
|
+
return {
|
|
64
|
+
pathSuffix: "",
|
|
65
|
+
qualifiers: [{ text: `relative lines ${range}` }],
|
|
66
|
+
details: [{ label: "relative lines", value: range }],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (offset !== undefined && offset < 0) {
|
|
71
|
+
return {
|
|
72
|
+
pathSuffix: "",
|
|
73
|
+
qualifiers: [
|
|
74
|
+
{ text: `tail ${Math.abs(offset)}` },
|
|
75
|
+
...(limit === undefined ? [] : [{ text: `limit ${limit}` }]),
|
|
76
|
+
],
|
|
77
|
+
details: [
|
|
78
|
+
{ label: "tail", value: String(Math.abs(offset)) },
|
|
79
|
+
...(limit === undefined ? [] : [{ label: "limit", value: String(limit) }]),
|
|
80
|
+
],
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const start = Math.max(1, offset ?? 1);
|
|
85
|
+
const range = limit === undefined ? String(start) : `${start}-${start + limit - 1}`;
|
|
86
|
+
return {
|
|
87
|
+
pathSuffix: `:${range}`,
|
|
88
|
+
qualifiers: [],
|
|
89
|
+
details: [{ label: "lines", value: range }],
|
|
90
|
+
};
|
|
38
91
|
}
|
|
39
92
|
|
|
40
93
|
/** Renders the requested read source and non-default options in the shared tool-card header. */
|
|
41
94
|
export function renderReadCall(
|
|
42
95
|
arguments_: ReadCallArguments,
|
|
43
96
|
theme: Theme,
|
|
44
|
-
context:
|
|
97
|
+
context: ReadRenderContext,
|
|
45
98
|
): Component {
|
|
99
|
+
const nativeArgs = nativeReadArguments(arguments_, context.cwd);
|
|
100
|
+
if (nativeArgs !== undefined) {
|
|
101
|
+
return requiredValue(nativeReadPresentation.renderCall)(
|
|
102
|
+
nativeArgs,
|
|
103
|
+
theme,
|
|
104
|
+
nativeReadContext(context, nativeArgs),
|
|
105
|
+
);
|
|
106
|
+
}
|
|
46
107
|
const path = typeof arguments_.path === "string" ? arguments_.path : "inherited source";
|
|
47
|
-
const
|
|
48
|
-
const limit = typeof arguments_.limit === "number" ? arguments_.limit : undefined;
|
|
108
|
+
const window = readWindowPresentation(path, arguments_.offset, arguments_.limit);
|
|
49
109
|
const views = Array.isArray(arguments_.views)
|
|
50
110
|
? arguments_.views.filter((view): view is string => typeof view === "string")
|
|
51
111
|
: [];
|
|
52
112
|
const qualifiers = [
|
|
53
|
-
...
|
|
54
|
-
? []
|
|
55
|
-
: [
|
|
56
|
-
{
|
|
57
|
-
text: offset < 0 ? `tail ${String(Math.abs(offset))}` : `offset ${String(offset)}`,
|
|
58
|
-
},
|
|
59
|
-
]),
|
|
60
|
-
...(limit === undefined ? [] : [{ text: `limit ${String(limit)}` }]),
|
|
113
|
+
...window.qualifiers,
|
|
61
114
|
...(views.length === 0 ? [] : [{ text: `views ${views.join(",")}` }]),
|
|
62
115
|
];
|
|
63
116
|
const details = [
|
|
64
117
|
...(typeof arguments_.path === "string" ? [{ label: "path", value: arguments_.path }] : []),
|
|
65
|
-
...
|
|
66
|
-
...(limit === undefined ? [] : [{ label: "limit", value: String(limit) }]),
|
|
118
|
+
...window.details,
|
|
67
119
|
...(views.length === 0 ? [] : [{ label: "views", value: views.join(",") }]),
|
|
68
120
|
];
|
|
69
121
|
return toolCallHeader(
|
|
@@ -71,14 +123,14 @@ export function renderReadCall(
|
|
|
71
123
|
{
|
|
72
124
|
tool: "read",
|
|
73
125
|
primary: {
|
|
74
|
-
text: path
|
|
126
|
+
text: `${path}${window.pathSuffix}`,
|
|
75
127
|
color: typeof arguments_.path === "string" ? "accent" : "muted",
|
|
76
128
|
underline: typeof arguments_.path === "string",
|
|
77
129
|
truncate: "start",
|
|
78
130
|
},
|
|
79
131
|
qualifiers,
|
|
80
132
|
details,
|
|
81
|
-
expanded: context.expanded
|
|
133
|
+
expanded: context.expanded,
|
|
82
134
|
},
|
|
83
135
|
theme,
|
|
84
136
|
);
|
|
@@ -95,12 +147,26 @@ interface ReadPanelState {
|
|
|
95
147
|
export function createReadResultRenderer(options: ReadResultRendererOptions): ReadResultRenderer {
|
|
96
148
|
const restored = new WeakMap<object, ReadResultDetails>();
|
|
97
149
|
return (result, renderOptions, theme, context): Component => {
|
|
150
|
+
const nativeArgs = options.nativeResources
|
|
151
|
+
? nativeReadArguments(context.args, context.cwd)
|
|
152
|
+
: undefined;
|
|
153
|
+
if (nativeArgs !== undefined && !renderOptions.isPartial) {
|
|
154
|
+
return requiredValue(nativeReadPresentation.renderResult)(
|
|
155
|
+
{ ...result, details: { truncation: readDetails(result.details).truncation } },
|
|
156
|
+
renderOptions,
|
|
157
|
+
theme,
|
|
158
|
+
nativeReadContext(context, nativeArgs),
|
|
159
|
+
);
|
|
160
|
+
}
|
|
98
161
|
if (renderOptions.isPartial || context.isError) {
|
|
99
162
|
const text = textBlocks(result);
|
|
100
163
|
const color = context.isError ? "error" : "dim";
|
|
101
164
|
return new Text(theme.fg(color, text), 0, 0);
|
|
102
165
|
}
|
|
103
166
|
|
|
167
|
+
const check = readDetails(result.details).diagnosticCheck;
|
|
168
|
+
if (check?.complete && check.count === 0) return new Container();
|
|
169
|
+
|
|
104
170
|
if (!hasTextContent(result)) {
|
|
105
171
|
return context.lastComponent instanceof Container ? context.lastComponent : new Container();
|
|
106
172
|
}
|
|
@@ -159,7 +225,9 @@ export class ReadResultPanel implements Component {
|
|
|
159
225
|
|
|
160
226
|
const innerWidth = width - 2;
|
|
161
227
|
const contentWidth = Math.max(1, innerWidth - 2);
|
|
162
|
-
const renderedRows = renderContentRows(this.state, contentWidth)
|
|
228
|
+
const renderedRows = renderContentRows(this.state, contentWidth).flatMap((row) =>
|
|
229
|
+
wrapTextWithAnsi(row, contentWidth),
|
|
230
|
+
);
|
|
163
231
|
const rows = compactRows(renderedRows, this.state.expanded, this.state.theme);
|
|
164
232
|
const lines = [renderTopBorder(this.state, innerWidth, this.state.theme)];
|
|
165
233
|
|
|
@@ -42,6 +42,7 @@ export function createReadState(
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
export interface ReadProjectionOptions {
|
|
45
|
+
readonly audience?: "agent" | "script";
|
|
45
46
|
/** Absolute 1-based line where an anchored read's window starts. */
|
|
46
47
|
readonly originLine?: number;
|
|
47
48
|
}
|
|
@@ -64,6 +65,9 @@ export function projectReadState(
|
|
|
64
65
|
const projected = projectAgentContent(state.content);
|
|
65
66
|
|
|
66
67
|
return {
|
|
68
|
+
...(options?.audience === "script" && {
|
|
69
|
+
script: { kind: "native" as const, source: state.source, blocks: state.content },
|
|
70
|
+
}),
|
|
67
71
|
content: projected.content,
|
|
68
72
|
details: {
|
|
69
73
|
...readDetails(state),
|
|
@@ -100,6 +104,17 @@ export function projectReadState(
|
|
|
100
104
|
];
|
|
101
105
|
|
|
102
106
|
return {
|
|
107
|
+
...(options?.audience === "script" && {
|
|
108
|
+
script: {
|
|
109
|
+
kind: "text" as const,
|
|
110
|
+
source: state.source,
|
|
111
|
+
content: lines.map((line) => line.content + line.lineEnding).join(""),
|
|
112
|
+
lines,
|
|
113
|
+
startLine: lines[0]?.lineNumber ?? 0,
|
|
114
|
+
endLine: lines.at(-1)?.lineNumber ?? 0,
|
|
115
|
+
totalLines,
|
|
116
|
+
},
|
|
117
|
+
}),
|
|
103
118
|
content,
|
|
104
119
|
details: {
|
|
105
120
|
...readDetails(state),
|