pi-agent-ide 0.7.1 → 0.7.3
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 +66 -0
- package/README.md +3 -1
- package/dist/{chunk-PKKDDIWW.js → chunk-2ZMMRINH.js} +1 -1
- package/dist/chunk-6U5OU77O.js +3 -0
- package/dist/chunk-BYZSBXUK.js +2 -0
- package/dist/{chunk-LEEQIQ7D.js → chunk-CEX73RI5.js} +6 -6
- package/dist/chunk-DZWTKF2K.js +1 -0
- package/dist/{chunk-WMO6RNE2.js → chunk-EOKEQ3YH.js} +6 -6
- package/dist/{chunk-HZEY4GT4.js → chunk-H445SHSJ.js} +2 -2
- package/dist/{chunk-4GCWGE2C.js → chunk-HZ5BNF3A.js} +1 -1
- package/dist/chunk-IG56UGSO.js +2 -0
- package/dist/chunk-IICJXZBU.js +6 -0
- package/dist/{chunk-XYS4FSCC.js → chunk-IM24DB3K.js} +1 -1
- package/dist/chunk-MXLSGMRZ.js +3 -0
- package/dist/{chunk-76ZK5ODR.js → chunk-NHKPP2AI.js} +13 -13
- package/dist/chunk-OB46OPMZ.js +1 -0
- package/dist/{chunk-PNU3E7IO.js → chunk-Q6CZ6GBR.js} +2 -2
- package/dist/chunk-QUYXINGZ.js +7 -0
- package/dist/{chunk-OMVRLWMX.js → chunk-SBP3ABH4.js} +1 -1
- package/dist/{chunk-YP46DVVP.js → chunk-STBJO3Z3.js} +1 -1
- package/dist/{chunk-2TRHFMCZ.js → chunk-TXOTNK6B.js} +1 -1
- package/dist/chunk-WLZIUMJL.js +1 -0
- package/dist/chunk-ZIWPKIBZ.js +1 -0
- 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-17.js +1 -1
- package/dist/entry-25.js +1 -1
- 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-31.js +12 -11
- package/dist/entry-33.js +3 -1
- package/dist/entry-37.js +6 -6
- package/dist/entry-42.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +20 -12
- package/dist/entry-46.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +1 -1
- package/dist/entry-51.js +7 -6
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-54.js +1 -1
- package/dist/entry-56.js +1 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-62.js +1 -1
- package/dist/entry-65.js +1 -1
- package/dist/entry-66.js +1 -1
- package/dist/entry-68.js +1 -1
- package/dist/entry-70.js +1 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-77.js +63 -49
- package/dist/entry-78.js +15 -14
- package/dist/entry-79.js +1 -1
- package/dist/entry-82.js +5 -5
- package/dist/entry-83.js +1 -1
- package/dist/entry-84.js +1 -1
- package/dist/entry-85.js +1 -1
- package/dist/entry-86.js +1 -1
- package/dist/pi-agent-ide.js +34 -11
- package/docs/agent-guides/editing.md +14 -7
- package/docs/agent-guides/git-changes.md +10 -0
- package/docs/agent-guides/read-resources.md +9 -46
- package/docs/agent-guides/search-code.md +7 -1
- package/docs/agent-guides/select-code.md +1 -0
- package/docs/agent-guides/terminal.md +9 -1
- package/docs/configuration.md +22 -1
- package/docs/development.md +4 -0
- package/docs/directory-operations.md +45 -0
- package/docs/releases.md +12 -0
- package/docs/research/codemode-write-context.md +56 -0
- package/docs/research/native-codemode-batch-decision.md +2 -0
- package/docs/structured-results.md +2 -2
- package/docs/tools.md +10 -2
- package/docs/user-hooks.md +26 -0
- 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-filesystem/package.json +7 -7
- 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-jq/src/jq.ts +4 -1
- 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 +13 -13
- package/node_modules/pi-agent-ide-ast/src/extension.ts +3 -3
- package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +9 -4
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +0 -3
- package/node_modules/pi-agent-ide-ast/src/select-schema.ts +8 -6
- package/node_modules/pi-agent-ide-ast/src/tool-select.ts +13 -5
- package/node_modules/pi-agent-ide-changes/package.json +9 -8
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +82 -4
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +8 -11
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-languages/package.json +2 -2
- package/node_modules/pi-agent-ide-lint/package.json +7 -7
- package/node_modules/pi-agent-ide-lsp/index.ts +1 -1
- package/node_modules/pi-agent-ide-lsp/package.json +9 -9
- package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +2 -1
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +0 -1
- package/node_modules/pi-agent-image/package.json +2 -2
- package/node_modules/pi-agent-invariant/package.json +1 -1
- package/node_modules/pi-agent-pdf/package.json +2 -2
- package/node_modules/pi-agent-read/package.json +7 -7
- package/node_modules/pi-agent-read/src/api/read-parameters.ts +3 -3
- package/node_modules/pi-agent-read/src/api/tools/read.ts +11 -0
- package/node_modules/pi-agent-read/src/core/extension.ts +1 -1
- package/node_modules/pi-agent-read/src/core/read-core.ts +5 -1
- package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +91 -18
- package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +8 -2
- package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +38 -1
- package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +57 -2
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +99 -44
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/index.ts +1 -0
- package/node_modules/pi-agent-resource/src/result-targets.ts +6 -3
- package/node_modules/{pi-agent-read/src/core/tools/read → pi-agent-resource/src}/temp-resource-store.ts +17 -7
- package/node_modules/pi-agent-search/package.json +5 -5
- package/node_modules/pi-agent-search/src/api/fuzzy.ts +5 -1
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +2 -2
- package/node_modules/pi-agent-search/src/core/extension.ts +2 -1
- package/node_modules/pi-agent-search/src/core/search-core.ts +13 -4
- package/node_modules/pi-agent-search-text/package.json +7 -7
- package/node_modules/pi-agent-search-text/src/resolvers.ts +11 -1
- package/node_modules/pi-agent-search-text/src/scoped-search.ts +1 -1
- package/node_modules/pi-agent-search-text/src/search-presentation.ts +42 -32
- package/node_modules/pi-agent-search-text/src/search-recipe.ts +1 -1
- package/node_modules/pi-agent-search-text/src/search-renderer.ts +6 -0
- package/node_modules/pi-agent-search-text/src/search-result.ts +17 -3
- package/node_modules/pi-agent-text/package.json +2 -2
- 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/package.json +5 -5
- package/node_modules/pi-agent-text-editor/package.json +9 -9
- package/node_modules/pi-agent-text-editor/src/api/delete-guard.ts +24 -0
- package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +2 -2
- package/node_modules/pi-agent-text-editor/src/api/mutation-guard.ts +1 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +1 -2
- package/node_modules/pi-agent-text-editor/src/api/native-edit-batch-event.ts +4 -0
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +4 -1
- package/node_modules/pi-agent-text-editor/src/api/stale-anchor-message.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/delete-policy.ts +284 -0
- package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +54 -12
- package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +32 -3
- package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +30 -40
- package/node_modules/pi-agent-text-editor/src/core/file-result-targets.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/file-transfers.ts +164 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +36 -12
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +25 -1
- package/node_modules/pi-agent-text-editor/src/core/mutation-result-targets.ts +132 -11
- package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +286 -162
- package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +34 -10
- package/node_modules/pi-agent-text-editor/src/core/result-input.ts +24 -4
- package/node_modules/pi-agent-text-editor/src/core/result-transfer.ts +46 -11
- package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +21 -14
- package/node_modules/pi-agent-text-editor/src/core/temporary-directories.ts +96 -0
- package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +5 -1
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +155 -22
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +126 -32
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +428 -189
- package/node_modules/pi-agent-text-editor/src/core/write-agent-result.ts +66 -0
- package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +6 -4
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +15 -6
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +9 -4
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +7 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +6 -4
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +2 -3
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +10 -4
- package/node_modules/pi-agent-text-editor-renderer/package.json +5 -5
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +11 -0
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +75 -11
- package/node_modules/pi-agent-text-editor-renderer/src/status-summary.ts +18 -3
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +4 -4
- package/node_modules/pi-agent-tool-call-interception/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/package.json +1 -1
- package/node_modules/pi-agent-web/package.json +7 -7
- package/node_modules/pi-agent-web/src/resolver.ts +11 -13
- package/node_modules/pi-agent-web-html/package.json +2 -2
- package/node_modules/pi-agent-web-image/package.json +3 -3
- package/node_modules/pi-agent-web-pdf/package.json +3 -3
- package/node_modules/pi-agent-web-text/package.json +3 -3
- package/package.json +36 -35
- package/src/api/hooks.ts +24 -0
- package/src/composite/nested-tool-rendering.ts +184 -77
- package/src/composite/output-limits.ts +125 -0
- package/src/composite/responses-tools.ts +25 -0
- package/src/composite/text-results.ts +158 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
- 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-jq/src/jq.ts +4 -1
- 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/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +2 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/resolver.ts +11 -13
- package/src/extensions/pi-agent-read/package.json +7 -7
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +3 -3
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +11 -0
- package/src/extensions/pi-agent-read/src/core/extension.ts +1 -1
- package/src/extensions/pi-agent-read/src/core/read-core.ts +5 -1
- package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +91 -18
- package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +8 -2
- package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +38 -1
- package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +57 -2
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +99 -44
- package/src/extensions/pi-agent-search/package.json +5 -5
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +7 -7
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +11 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +1 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-presentation.ts +42 -32
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +1 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +6 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +17 -3
- package/src/extensions/pi-agent-search/src/api/fuzzy.ts +5 -1
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +2 -2
- package/src/extensions/pi-agent-search/src/core/extension.ts +2 -1
- package/src/extensions/pi-agent-search/src/core/search-core.ts +13 -4
- package/src/extensions/pi-agent-text-editor/package.json +9 -9
- 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/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +11 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +75 -11
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/status-summary.ts +18 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +4 -4
- package/src/extensions/pi-agent-text-editor/src/api/delete-guard.ts +24 -0
- package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +2 -2
- package/src/extensions/pi-agent-text-editor/src/api/mutation-guard.ts +1 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +1 -2
- package/src/extensions/pi-agent-text-editor/src/api/native-edit-batch-event.ts +4 -0
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +4 -1
- package/src/extensions/pi-agent-text-editor/src/api/stale-anchor-message.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/delete-policy.ts +284 -0
- package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +54 -12
- package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +32 -3
- package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +30 -40
- package/src/extensions/pi-agent-text-editor/src/core/file-result-targets.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/file-transfers.ts +164 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +36 -12
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +25 -1
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result-targets.ts +132 -11
- package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +286 -162
- package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +34 -10
- package/src/extensions/pi-agent-text-editor/src/core/result-input.ts +24 -4
- package/src/extensions/pi-agent-text-editor/src/core/result-transfer.ts +46 -11
- package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +21 -14
- package/src/extensions/pi-agent-text-editor/src/core/temporary-directories.ts +96 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +5 -1
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +155 -22
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +126 -32
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +428 -189
- package/src/extensions/pi-agent-text-editor/src/core/write-agent-result.ts +66 -0
- package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +6 -4
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +15 -6
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +9 -4
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +7 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +6 -4
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +2 -3
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +10 -4
- package/src/pi-agent-ide.ts +11 -0
- package/src/plugins/pi-agent-ide-ast/package.json +13 -13
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +3 -3
- package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +9 -4
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +0 -3
- package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +8 -6
- package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +13 -5
- package/src/plugins/pi-agent-ide-changes/package.json +9 -8
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +82 -4
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +8 -11
- package/src/plugins/pi-agent-ide-debugger/index.ts +20 -8
- package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +5 -0
- package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +93 -38
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +3 -2
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-languages/package.json +2 -2
- package/src/plugins/pi-agent-ide-lint/package.json +7 -7
- package/src/plugins/pi-agent-ide-lsp/index.ts +1 -1
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
- package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +2 -1
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +0 -1
- package/src/plugins/pi-agent-ide-terminal/src/output-limits.ts +3 -3
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +3 -3
- package/src/plugins/pi-agent-ide-vision/index.ts +1 -0
- package/src/post-edit/gate.ts +13 -2
- package/dist/chunk-4XMY4H4V.js +0 -1
- package/dist/chunk-64M3SQPG.js +0 -3
- package/dist/chunk-CWD4O5PM.js +0 -3
- package/dist/chunk-D3WTDA6V.js +0 -2
- package/dist/chunk-EAZGN5ND.js +0 -7
- package/dist/chunk-GXEGY7GV.js +0 -1
- package/dist/chunk-MBUXFKIW.js +0 -3
- package/dist/chunk-PGIVHICI.js +0 -1
- package/dist/chunk-VMTR74FF.js +0 -2
- package/dist/chunk-WU6ZK6YD.js +0 -1
- package/src/extensions/pi-agent-read/src/core/tools/read/temp-resource-store.ts +0 -105
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-web-html",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"defuddle": "^0.19.1",
|
|
10
10
|
"linkedom": "^0.18.12",
|
|
11
|
-
"pi-agent-resource": "0.7.
|
|
11
|
+
"pi-agent-resource": "0.7.3"
|
|
12
12
|
},
|
|
13
13
|
"pi": {
|
|
14
14
|
"extensions": [
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-web-image",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"pi-agent-image": "0.7.
|
|
7
|
-
"pi-agent-resource": "0.7.
|
|
6
|
+
"pi-agent-image": "0.7.3",
|
|
7
|
+
"pi-agent-resource": "0.7.3"
|
|
8
8
|
},
|
|
9
9
|
"pi": {
|
|
10
10
|
"extensions": [
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-web-pdf",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"pi-agent-pdf": "0.7.
|
|
7
|
-
"pi-agent-resource": "0.7.
|
|
6
|
+
"pi-agent-pdf": "0.7.3",
|
|
7
|
+
"pi-agent-resource": "0.7.3"
|
|
8
8
|
},
|
|
9
9
|
"pi": {
|
|
10
10
|
"extensions": [
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-web-text",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"pi-agent-resource": "0.7.
|
|
7
|
-
"pi-agent-text": "0.7.
|
|
6
|
+
"pi-agent-resource": "0.7.3",
|
|
7
|
+
"pi-agent-text": "0.7.3"
|
|
8
8
|
},
|
|
9
9
|
"pi": {
|
|
10
10
|
"extensions": [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-ide",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "Agent-native IDE extension for Pi Coding Agent with guarded editing, search, LSP, terminals, debugging, and observability",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent-ide",
|
|
@@ -91,6 +91,7 @@
|
|
|
91
91
|
"#pi-agent-text-anchor-exact/*": "./src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/*",
|
|
92
92
|
"#pi-agent-text-editor-renderer/*": "./src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/*",
|
|
93
93
|
"#pi-agent-text-editor/*": "./src/extensions/pi-agent-text-editor/src/*",
|
|
94
|
+
"#capabilities/*": "./benchmarks/tool-capabilities/*",
|
|
94
95
|
"#scripts/*": "./scripts/*"
|
|
95
96
|
},
|
|
96
97
|
"exports": {
|
|
@@ -202,40 +203,40 @@
|
|
|
202
203
|
"oxfmt": "0.64.0",
|
|
203
204
|
"partial-json": "^0.1.7",
|
|
204
205
|
"pdfjs-dist": "^6.2.108",
|
|
205
|
-
"pi-agent-doctor": "0.7.
|
|
206
|
-
"pi-agent-documentation": "0.7.
|
|
207
|
-
"pi-agent-filesystem": "0.7.
|
|
208
|
-
"pi-agent-filesystem-image": "0.7.
|
|
209
|
-
"pi-agent-filesystem-jq": "0.7.
|
|
210
|
-
"pi-agent-filesystem-pdf": "0.7.
|
|
211
|
-
"pi-agent-filesystem-text": "0.7.
|
|
212
|
-
"pi-agent-ide-ast": "0.7.
|
|
213
|
-
"pi-agent-ide-changes": "0.7.
|
|
214
|
-
"pi-agent-ide-formatter": "0.7.
|
|
215
|
-
"pi-agent-ide-languages": "0.7.
|
|
216
|
-
"pi-agent-ide-lint": "0.7.
|
|
217
|
-
"pi-agent-ide-lsp": "0.7.
|
|
218
|
-
"pi-agent-image": "0.7.
|
|
219
|
-
"pi-agent-invariant": "0.7.
|
|
220
|
-
"pi-agent-pdf": "0.7.
|
|
221
|
-
"pi-agent-read": "0.7.
|
|
222
|
-
"pi-agent-resource": "0.7.
|
|
223
|
-
"pi-agent-search": "0.7.
|
|
224
|
-
"pi-agent-search-text": "0.7.
|
|
225
|
-
"pi-agent-text": "0.7.
|
|
226
|
-
"pi-agent-text-anchor-constant": "0.7.
|
|
227
|
-
"pi-agent-text-anchor-exact": "0.7.
|
|
228
|
-
"pi-agent-text-anchor-line-hash": "0.7.
|
|
229
|
-
"pi-agent-text-editor": "0.7.
|
|
230
|
-
"pi-agent-text-editor-renderer": "0.7.
|
|
231
|
-
"pi-agent-text-editor-stale-anchor": "0.7.
|
|
232
|
-
"pi-agent-tool-call-interception": "0.7.
|
|
233
|
-
"pi-agent-tool-ui": "0.7.
|
|
234
|
-
"pi-agent-web": "0.7.
|
|
235
|
-
"pi-agent-web-html": "0.7.
|
|
236
|
-
"pi-agent-web-image": "0.7.
|
|
237
|
-
"pi-agent-web-pdf": "0.7.
|
|
238
|
-
"pi-agent-web-text": "0.7.
|
|
206
|
+
"pi-agent-doctor": "0.7.3",
|
|
207
|
+
"pi-agent-documentation": "0.7.3",
|
|
208
|
+
"pi-agent-filesystem": "0.7.3",
|
|
209
|
+
"pi-agent-filesystem-image": "0.7.3",
|
|
210
|
+
"pi-agent-filesystem-jq": "0.7.3",
|
|
211
|
+
"pi-agent-filesystem-pdf": "0.7.3",
|
|
212
|
+
"pi-agent-filesystem-text": "0.7.3",
|
|
213
|
+
"pi-agent-ide-ast": "0.7.3",
|
|
214
|
+
"pi-agent-ide-changes": "0.7.3",
|
|
215
|
+
"pi-agent-ide-formatter": "0.7.3",
|
|
216
|
+
"pi-agent-ide-languages": "0.7.3",
|
|
217
|
+
"pi-agent-ide-lint": "0.7.3",
|
|
218
|
+
"pi-agent-ide-lsp": "0.7.3",
|
|
219
|
+
"pi-agent-image": "0.7.3",
|
|
220
|
+
"pi-agent-invariant": "0.7.3",
|
|
221
|
+
"pi-agent-pdf": "0.7.3",
|
|
222
|
+
"pi-agent-read": "0.7.3",
|
|
223
|
+
"pi-agent-resource": "0.7.3",
|
|
224
|
+
"pi-agent-search": "0.7.3",
|
|
225
|
+
"pi-agent-search-text": "0.7.3",
|
|
226
|
+
"pi-agent-text": "0.7.3",
|
|
227
|
+
"pi-agent-text-anchor-constant": "0.7.3",
|
|
228
|
+
"pi-agent-text-anchor-exact": "0.7.3",
|
|
229
|
+
"pi-agent-text-anchor-line-hash": "0.7.3",
|
|
230
|
+
"pi-agent-text-editor": "0.7.3",
|
|
231
|
+
"pi-agent-text-editor-renderer": "0.7.3",
|
|
232
|
+
"pi-agent-text-editor-stale-anchor": "0.7.3",
|
|
233
|
+
"pi-agent-tool-call-interception": "0.7.3",
|
|
234
|
+
"pi-agent-tool-ui": "0.7.3",
|
|
235
|
+
"pi-agent-web": "0.7.3",
|
|
236
|
+
"pi-agent-web-html": "0.7.3",
|
|
237
|
+
"pi-agent-web-image": "0.7.3",
|
|
238
|
+
"pi-agent-web-pdf": "0.7.3",
|
|
239
|
+
"pi-agent-web-text": "0.7.3",
|
|
239
240
|
"playwright-core": "^1.62.1",
|
|
240
241
|
"tree-sitter-cpp": "^0.23.4",
|
|
241
242
|
"tree-sitter-javascript": "^0.25.0",
|
package/src/api/hooks.ts
CHANGED
|
@@ -8,6 +8,30 @@ import {
|
|
|
8
8
|
type TextDocument,
|
|
9
9
|
} from "./text-editor.js";
|
|
10
10
|
|
|
11
|
+
import type { BeforeDeleteEvent } from "pi-agent-text-editor/api/mutation-guard";
|
|
12
|
+
export type { BeforeDeleteEvent } from "pi-agent-text-editor/api/mutation-guard";
|
|
13
|
+
|
|
14
|
+
/** A policy over a whole file, directory, or symlink before removal. */
|
|
15
|
+
export interface BeforeDeleteHook {
|
|
16
|
+
readonly id: string;
|
|
17
|
+
run(event: BeforeDeleteEvent): FileHookDecision | Promise<FileHookDecision>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Register a fail-closed deletion policy; allowing never bypasses built-in safety or approval. */
|
|
21
|
+
export function connectBeforeDeleteHook(
|
|
22
|
+
pi: ExtensionAPI,
|
|
23
|
+
hook: BeforeDeleteHook,
|
|
24
|
+
): void | Promise<void> {
|
|
25
|
+
assertHook(hook);
|
|
26
|
+
return connectTextEditorPlugin(pi, {
|
|
27
|
+
protocol: TEXT_EDITOR_PROTOCOL,
|
|
28
|
+
apiVersion: TEXT_EDITOR_API_VERSION,
|
|
29
|
+
id: `hook/before-delete/${hook.id}`,
|
|
30
|
+
setup(api) {
|
|
31
|
+
api.addDeleteGuard({ id: hook.id, guard: (event) => hook.run(event) });
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
}
|
|
11
35
|
/** The decision returned by a file policy hook. */
|
|
12
36
|
export type FileHookDecision =
|
|
13
37
|
| { readonly decision: "allow" }
|
|
@@ -22,8 +22,15 @@ interface ChildPanel {
|
|
|
22
22
|
name: string;
|
|
23
23
|
args: unknown;
|
|
24
24
|
renderArgs?: unknown;
|
|
25
|
+
argumentsTruncated?: boolean;
|
|
26
|
+
resultOmitted?: boolean;
|
|
27
|
+
// Older sessions only recorded whether a result display was omitted.
|
|
25
28
|
omitted?: boolean;
|
|
26
29
|
batched?: boolean;
|
|
30
|
+
rollback?: boolean;
|
|
31
|
+
postWriteFailure?: boolean;
|
|
32
|
+
unchangedCopy?: boolean;
|
|
33
|
+
copyRollback?: "restored" | "failed";
|
|
27
34
|
result?: { content: AgentToolResult<unknown>["content"]; details: unknown; isError: boolean };
|
|
28
35
|
}
|
|
29
36
|
interface BatchReport {
|
|
@@ -33,7 +40,42 @@ interface PanelGroup {
|
|
|
33
40
|
parentToolCallId: string;
|
|
34
41
|
cwd: string;
|
|
35
42
|
calls: ChildPanel[];
|
|
36
|
-
|
|
43
|
+
retention: RetentionReasons;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface RetentionReasons {
|
|
47
|
+
argumentsTruncated: boolean;
|
|
48
|
+
resultsOmitted: boolean;
|
|
49
|
+
callsOmitted: boolean;
|
|
50
|
+
resultsUnavailable: boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const retained = (): RetentionReasons => ({
|
|
54
|
+
argumentsTruncated: false,
|
|
55
|
+
resultsOmitted: false,
|
|
56
|
+
callsOmitted: false,
|
|
57
|
+
resultsUnavailable: false,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
interface SavedPanelGroup extends Omit<PanelGroup, "retention"> {
|
|
61
|
+
retention?: RetentionReasons;
|
|
62
|
+
// Older history did not record why it was incomplete.
|
|
63
|
+
complete?: boolean;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function retentionWarning(group: SavedPanelGroup): string | undefined {
|
|
67
|
+
const reasons = group.retention;
|
|
68
|
+
const omissions = [
|
|
69
|
+
reasons?.argumentsTruncated && "arguments shortened",
|
|
70
|
+
reasons?.resultsOmitted && "result displays omitted",
|
|
71
|
+
reasons?.callsOmitted && "call panels omitted",
|
|
72
|
+
reasons?.resultsUnavailable && "results unavailable",
|
|
73
|
+
].filter(Boolean);
|
|
74
|
+
if (omissions.length > 0)
|
|
75
|
+
return `Nested IDE display: ${omissions.join("; ")}. Tool execution and parent output are unchanged.`;
|
|
76
|
+
if (!reasons && group.complete === false)
|
|
77
|
+
return "Nested IDE display is incomplete; omission details are unavailable.";
|
|
78
|
+
return undefined;
|
|
37
79
|
}
|
|
38
80
|
|
|
39
81
|
/** Keep bounded display data for nested IDE tools, separate from model context and usage. */
|
|
@@ -50,6 +92,7 @@ export function createNestedIdeRendering(pi: ExtensionAPI) {
|
|
|
50
92
|
) => {
|
|
51
93
|
// Bound in-memory display data as each call finishes, not only at persistence.
|
|
52
94
|
call.result = result;
|
|
95
|
+
call.resultOmitted = false;
|
|
53
96
|
try {
|
|
54
97
|
const serialized = JSON.stringify(group);
|
|
55
98
|
if (Buffer.byteLength(serialized) <= MAX_BYTES) {
|
|
@@ -81,8 +124,7 @@ export function createNestedIdeRendering(pi: ExtensionAPI) {
|
|
|
81
124
|
details: undefined,
|
|
82
125
|
isError: result.isError,
|
|
83
126
|
};
|
|
84
|
-
call.
|
|
85
|
-
group.complete = false;
|
|
127
|
+
call.resultOmitted = true;
|
|
86
128
|
};
|
|
87
129
|
const clear = () => {
|
|
88
130
|
parents.clear();
|
|
@@ -106,21 +148,22 @@ export function createNestedIdeRendering(pi: ExtensionAPI) {
|
|
|
106
148
|
if (event.parentToolCallId === undefined) return;
|
|
107
149
|
const root = parents.get(event.parentToolCallId) ?? event.parentToolCallId;
|
|
108
150
|
parents.set(event.toolCallId, root);
|
|
109
|
-
|
|
110
|
-
if (event.toolName === "flush" || !definitions.has(event.toolName)) return;
|
|
151
|
+
if (!definitions.has(event.toolName)) return;
|
|
111
152
|
let group = groups.get(root);
|
|
112
153
|
if (!group) {
|
|
113
|
-
group = { parentToolCallId: root, cwd: context.cwd, calls: [],
|
|
154
|
+
group = { parentToolCallId: root, cwd: context.cwd, calls: [], retention: retained() };
|
|
114
155
|
groups.set(root, group);
|
|
115
156
|
}
|
|
116
157
|
if (group.calls.length >= MAX_CALLS) {
|
|
117
|
-
group.
|
|
158
|
+
group.retention.callsOmitted = true;
|
|
118
159
|
return;
|
|
119
160
|
}
|
|
120
161
|
const json = JSON.stringify(event.args);
|
|
121
162
|
const remaining =
|
|
122
163
|
MAX_ARGUMENT_TOTAL_BYTES -
|
|
123
|
-
group.calls.reduce((bytes, call) => bytes + Buffer.byteLength(JSON.stringify(call.args)), 0)
|
|
164
|
+
group.calls.reduce((bytes, call) => bytes + Buffer.byteLength(JSON.stringify(call.args)), 0) -
|
|
165
|
+
// Reserve an empty object for every remaining call, even after argument space runs out.
|
|
166
|
+
(MAX_CALLS - group.calls.length - 1) * 2;
|
|
124
167
|
const omitted = Buffer.byteLength(json) > Math.min(MAX_ARGUMENT_BYTES, remaining);
|
|
125
168
|
const args = omitted
|
|
126
169
|
? Object.fromEntries(
|
|
@@ -132,9 +175,16 @@ export function createNestedIdeRendering(pi: ExtensionAPI) {
|
|
|
132
175
|
]),
|
|
133
176
|
)
|
|
134
177
|
: (JSON.parse(json) as unknown);
|
|
135
|
-
const boundedArgs =
|
|
136
|
-
|
|
137
|
-
|
|
178
|
+
const boundedArgs =
|
|
179
|
+
Buffer.byteLength(JSON.stringify(args)) <= Math.min(MAX_ARGUMENT_BYTES, remaining)
|
|
180
|
+
? args
|
|
181
|
+
: {};
|
|
182
|
+
group.calls.push({
|
|
183
|
+
id: event.toolCallId,
|
|
184
|
+
name: event.toolName,
|
|
185
|
+
args: boundedArgs,
|
|
186
|
+
argumentsTruncated: omitted,
|
|
187
|
+
});
|
|
138
188
|
});
|
|
139
189
|
pi.on("tool_execution_end", (event) => {
|
|
140
190
|
const root = parents.get(event.toolCallId);
|
|
@@ -161,97 +211,150 @@ export function createNestedIdeRendering(pi: ExtensionAPI) {
|
|
|
161
211
|
groups.delete(event.message.toolCallId);
|
|
162
212
|
for (const [child, root] of parents) if (root === group.parentToolCallId) parents.delete(child);
|
|
163
213
|
// Serializing once strips runtime classes and prevents later hooks from mutating history.
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
214
|
+
const calls = group.calls.filter((call) => !call.batched);
|
|
215
|
+
const saved: PanelGroup = {
|
|
216
|
+
...group,
|
|
217
|
+
calls: [],
|
|
218
|
+
retention: {
|
|
219
|
+
...group.retention,
|
|
220
|
+
argumentsTruncated: calls.some((call) => call.argumentsTruncated === true),
|
|
221
|
+
resultsOmitted: calls.some((call) => call.resultOmitted === true),
|
|
222
|
+
resultsUnavailable: calls.some((call) => !call.result),
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
// Include group metadata and separators, not just call payloads, in the history budget.
|
|
226
|
+
let bytes = Buffer.byteLength(JSON.stringify(saved));
|
|
227
|
+
for (const call of calls) {
|
|
168
228
|
const json = JSON.stringify(call);
|
|
169
|
-
bytes += Buffer.byteLength(json);
|
|
229
|
+
bytes += Buffer.byteLength(json) + (saved.calls.length > 0 ? 1 : 0);
|
|
170
230
|
if (bytes > MAX_BYTES) {
|
|
171
|
-
saved.
|
|
231
|
+
saved.retention.callsOmitted = true;
|
|
172
232
|
break;
|
|
173
233
|
}
|
|
174
234
|
saved.calls.push(JSON.parse(json) as ChildPanel);
|
|
175
|
-
if (!call.result) saved.complete = false;
|
|
176
235
|
}
|
|
177
236
|
pi.appendEntry(ENTRY_TYPE, saved);
|
|
178
237
|
});
|
|
179
|
-
pi.registerEntryRenderer<
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
238
|
+
pi.registerEntryRenderer<SavedPanelGroup>(
|
|
239
|
+
ENTRY_TYPE,
|
|
240
|
+
function renderEntry(entry, options, theme) {
|
|
241
|
+
if (!Array.isArray(entry.data?.calls)) return undefined;
|
|
242
|
+
// Pi rebuilds resumed history before session_start binds the public UI.
|
|
243
|
+
// Keep the entry mounted and resolve its tool components on the next render.
|
|
244
|
+
if (!tui)
|
|
245
|
+
return {
|
|
246
|
+
render: (width: number): string[] =>
|
|
247
|
+
tui ? (renderEntry(entry, options, theme)?.render(width) ?? []) : [],
|
|
248
|
+
invalidate: () => {
|
|
249
|
+
if (entry.data) components.get(entry.data)?.invalidate();
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
const warningText = retentionWarning(entry.data);
|
|
253
|
+
let panel = components.get(entry.data);
|
|
254
|
+
if (!panel) {
|
|
255
|
+
panel = new Container();
|
|
256
|
+
for (const call of entry.data.calls) {
|
|
257
|
+
const component = new ToolExecutionComponent(
|
|
258
|
+
call.name,
|
|
259
|
+
call.id,
|
|
260
|
+
call.renderArgs ?? call.args,
|
|
261
|
+
{ showImages: true },
|
|
262
|
+
call.resultOmitted || call.omitted || !call.result
|
|
263
|
+
? undefined
|
|
264
|
+
: definitions.get(call.name),
|
|
265
|
+
tui,
|
|
266
|
+
entry.data.cwd,
|
|
267
|
+
);
|
|
268
|
+
if (call.result) component.updateResult(call.result);
|
|
269
|
+
else
|
|
270
|
+
component.updateResult({
|
|
271
|
+
content: [{ type: "text", text: "Result unavailable in this saved display." }],
|
|
272
|
+
isError: true,
|
|
273
|
+
});
|
|
274
|
+
panel.addChild(new Spacer(1));
|
|
275
|
+
panel.addChild(component);
|
|
276
|
+
}
|
|
277
|
+
if (warningText) panel.addChild(new Text(theme.fg("warning", warningText), 0, 0));
|
|
278
|
+
components.set(entry.data, panel);
|
|
212
279
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
0,
|
|
221
|
-
0,
|
|
222
|
-
),
|
|
223
|
-
);
|
|
224
|
-
components.set(entry.data, panel);
|
|
225
|
-
}
|
|
226
|
-
const warning = panel.children.at(-1);
|
|
227
|
-
if (!entry.data.complete && warning instanceof Text)
|
|
228
|
-
warning.setText(
|
|
229
|
-
theme.fg("warning", "Incomplete nested IDE presentation; some results were not retained."),
|
|
230
|
-
);
|
|
231
|
-
for (const child of panel.children)
|
|
232
|
-
if (child instanceof ToolExecutionComponent) child.setExpanded(options.expanded);
|
|
233
|
-
return panel;
|
|
234
|
-
});
|
|
280
|
+
const warning = panel.children.at(-1);
|
|
281
|
+
if (warningText && warning instanceof Text) warning.setText(theme.fg("warning", warningText));
|
|
282
|
+
for (const child of panel.children)
|
|
283
|
+
if (child instanceof ToolExecutionComponent) child.setExpanded(options.expanded);
|
|
284
|
+
return panel;
|
|
285
|
+
},
|
|
286
|
+
);
|
|
235
287
|
const finalize = () => {
|
|
236
288
|
pi.events.on(NATIVE_EDIT_BATCH_EVENT, (value) => {
|
|
237
289
|
const batch = value as NativeEditBatchEvent;
|
|
238
290
|
const group = groups.get(batch.parentToolCallId);
|
|
239
291
|
if (!group) return;
|
|
240
292
|
const details = compactMutationDetails(batch.result.details);
|
|
293
|
+
const lastChangedCall = batch.calls.findLast((id) => !batch.unchangedCopyCalls?.includes(id));
|
|
294
|
+
const callIdsByResult: readonly unknown[] =
|
|
295
|
+
"callIdsByResult" in details && Array.isArray(details.callIdsByResult)
|
|
296
|
+
? details.callIdsByResult
|
|
297
|
+
: [];
|
|
241
298
|
for (const id of batch.calls) {
|
|
242
299
|
const call = group.calls.find((call) => call.id === id);
|
|
243
300
|
if (!call) continue;
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
301
|
+
const postWriteResults =
|
|
302
|
+
details.results?.filter(
|
|
303
|
+
(result, index) =>
|
|
304
|
+
(callIdsByResult[index] === id ||
|
|
305
|
+
(callIdsByResult.length === 0 && batch.calls.length === 1)) &&
|
|
306
|
+
result.data.errors?.some(
|
|
307
|
+
(error) => error.code === "POST_WRITE_FAILED" || error.code === "POST_EDIT_FAILED",
|
|
308
|
+
),
|
|
309
|
+
) ?? [];
|
|
310
|
+
call.postWriteFailure = postWriteResults.length > 0;
|
|
311
|
+
if (call.postWriteFailure) {
|
|
312
|
+
call.batched = false;
|
|
313
|
+
delete call.renderArgs;
|
|
314
|
+
retainResult(group, call, {
|
|
315
|
+
content: batch.result.content,
|
|
316
|
+
details: { results: postWriteResults, effect: "applied" },
|
|
317
|
+
isError: true,
|
|
318
|
+
});
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
const copyResult = batch.copyResults?.get(id);
|
|
322
|
+
const rollback = copyResult?.details.metadata?.copyRollback;
|
|
323
|
+
if (
|
|
324
|
+
call.name === "copy" &&
|
|
325
|
+
copyResult &&
|
|
326
|
+
(rollback === "restored" || rollback === "failed")
|
|
327
|
+
) {
|
|
328
|
+
call.copyRollback = rollback;
|
|
329
|
+
call.batched = false;
|
|
330
|
+
retainResult(group, call, {
|
|
331
|
+
content: copyResult.content,
|
|
332
|
+
details: compactMutationDetails(copyResult.details),
|
|
333
|
+
isError: true,
|
|
334
|
+
});
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
// Keep no-op Copy outcomes; changed peers share the final batch diff.
|
|
338
|
+
call.unchangedCopy =
|
|
339
|
+
call.name === "copy" && batch.unchangedCopyCalls?.includes(id) === true;
|
|
340
|
+
call.batched = !call.unchangedCopy && id !== lastChangedCall;
|
|
341
|
+
if (call.unchangedCopy) {
|
|
342
|
+
retainResult(group, call, {
|
|
343
|
+
content: [{ type: "text", text: "No changes: destination already has this text." }],
|
|
344
|
+
details: {},
|
|
345
|
+
isError: false,
|
|
346
|
+
});
|
|
347
|
+
} else if (call.batched) call.result = undefined;
|
|
247
348
|
else {
|
|
248
349
|
// A multi-file batch has no single source: let the existing renderer label each file.
|
|
249
350
|
if (new Set(details.mutationRender?.map((resource) => resource.path)).size > 1)
|
|
250
351
|
call.renderArgs = {};
|
|
352
|
+
call.rollback =
|
|
353
|
+
details.results?.some((result) => result.data.rollback !== undefined) === true;
|
|
251
354
|
retainResult(group, call, {
|
|
252
355
|
content: batch.result.content,
|
|
253
356
|
details,
|
|
254
|
-
isError: batch.result.isError === true,
|
|
357
|
+
isError: batch.result.isError === true || call.rollback,
|
|
255
358
|
});
|
|
256
359
|
}
|
|
257
360
|
}
|
|
@@ -271,6 +374,10 @@ export function createNestedIdeRendering(pi: ExtensionAPI) {
|
|
|
271
374
|
const call = group.calls.find((call) => call.id === operation.id);
|
|
272
375
|
if (!call) continue;
|
|
273
376
|
const errors = operation.errors.map((error) => error.message);
|
|
377
|
+
// Keep precise failure effects and their custom error panels.
|
|
378
|
+
if (call.rollback || call.postWriteFailure || call.copyRollback !== undefined) continue;
|
|
379
|
+
if (call.unchangedCopy && errors.length === 0 && operation.effect === "not-applied")
|
|
380
|
+
continue;
|
|
274
381
|
if (errors.length > 0 || operation.effect !== "applied") {
|
|
275
382
|
call.batched = false;
|
|
276
383
|
delete call.renderArgs;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { createCanvas, loadImage } from "@napi-rs/canvas";
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_MAX_BYTES,
|
|
4
|
+
DEFAULT_MAX_LINES,
|
|
5
|
+
truncateHead,
|
|
6
|
+
type AgentToolResult,
|
|
7
|
+
} from "@earendil-works/pi-coding-agent";
|
|
8
|
+
|
|
9
|
+
type Content = AgentToolResult<unknown>["content"];
|
|
10
|
+
|
|
11
|
+
/** Shared useful-content budgets. Notices and composition metadata are added afterward. */
|
|
12
|
+
export const IDE_OUTPUT_LIMITS = {
|
|
13
|
+
bytes: DEFAULT_MAX_BYTES,
|
|
14
|
+
lines: DEFAULT_MAX_LINES,
|
|
15
|
+
pixels: 4_000_000,
|
|
16
|
+
images: 20,
|
|
17
|
+
imageBytes: 20 * 1024 * 1024,
|
|
18
|
+
} as const;
|
|
19
|
+
|
|
20
|
+
/** Bound the complete useful payload, not each individual content block. */
|
|
21
|
+
export async function limitIdeOutput(
|
|
22
|
+
content: Content,
|
|
23
|
+
metadata: string | readonly string[] = "",
|
|
24
|
+
saveFullOutput?: (text: string) => Promise<string>,
|
|
25
|
+
) {
|
|
26
|
+
const suffixes = typeof metadata === "string" ? [metadata] : metadata;
|
|
27
|
+
const retained: string[] = [];
|
|
28
|
+
const text = content
|
|
29
|
+
.flatMap((block) => {
|
|
30
|
+
if (block.type !== "text") return [];
|
|
31
|
+
const suffix = suffixes.find(
|
|
32
|
+
(candidate) => candidate.length > 0 && block.text.endsWith(candidate),
|
|
33
|
+
);
|
|
34
|
+
if (!suffix) return [block.text];
|
|
35
|
+
retained.push(suffix);
|
|
36
|
+
return [block.text.slice(0, -suffix.length)];
|
|
37
|
+
})
|
|
38
|
+
.join("\n");
|
|
39
|
+
const metadataSuffix = retained.join("");
|
|
40
|
+
const truncated = truncateHead(text, {
|
|
41
|
+
maxBytes: IDE_OUTPUT_LIMITS.bytes,
|
|
42
|
+
maxLines: IDE_OUTPUT_LIMITS.lines,
|
|
43
|
+
});
|
|
44
|
+
const notices: string[] = [];
|
|
45
|
+
let fullOutput: string | undefined;
|
|
46
|
+
if (truncated.truncated && saveFullOutput !== undefined) {
|
|
47
|
+
try {
|
|
48
|
+
fullOutput = await saveFullOutput(text);
|
|
49
|
+
} catch {
|
|
50
|
+
notices.push("[Full output could not be saved. Narrow the request to inspect it.]");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (truncated.truncated)
|
|
54
|
+
notices.push(
|
|
55
|
+
`[Output truncated: useful content is limited to ${IDE_OUTPUT_LIMITS.bytes} bytes / ${IDE_OUTPUT_LIMITS.lines} lines. Narrow the request or read a smaller source range.]`,
|
|
56
|
+
);
|
|
57
|
+
if (fullOutput !== undefined)
|
|
58
|
+
notices.push(
|
|
59
|
+
`[Full output: ${JSON.stringify(fullOutput)}. Read with offset/limit, or read ${JSON.stringify("raw:" + fullOutput)} for byte ranges. Available until this runtime is disposed.]`,
|
|
60
|
+
);
|
|
61
|
+
const candidates = content.filter((block) => block.type === "image");
|
|
62
|
+
const selected = candidates.slice(0, IDE_OUTPUT_LIMITS.images);
|
|
63
|
+
const images: Content = [];
|
|
64
|
+
const pixelShare = Math.floor(IDE_OUTPUT_LIMITS.pixels / Math.max(1, selected.length));
|
|
65
|
+
let bytes = 0;
|
|
66
|
+
let omitted = candidates.length - selected.length;
|
|
67
|
+
for (const [index, block] of selected.entries()) {
|
|
68
|
+
try {
|
|
69
|
+
const original = Buffer.from(block.data, "base64");
|
|
70
|
+
const decoded = await loadImage(original);
|
|
71
|
+
const scale = Math.min(1, Math.sqrt(pixelShare / (decoded.width * decoded.height)));
|
|
72
|
+
const height = Math.min(pixelShare, Math.max(1, Math.floor(decoded.height * scale)));
|
|
73
|
+
const width = Math.min(
|
|
74
|
+
Math.floor(pixelShare / height),
|
|
75
|
+
Math.max(1, Math.floor(decoded.width * scale)),
|
|
76
|
+
);
|
|
77
|
+
let data: Buffer = original;
|
|
78
|
+
let mimeType = block.mimeType;
|
|
79
|
+
if (scale < 1 || bytes + data.byteLength > IDE_OUTPUT_LIMITS.imageBytes) {
|
|
80
|
+
const canvas = createCanvas(width, height);
|
|
81
|
+
canvas.getContext("2d").drawImage(decoded, 0, 0, width, height);
|
|
82
|
+
data = await canvas.encode("png");
|
|
83
|
+
mimeType = "image/png";
|
|
84
|
+
}
|
|
85
|
+
if (bytes + data.byteLength > IDE_OUTPUT_LIMITS.imageBytes) {
|
|
86
|
+
omitted++;
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
bytes += data.byteLength;
|
|
90
|
+
images.push({ type: "image", data: data.toString("base64"), mimeType });
|
|
91
|
+
if (scale < 1)
|
|
92
|
+
notices.push(
|
|
93
|
+
`[Image ${index + 1} resized from ${decoded.width}x${decoded.height} to ${width}x${height} to fit the shared media budget.]`,
|
|
94
|
+
);
|
|
95
|
+
} catch {
|
|
96
|
+
omitted++;
|
|
97
|
+
notices.push(`[Image ${index + 1} could not be decoded and was not returned.]`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (omitted > 0)
|
|
101
|
+
notices.push(
|
|
102
|
+
`[${omitted} images omitted from the result. Read fewer frames or a smaller image region.]`,
|
|
103
|
+
);
|
|
104
|
+
return {
|
|
105
|
+
text: truncated.firstLineExceedsLimit ? bytePrefix(text) : truncated.content,
|
|
106
|
+
textTruncated: truncated.truncated,
|
|
107
|
+
images,
|
|
108
|
+
notices,
|
|
109
|
+
metadataSuffix,
|
|
110
|
+
fullOutput,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** Keep complete UTF-8 code points when even one output line exceeds the shared budget. */
|
|
115
|
+
function bytePrefix(text: string): string {
|
|
116
|
+
let bytes = 0;
|
|
117
|
+
let end = 0;
|
|
118
|
+
for (const character of text) {
|
|
119
|
+
const size = Buffer.byteLength(character);
|
|
120
|
+
if (bytes + size > IDE_OUTPUT_LIMITS.bytes) break;
|
|
121
|
+
bytes += size;
|
|
122
|
+
end += character.length;
|
|
123
|
+
}
|
|
124
|
+
return text.slice(0, end);
|
|
125
|
+
}
|