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
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { AgentToolResult } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { TextEditCompletion } from "#src/api/edit-completion.js";
|
|
3
|
+
import type { FileMutationBatchResult, FileMutationResult } from "#src/api/mutation-result.js";
|
|
4
|
+
import { mutationOutcome } from "./structured-result.js";
|
|
5
|
+
|
|
6
|
+
/** Summarize Write problems without quoting diagnostics, diffs, or file text. */
|
|
7
|
+
export function writeProblemNotices(results: readonly FileMutationResult[]): string[] {
|
|
8
|
+
const notices = new Set<string>();
|
|
9
|
+
for (const result of results) {
|
|
10
|
+
if (result.data.formatting?.status === "failed") notices.add("Formatting failed.");
|
|
11
|
+
if (
|
|
12
|
+
result.data.formatting?.status === "skipped-syntax" ||
|
|
13
|
+
result.warnings.some((warning) => warning.severity === "syntax") ||
|
|
14
|
+
result.hints.some((hint) => hint.source === "compiler" && hint.severity === "error")
|
|
15
|
+
)
|
|
16
|
+
notices.add("Syntax diagnostics detected.");
|
|
17
|
+
if (
|
|
18
|
+
result.data.diffStatuses?.some(
|
|
19
|
+
(status) =>
|
|
20
|
+
(status.tone === "warning" || status.tone === "error") &&
|
|
21
|
+
(status.formattingStatus === undefined ||
|
|
22
|
+
status.formattingStatus !== result.data.formatting?.status),
|
|
23
|
+
)
|
|
24
|
+
)
|
|
25
|
+
notices.add("Post-edit processing was interrupted or incomplete.");
|
|
26
|
+
}
|
|
27
|
+
return [...notices];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Keep the agent's file Write receipt small while retaining full renderer data and targets. */
|
|
31
|
+
export function writeAgentResult(
|
|
32
|
+
result: AgentToolResult<FileMutationBatchResult>,
|
|
33
|
+
completions: readonly TextEditCompletion[],
|
|
34
|
+
requestedPath: unknown,
|
|
35
|
+
): AgentToolResult<FileMutationBatchResult> {
|
|
36
|
+
// Terminal input and other live resources keep their own action receipts.
|
|
37
|
+
if (
|
|
38
|
+
(typeof requestedPath === "string" && requestedPath.startsWith("shell:")) ||
|
|
39
|
+
completions.some((completion) => completion.resolvedBy !== "filesystem")
|
|
40
|
+
)
|
|
41
|
+
return result;
|
|
42
|
+
const outcome = mutationOutcome(result, "write", completions);
|
|
43
|
+
// Write accepts one file. Completion metadata may also name its absolute alias.
|
|
44
|
+
const source = outcome.data?.files[0]?.source;
|
|
45
|
+
const fallback =
|
|
46
|
+
typeof requestedPath === "string" && !requestedPath.startsWith("<system-result")
|
|
47
|
+
? requestedPath
|
|
48
|
+
: undefined;
|
|
49
|
+
const status =
|
|
50
|
+
outcome.data?.effect === "applied"
|
|
51
|
+
? "Saved file."
|
|
52
|
+
: outcome.status === "success" && outcome.data?.effect === "not-applied"
|
|
53
|
+
? "No write needed."
|
|
54
|
+
: outcome.data?.effect === "unknown"
|
|
55
|
+
? "Write outcome unknown."
|
|
56
|
+
: "Write failed; no file was written.";
|
|
57
|
+
const reason = outcome.errors[0]?.message.split(/\r?\n/u)[0]?.slice(0, 200);
|
|
58
|
+
const lines = [
|
|
59
|
+
status,
|
|
60
|
+
...((source ?? fallback) ? [`Path: ${source ?? fallback}`] : []),
|
|
61
|
+
...(reason ? [`Reason: ${reason}`] : []),
|
|
62
|
+
...writeProblemNotices(result.details.results ?? []),
|
|
63
|
+
"Read the file if you need its content.",
|
|
64
|
+
];
|
|
65
|
+
return { ...result, content: [{ type: "text", text: lines.join("\n") }] };
|
|
66
|
+
}
|
|
@@ -11,18 +11,20 @@ export function sourcePathProperty(description: string) {
|
|
|
11
11
|
return Type.Optional(Type.String({ description }));
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
/** Build
|
|
15
|
-
export function sourceRangeProperties() {
|
|
14
|
+
/** Build shared source-range selectors, with optional tool-specific descriptions. */
|
|
15
|
+
export function sourceRangeProperties(descriptions: Partial<Record<"start" | "end", string>> = {}) {
|
|
16
16
|
return {
|
|
17
17
|
start: Type.Optional(
|
|
18
18
|
Type.String({
|
|
19
19
|
description:
|
|
20
|
+
descriptions.start ??
|
|
20
21
|
"Anchor or unique exact text. Alone, selects that fragment; a line anchor selects only its line. Omit when path already selects text through a supported resource reference. With end, selects a whole-line range.",
|
|
21
22
|
}),
|
|
22
23
|
),
|
|
23
24
|
end: Type.Optional(
|
|
24
25
|
Type.String({
|
|
25
26
|
description:
|
|
27
|
+
descriptions.end ??
|
|
26
28
|
"Optional anchor or unique exact text. Range includes start's first line through end's last line, even for SEARCH :match. Mixed types allowed; boundaries must be unique, in one file, and forward-ordered. Omit when start already selects the intended content; do not repeat start. The end line is included, not a stopping point before it.",
|
|
27
29
|
}),
|
|
28
30
|
),
|
|
@@ -30,10 +32,10 @@ export function sourceRangeProperties() {
|
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
/** Build the destination selectors shared by copy and move schemas. */
|
|
33
|
-
export function targetProperties() {
|
|
35
|
+
export function targetProperties(directorySemantics: string) {
|
|
34
36
|
return {
|
|
35
37
|
target: resultSourceProperty(
|
|
36
|
-
|
|
38
|
+
`Destination path, unchanged source result or its UUID. A result replaces its exact ranges (zero-width ranges insert); omit targetStart/targetEnd. Source and destination selections pair in declared order with equal counts. A path with text selectors keeps its existing anchor semantics. Whole-object transfers create missing parents and replace regular destination files. ${directorySemantics} Reject symlink destinations, type conflicts, and overlapping directory trees.`,
|
|
37
39
|
),
|
|
38
40
|
targetStart: Type.Optional(
|
|
39
41
|
Type.String({
|
|
@@ -18,10 +18,12 @@ import type { TextMutationToolRegistration } from "#src/api/mutation-tool.js";
|
|
|
18
18
|
export const copySchema = Type.Object(
|
|
19
19
|
{
|
|
20
20
|
path: resultSourceProperty(
|
|
21
|
-
"
|
|
21
|
+
"Filesystem source path, unchanged source result or its UUID; omit start/end for result inputs. Use ordinary paths without selectors to copy whole files, directory trees, or symlink objects without following their targets. Use one whole-file result when the destination is a file path without text selectors. Source/destination selections pair in declared order, with equal counts and duplicate ranges removed.",
|
|
22
22
|
),
|
|
23
23
|
...sourceRangeProperties(),
|
|
24
|
-
...targetProperties(
|
|
24
|
+
...targetProperties(
|
|
25
|
+
"Directory Copy merges into the exact target path and retains destination-only entries.",
|
|
26
|
+
),
|
|
25
27
|
},
|
|
26
28
|
{ additionalProperties: false },
|
|
27
29
|
);
|
|
@@ -38,9 +40,9 @@ export const copyMutationTool: TextMutationToolRegistration<typeof copySchema> =
|
|
|
38
40
|
name: "copy",
|
|
39
41
|
wholeFileOperation: "copy",
|
|
40
42
|
description:
|
|
41
|
-
"Use copy to copy
|
|
43
|
+
"Use copy to copy a file, directory tree, or symlink object, or to duplicate selected text within or between files.",
|
|
42
44
|
|
|
43
|
-
promptSnippet: "Copy
|
|
45
|
+
promptSnippet: "Copy filesystem objects or selected text",
|
|
44
46
|
parameters: copySchema,
|
|
45
47
|
source: { field: "path", inherited: true, targets: [{ field: "target", fallbackTo: "path" }] },
|
|
46
48
|
anchors: [
|
|
@@ -77,7 +79,11 @@ export const copyMutationTool: TextMutationToolRegistration<typeof copySchema> =
|
|
|
77
79
|
const targetStarts = await context.resolveAnchors("targetStart");
|
|
78
80
|
if (parameters.targetEnd === undefined) {
|
|
79
81
|
const [target, change] = insertionAfterAnchor(context, targetStarts, "targetStart", copied);
|
|
80
|
-
return {
|
|
82
|
+
return {
|
|
83
|
+
edits: new Map([
|
|
84
|
+
[target, { changes: [{ ...change, allowUnchanged: true }], action: "edited" }],
|
|
85
|
+
]),
|
|
86
|
+
};
|
|
81
87
|
}
|
|
82
88
|
|
|
83
89
|
const targetEnds = await context.resolveAnchors("targetEnd");
|
|
@@ -92,7 +98,10 @@ export const copyMutationTool: TextMutationToolRegistration<typeof copySchema> =
|
|
|
92
98
|
edits: new Map([
|
|
93
99
|
[
|
|
94
100
|
targetSpan.source,
|
|
95
|
-
{
|
|
101
|
+
{
|
|
102
|
+
changes: [{ ...replaceAnchorSpan(context, targetSpan, copied), allowUnchanged: true }],
|
|
103
|
+
action: "edited",
|
|
104
|
+
},
|
|
96
105
|
],
|
|
97
106
|
]),
|
|
98
107
|
};
|
|
@@ -18,9 +18,13 @@ import type { TextMutationToolRegistration } from "#src/api/mutation-tool.js";
|
|
|
18
18
|
export const deleteSchema = Type.Object(
|
|
19
19
|
{
|
|
20
20
|
path: resultSourceProperty(
|
|
21
|
-
"
|
|
21
|
+
"Filesystem path, shell:<session>, debug:<session>, debug:<session>/breakpoint/<id>, unchanged source result or its UUID, or an array of results. An ordinary filesystem path without start/end deletes the object: directories recursively, symlinks only as links. A text result input removes only selected text and keeps the file, even for a whole-file selection. For Read results from symbol:<file>#<selector>, deletion removes only the declaration text; imports and references are unchanged. Omit start/end for result inputs. Omit path when a supplied text anchor identifies the file.",
|
|
22
22
|
),
|
|
23
|
-
...sourceRangeProperties(
|
|
23
|
+
...sourceRangeProperties({
|
|
24
|
+
start:
|
|
25
|
+
"Anchor or unique exact text locating the text to remove. Without end, exact text selects only that fragment; a line anchor selects its whole line. Omit when path already selects text.",
|
|
26
|
+
end: "Anchor or unique exact text locating the last line to remove. With start, removes whole lines including both boundary lines, even for SEARCH :match anchors. Both boundaries must be unique, in one file, and in forward order. Mixed anchor types are allowed. Omit when start alone selects the intended text.",
|
|
27
|
+
}),
|
|
24
28
|
},
|
|
25
29
|
{ additionalProperties: false },
|
|
26
30
|
);
|
|
@@ -34,9 +38,10 @@ export const deleteMutationTool: TextMutationToolRegistration<typeof deleteSchem
|
|
|
34
38
|
name: "delete",
|
|
35
39
|
wholeFileOperation: "delete",
|
|
36
40
|
description:
|
|
37
|
-
"Use delete to
|
|
41
|
+
"Use delete to remove selected text, permanently delete a file or directory, unlink a symlink, terminate a terminal or debugger session, or remove a debugger breakpoint.",
|
|
38
42
|
|
|
39
|
-
promptSnippet:
|
|
43
|
+
promptSnippet:
|
|
44
|
+
"Delete files or selected text, terminate terminal or debugger sessions, or remove debugger breakpoints",
|
|
40
45
|
parameters: deleteSchema,
|
|
41
46
|
source: { field: "path", inherited: true },
|
|
42
47
|
anchors: [
|
|
@@ -15,30 +15,30 @@ export const insertSchema = Type.Object(
|
|
|
15
15
|
path: Type.Optional(
|
|
16
16
|
Type.String({
|
|
17
17
|
description:
|
|
18
|
-
"
|
|
18
|
+
"Pass a file path, source resource reference, unchanged Read/Search/Select/edit result, or its UUID. Result inputs select only their registered ranges.",
|
|
19
19
|
}),
|
|
20
20
|
),
|
|
21
21
|
anchor: Type.Optional(
|
|
22
22
|
Type.String({
|
|
23
23
|
description:
|
|
24
|
-
"
|
|
24
|
+
"For text edits, use a registered anchor or unique exact text to locate the insertion. Omit anchor when path already supplies the intended selection; otherwise it is required. For live resources, follow the action rules above.",
|
|
25
25
|
}),
|
|
26
26
|
),
|
|
27
27
|
text: Type.String({
|
|
28
28
|
minLength: 1,
|
|
29
29
|
description:
|
|
30
|
-
"
|
|
30
|
+
"For text edits, supply non-empty new text. The tool adds missing line breaks between the insertion and existing text. Add a leading newline only for an intentional blank line, not to start a new line. Payload newlines are kept, with line endings converted to the file's LF/CRLF style. No trailing newline is added at EOF.",
|
|
31
31
|
}),
|
|
32
32
|
separation: Type.Optional(
|
|
33
33
|
Type.Union([Type.Literal("line"), Type.Literal("blank-line")], {
|
|
34
34
|
description:
|
|
35
|
-
"
|
|
35
|
+
"For text edits, defaults to line: separate inserted text from existing lines without adding extra blank lines. Use blank-line to add only missing blank lines between the insertion and existing text.",
|
|
36
36
|
}),
|
|
37
37
|
),
|
|
38
38
|
before: Type.Optional(
|
|
39
39
|
Type.Boolean({
|
|
40
40
|
description:
|
|
41
|
-
"
|
|
41
|
+
"For text edits, defaults to false: insert after the last containing line of each selection. With true, insert before its first containing line. Selected text is kept. Multiple selections on the same insertion line produce one insertion.",
|
|
42
42
|
}),
|
|
43
43
|
),
|
|
44
44
|
},
|
|
@@ -56,10 +56,9 @@ interface InsertParameters {
|
|
|
56
56
|
export const insertMutationTool: TextMutationToolRegistration<typeof insertSchema> = {
|
|
57
57
|
name: "insert",
|
|
58
58
|
description:
|
|
59
|
-
"Use insert to add new text before or after selected lines while keeping existing text. Insertion is line-based, including for exact-text and SEARCH :match anchors.",
|
|
59
|
+
"Use insert to edit text or act on a live resource. For text edits, add new text before or after selected lines while keeping existing text. Insertion is line-based, including for exact-text and SEARCH :match anchors. An empty result selection makes no changes and is not an error.",
|
|
60
60
|
|
|
61
|
-
promptSnippet:
|
|
62
|
-
"Make precise file edits by inserting text before or after exact matches or anchors",
|
|
61
|
+
promptSnippet: "Insert file text, send terminal keys, or perform debugger actions",
|
|
63
62
|
parameters: insertSchema,
|
|
64
63
|
source: { field: "path", inherited: true },
|
|
65
64
|
anchors: [
|
|
@@ -20,10 +20,12 @@ import type { TextChange } from "#src/core/text-change-engine.js";
|
|
|
20
20
|
export const moveSchema = Type.Object(
|
|
21
21
|
{
|
|
22
22
|
path: resultSourceProperty(
|
|
23
|
-
"
|
|
23
|
+
"Filesystem source path, unchanged source result or its UUID; omit start/end for result inputs. Use ordinary paths without selectors to move whole files, directory trees, or symlink objects without following their targets. Use one whole-file result when the destination is a file path without text selectors. Source/destination selections pair in declared order, with equal counts and duplicate ranges removed. Destinations must not overlap or touch source ranges.",
|
|
24
24
|
),
|
|
25
25
|
...sourceRangeProperties(),
|
|
26
|
-
...targetProperties(
|
|
26
|
+
...targetProperties(
|
|
27
|
+
"Directory Move replaces the exact target directory, removing destination-only entries.",
|
|
28
|
+
),
|
|
27
29
|
},
|
|
28
30
|
{ additionalProperties: false },
|
|
29
31
|
);
|
|
@@ -40,9 +42,9 @@ export const moveMutationTool: TextMutationToolRegistration<typeof moveSchema> =
|
|
|
40
42
|
name: "move",
|
|
41
43
|
wholeFileOperation: "move",
|
|
42
44
|
description:
|
|
43
|
-
"Use move to move or rename
|
|
45
|
+
"Use move to move or rename a file, directory tree, or symlink object, or to relocate selected text within or between files.",
|
|
44
46
|
|
|
45
|
-
promptSnippet: "Move
|
|
47
|
+
promptSnippet: "Move filesystem objects or selected text",
|
|
46
48
|
parameters: moveSchema,
|
|
47
49
|
source: { field: "path", inherited: true, targets: [{ field: "target", fallbackTo: "path" }] },
|
|
48
50
|
anchors: [
|
|
@@ -23,7 +23,7 @@ export const replaceSchema = Type.Object(
|
|
|
23
23
|
...sourceRangeProperties(),
|
|
24
24
|
text: Type.String({
|
|
25
25
|
description:
|
|
26
|
-
"Replacement text. Empty text removes the selection; a whole-line selection removes its lines without inserting a blank line. Adjacent unselected lines are kept.",
|
|
26
|
+
"Replacement text for each selected range. Empty text removes the selection; a whole-line selection removes its lines without inserting a blank line. Adjacent unselected lines are kept.",
|
|
27
27
|
}),
|
|
28
28
|
},
|
|
29
29
|
{ additionalProperties: false },
|
|
@@ -37,8 +37,7 @@ interface ReplaceParameters {
|
|
|
37
37
|
|
|
38
38
|
export const replaceMutationTool: TextMutationToolRegistration<typeof replaceSchema> = {
|
|
39
39
|
name: "replace",
|
|
40
|
-
description:
|
|
41
|
-
"Use replace to change an existing text fragment, an inclusive line range, or every selected search match.",
|
|
40
|
+
description: "Use replace to replace a text fragment or each selected range.",
|
|
42
41
|
|
|
43
42
|
promptSnippet: "Make precise file edits by replacing text using exact matches or anchors",
|
|
44
43
|
parameters: replaceSchema,
|
|
@@ -8,9 +8,12 @@ export const writeSchema = Type.Object(
|
|
|
8
8
|
path: {
|
|
9
9
|
...resultInputSchema,
|
|
10
10
|
description:
|
|
11
|
-
"
|
|
11
|
+
"File path or one whole-file source result. Partial file scopes and multiple files are rejected. Use shell:<session> to send input to a running terminal.",
|
|
12
12
|
},
|
|
13
|
-
content: Type.String({
|
|
13
|
+
content: Type.String({
|
|
14
|
+
description:
|
|
15
|
+
"Complete file contents, or exact terminal input. Terminal input does not add Enter.",
|
|
16
|
+
}),
|
|
14
17
|
},
|
|
15
18
|
{ additionalProperties: false },
|
|
16
19
|
);
|
|
@@ -23,7 +26,7 @@ interface WriteParameters {
|
|
|
23
26
|
export const writeMutationTool: TextMutationToolRegistration<typeof writeSchema> = {
|
|
24
27
|
name: "write",
|
|
25
28
|
description:
|
|
26
|
-
"Use write to create
|
|
29
|
+
"Use write to create or deliberately overwrite a whole file, or send input to a running terminal.",
|
|
27
30
|
|
|
28
31
|
promptSnippet: "Create or overwrite files",
|
|
29
32
|
parameters: writeSchema,
|
|
@@ -34,7 +37,10 @@ export const writeMutationTool: TextMutationToolRegistration<typeof writeSchema>
|
|
|
34
37
|
[
|
|
35
38
|
context.sourceFor("path"),
|
|
36
39
|
{
|
|
37
|
-
changes:
|
|
40
|
+
changes:
|
|
41
|
+
context.sourceDocument.content === parameters.content
|
|
42
|
+
? []
|
|
43
|
+
: [context.sourceDocument.replaceAll(parameters.content)],
|
|
38
44
|
action: "overwritten",
|
|
39
45
|
},
|
|
40
46
|
],
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-text-editor-renderer",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"diff": "^9.0.0",
|
|
10
|
-
"pi-agent-invariant": "0.7.
|
|
11
|
-
"pi-agent-text-editor": "0.7.
|
|
12
|
-
"pi-agent-tool-call-interception": "0.7.
|
|
13
|
-
"pi-agent-tool-ui": "0.7.
|
|
10
|
+
"pi-agent-invariant": "0.7.3",
|
|
11
|
+
"pi-agent-text-editor": "0.7.3",
|
|
12
|
+
"pi-agent-tool-call-interception": "0.7.3",
|
|
13
|
+
"pi-agent-tool-ui": "0.7.3",
|
|
14
14
|
"vscode-diff": "3.0.1"
|
|
15
15
|
},
|
|
16
16
|
"pi": {
|
|
@@ -317,6 +317,17 @@ function renderTail(
|
|
|
317
317
|
: `Formatted ${grouped.formatted.length} files by ${by}`;
|
|
318
318
|
statuses.unshift(theme.fg("success", label.replace(/[\u0000-\u001f\u007f-\u009f]/g, " ")));
|
|
319
319
|
}
|
|
320
|
+
if (grouped.alreadyFormatted.length > 0) {
|
|
321
|
+
const by =
|
|
322
|
+
grouped.unchangedFormatters.length === 1
|
|
323
|
+
? grouped.unchangedFormatters[0]
|
|
324
|
+
: `${grouped.unchangedFormatters.length} formatters`;
|
|
325
|
+
const label =
|
|
326
|
+
resources.length === 1
|
|
327
|
+
? `Already formatted (${by})`
|
|
328
|
+
: `Already formatted ${grouped.alreadyFormatted.length} files by ${by}`;
|
|
329
|
+
statuses.unshift(theme.fg("success", label.replace(/[\u0000-\u001f\u007f-\u009f]/g, " ")));
|
|
330
|
+
}
|
|
320
331
|
const text = [counts, ...statuses]
|
|
321
332
|
.filter((item) => item !== undefined)
|
|
322
333
|
.join(theme.fg("dim", " · "));
|
|
@@ -251,7 +251,17 @@ function createRenderer(
|
|
|
251
251
|
options.expanded,
|
|
252
252
|
theme,
|
|
253
253
|
);
|
|
254
|
-
return new Text(
|
|
254
|
+
return new Text(
|
|
255
|
+
registration.name === "copy" &&
|
|
256
|
+
typeof result.details.metadata?.targetUnavailable === "string"
|
|
257
|
+
? theme.fg(
|
|
258
|
+
"muted",
|
|
259
|
+
"No verified text selection. Read the destination before further edits.",
|
|
260
|
+
)
|
|
261
|
+
: "",
|
|
262
|
+
0,
|
|
263
|
+
0,
|
|
264
|
+
);
|
|
255
265
|
}
|
|
256
266
|
|
|
257
267
|
clearTypingRuntime(state);
|
|
@@ -272,14 +282,33 @@ function createRenderer(
|
|
|
272
282
|
state.panel?.setPreviewResources([]);
|
|
273
283
|
|
|
274
284
|
if (!context.isError && result.details.metadata?.emptyTargets === true) {
|
|
275
|
-
return new Text(
|
|
285
|
+
return new Text(
|
|
286
|
+
theme.fg(
|
|
287
|
+
"muted",
|
|
288
|
+
registration.name === "copy"
|
|
289
|
+
? "No changes: empty selection."
|
|
290
|
+
: "No changes · empty target set",
|
|
291
|
+
),
|
|
292
|
+
0,
|
|
293
|
+
0,
|
|
294
|
+
);
|
|
276
295
|
}
|
|
277
|
-
const
|
|
278
|
-
if (
|
|
296
|
+
const wholeFileEffect = wholeFileOperationEffect(result.details);
|
|
297
|
+
if (wholeFileEffect !== undefined) {
|
|
298
|
+
const applied = wholeFileEffect === "applied";
|
|
299
|
+
const unknown = wholeFileEffect === "unknown";
|
|
300
|
+
const affected = registration.name === "delete" ? "the source" : "source and destination";
|
|
279
301
|
return new Text(
|
|
280
302
|
theme.fg(
|
|
281
|
-
|
|
282
|
-
|
|
303
|
+
unknown ? "warning" : applied ? "success" : "error",
|
|
304
|
+
unknown
|
|
305
|
+
? `Effects unknown · ${registration.name} failed; read ${affected} before retrying`
|
|
306
|
+
: applied
|
|
307
|
+
? registration.name === "copy" &&
|
|
308
|
+
typeof result.details.metadata?.targetUnavailable === "string"
|
|
309
|
+
? "✓ Applied · no verified text selection; read destination before further edits"
|
|
310
|
+
: "✓ Applied"
|
|
311
|
+
: "✗ Not applied",
|
|
283
312
|
),
|
|
284
313
|
0,
|
|
285
314
|
0,
|
|
@@ -292,7 +321,19 @@ function createRenderer(
|
|
|
292
321
|
)
|
|
293
322
|
.map((item) => item.text)
|
|
294
323
|
.join("\n");
|
|
295
|
-
const
|
|
324
|
+
const rollback =
|
|
325
|
+
registration.name === "copy" ? result.details.metadata?.copyRollback : undefined;
|
|
326
|
+
const uncertainExecution =
|
|
327
|
+
registration.name === "copy" && result.details.metadata?.copyExecution === "uncertain";
|
|
328
|
+
const displayedOutput = context.isError
|
|
329
|
+
? uncertainExecution
|
|
330
|
+
? "Copy failed · effects uncertain; read destination before retrying"
|
|
331
|
+
: rollback === "restored"
|
|
332
|
+
? "Copy failed · changes rolled back"
|
|
333
|
+
: rollback === "failed"
|
|
334
|
+
? "Copy failed · rollback failed; read destination before retrying"
|
|
335
|
+
: userFacingFailure(output, result.details)
|
|
336
|
+
: output;
|
|
296
337
|
return new Text(
|
|
297
338
|
displayedOutput.length === 0
|
|
298
339
|
? ""
|
|
@@ -856,19 +897,42 @@ function semanticRange(start: string, end: string): string {
|
|
|
856
897
|
: `${start}–${end}`;
|
|
857
898
|
}
|
|
858
899
|
|
|
859
|
-
function
|
|
900
|
+
function wholeFileOperationEffect(
|
|
901
|
+
details: unknown,
|
|
902
|
+
): "applied" | "not-applied" | "unknown" | undefined {
|
|
860
903
|
if (details === null || typeof details !== "object" || !("metadata" in details)) return undefined;
|
|
861
904
|
const metadata = details.metadata;
|
|
862
905
|
if (metadata === null || typeof metadata !== "object" || !("semanticAction" in metadata))
|
|
863
906
|
return undefined;
|
|
864
907
|
const action = metadata.semanticAction;
|
|
865
908
|
if (action === null || typeof action !== "object" || !("kind" in action)) return undefined;
|
|
866
|
-
|
|
867
|
-
|
|
909
|
+
if (action.kind !== "file-operation" || !("effect" in action)) return undefined;
|
|
910
|
+
return action.effect === "applied" ||
|
|
911
|
+
action.effect === "not-applied" ||
|
|
912
|
+
action.effect === "unknown"
|
|
913
|
+
? action.effect
|
|
868
914
|
: undefined;
|
|
869
915
|
}
|
|
870
916
|
|
|
871
|
-
function userFacingFailure(
|
|
917
|
+
function userFacingFailure(
|
|
918
|
+
agentOutput: string,
|
|
919
|
+
details: FileMutationBatchResult | undefined,
|
|
920
|
+
): string {
|
|
921
|
+
const rollbacks =
|
|
922
|
+
details?.results?.flatMap((result) => (result.data.rollback ? [result.data.rollback] : [])) ??
|
|
923
|
+
[];
|
|
924
|
+
if (rollbacks.length > 0) {
|
|
925
|
+
const failed = [...new Set(rollbacks.flatMap((rollback) => rollback.failedSources))];
|
|
926
|
+
const restored = [...new Set(rollbacks.flatMap((rollback) => rollback.restoredSources))];
|
|
927
|
+
return [
|
|
928
|
+
failed.length === 0 ? "Rolled back · write failed" : "State unknown · rollback failed",
|
|
929
|
+
...(failed.length > 0 ? [`Unknown: ${failed.join(", ")}`] : []),
|
|
930
|
+
...(restored.length > 0 ? [`Rolled back: ${restored.join(", ")}`] : []),
|
|
931
|
+
].join("\n");
|
|
932
|
+
}
|
|
933
|
+
if (details?.effect === "unknown") return "Effects unknown · edit failed";
|
|
934
|
+
if (details?.effect === "applied") return "Saved · post-write step failed";
|
|
935
|
+
if (details?.metadata?.rollback === "restored") return "Rolled back · edit failed";
|
|
872
936
|
if (/\banchor\b[\s\S]*\bis ambiguous\./iu.test(agentOutput)) {
|
|
873
937
|
return "Not changed · selection is ambiguous";
|
|
874
938
|
}
|
|
@@ -9,12 +9,25 @@ export function summarizeStatuses(
|
|
|
9
9
|
) {
|
|
10
10
|
const formatted = new Set<string>();
|
|
11
11
|
const formatters = new Set<string>();
|
|
12
|
+
const alreadyFormatted = new Set<string>();
|
|
13
|
+
const unchangedFormatters = new Set<string>();
|
|
12
14
|
const remaining = new Map<string, { status: MutationDiffStatus; paths: Set<string> }>();
|
|
13
15
|
for (const resource of resources)
|
|
14
16
|
for (const status of resource.diffStatuses ?? []) {
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
if (
|
|
18
|
+
status.formatter !== undefined &&
|
|
19
|
+
status.tone === "success" &&
|
|
20
|
+
(status.formattingStatus === undefined ||
|
|
21
|
+
status.formattingStatus === "changed" ||
|
|
22
|
+
status.formattingStatus === "unchanged")
|
|
23
|
+
) {
|
|
24
|
+
if (status.formattingStatus === "unchanged") {
|
|
25
|
+
alreadyFormatted.add(resource.path);
|
|
26
|
+
unchangedFormatters.add(status.formatter);
|
|
27
|
+
} else {
|
|
28
|
+
formatted.add(resource.path);
|
|
29
|
+
formatters.add(status.formatter);
|
|
30
|
+
}
|
|
18
31
|
continue;
|
|
19
32
|
}
|
|
20
33
|
const key = JSON.stringify([status.text, status.tone]);
|
|
@@ -28,6 +41,8 @@ export function summarizeStatuses(
|
|
|
28
41
|
return {
|
|
29
42
|
formatted: [...formatted],
|
|
30
43
|
formatters: [...formatters],
|
|
44
|
+
alreadyFormatted: [...alreadyFormatted],
|
|
45
|
+
unchangedFormatters: [...unchangedFormatters],
|
|
31
46
|
statuses: [...remaining.values()].map(({ status, paths }) => ({ status, paths: [...paths] })),
|
|
32
47
|
};
|
|
33
48
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-text-editor-stale-anchor",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"pi-agent-invariant": "0.7.
|
|
7
|
-
"pi-agent-read": "0.7.
|
|
8
|
-
"pi-agent-text-editor": "0.7.
|
|
6
|
+
"pi-agent-invariant": "0.7.3",
|
|
7
|
+
"pi-agent-read": "0.7.3",
|
|
8
|
+
"pi-agent-text-editor": "0.7.3"
|
|
9
9
|
},
|
|
10
10
|
"pi": {
|
|
11
11
|
"extensions": [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-tool-call-interception",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./src/index.ts",
|
|
6
6
|
"exports": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"pi-agent-tool-ui": "0.7.
|
|
13
|
+
"pi-agent-tool-ui": "0.7.3"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"@earendil-works/pi-coding-agent": "*",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-web",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"defuddle": "^0.19.1",
|
|
10
10
|
"linkedom": "^0.18.12",
|
|
11
|
-
"pi-agent-doctor": "0.7.
|
|
12
|
-
"pi-agent-image": "0.7.
|
|
13
|
-
"pi-agent-read": "0.7.
|
|
14
|
-
"pi-agent-resource": "0.7.
|
|
15
|
-
"pi-agent-search": "0.7.
|
|
16
|
-
"pi-agent-text": "0.7.
|
|
11
|
+
"pi-agent-doctor": "0.7.3",
|
|
12
|
+
"pi-agent-image": "0.7.3",
|
|
13
|
+
"pi-agent-read": "0.7.3",
|
|
14
|
+
"pi-agent-resource": "0.7.3",
|
|
15
|
+
"pi-agent-search": "0.7.3",
|
|
16
|
+
"pi-agent-text": "0.7.3",
|
|
17
17
|
"playwright-core": "^1.62.1"
|
|
18
18
|
},
|
|
19
19
|
"pi": {
|
|
@@ -261,7 +261,8 @@ function formatUnsupportedBinaryResponse(
|
|
|
261
261
|
preview: Uint8Array,
|
|
262
262
|
): string {
|
|
263
263
|
const lines = [
|
|
264
|
-
"
|
|
264
|
+
"Unsupported binary response",
|
|
265
|
+
"Read cannot convert this Content-Type. Showing response metadata and a byte preview, not document text.",
|
|
265
266
|
`URL: ${requestedUrl.href}`,
|
|
266
267
|
`HTTP: ${response.status} ${response.statusText}`.trimEnd(),
|
|
267
268
|
`Content-Type: ${mediaType ?? "unknown"}`,
|
|
@@ -271,18 +272,15 @@ function formatUnsupportedBinaryResponse(
|
|
|
271
272
|
if (filename !== undefined) lines.push(`Filename: ${filename}`);
|
|
272
273
|
const length = response.headers.get("content-length");
|
|
273
274
|
if (length !== null) lines.push(`Content-Length: ${length}`);
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
lines.push(
|
|
282
|
-
|
|
283
|
-
`Preview: first ${preview.length} bytes (hex); the remaining body was not downloaded`,
|
|
284
|
-
formatHexPreview(preview),
|
|
285
|
-
);
|
|
275
|
+
const headers = [...response.headers]
|
|
276
|
+
.filter(
|
|
277
|
+
([name]) =>
|
|
278
|
+
!isSensitiveRedirectHeader(name) && name !== "content-type" && name !== "content-length",
|
|
279
|
+
)
|
|
280
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
281
|
+
.map(([name, value]) => `${name}: ${value}`);
|
|
282
|
+
if (headers.length > 0) lines.push("", "Headers:", ...headers);
|
|
283
|
+
lines.push("", `Preview: first ${preview.length} bytes (hex).`, formatHexPreview(preview));
|
|
286
284
|
return lines.join("\n");
|
|
287
285
|
}
|
|
288
286
|
|