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
|
@@ -32,9 +32,9 @@ export function formatAgentTerminalSnapshot(snapshot: TerminalSessionSnapshot):
|
|
|
32
32
|
snapshot.completionReason === undefined
|
|
33
33
|
? undefined
|
|
34
34
|
: `completionReason: ${snapshot.completionReason}`,
|
|
35
|
-
snapshot.
|
|
36
|
-
?
|
|
37
|
-
:
|
|
35
|
+
snapshot.status === "running" && snapshot.background
|
|
36
|
+
? `next: Continue independent work or finish your turn; completion or a one-time idle inspection notice will wake the agent. Read ${snapshot.source} to inspect output; use write or insert when input is needed.`
|
|
37
|
+
: undefined,
|
|
38
38
|
`outputRange: ${snapshot.outputStart}-${snapshot.outputEnd}`,
|
|
39
39
|
snapshot.truncated ? "retainedOutput: earlier data omitted from memory" : undefined,
|
|
40
40
|
truncation.truncated ? `fullOutput: ${snapshot.fullOutputPath}` : undefined,
|
|
@@ -34,7 +34,7 @@ const createRunParameters = (profile: ShellProfile) =>
|
|
|
34
34
|
background: Type.Optional(
|
|
35
35
|
Type.Boolean({
|
|
36
36
|
description:
|
|
37
|
-
"
|
|
37
|
+
"Set true to return after an initial output preview instead of waiting for completion. Defaults to false.",
|
|
38
38
|
}),
|
|
39
39
|
),
|
|
40
40
|
timeoutSeconds: Type.Optional(
|
|
@@ -42,7 +42,7 @@ const createRunParameters = (profile: ShellProfile) =>
|
|
|
42
42
|
minimum: 0.1,
|
|
43
43
|
maximum: 86_400,
|
|
44
44
|
description:
|
|
45
|
-
"
|
|
45
|
+
"Set the foreground wait limit in seconds. On expiry, the live session returns in background without stopping the process. Ignored when background is true. Defaults to 60.",
|
|
46
46
|
}),
|
|
47
47
|
),
|
|
48
48
|
cwd: Type.Optional(
|
|
@@ -91,7 +91,7 @@ export function registerTerminalTools(
|
|
|
91
91
|
promptGuidelines: [
|
|
92
92
|
`Do not use ${toolName} commands or scripts to edit files. Use the standalone editing tools instead. Commands that inherently generate files, such as formatters and code generators, are allowed.`,
|
|
93
93
|
],
|
|
94
|
-
description: `Use ${toolName} to execute a command in the user's configured
|
|
94
|
+
description: `Use ${toolName} to execute a command in the user's configured shell. Each call creates a new terminal session and returns its shell: source for inspection and interaction.`,
|
|
95
95
|
parameters: runParameters,
|
|
96
96
|
outputSchema: shellOutputSchema,
|
|
97
97
|
async execute(_toolCallId, input, signal, onUpdate, context) {
|
package/src/post-edit/gate.ts
CHANGED
|
@@ -47,13 +47,24 @@ export async function runIdePostEditGate(
|
|
|
47
47
|
}
|
|
48
48
|
: {
|
|
49
49
|
diffStatuses: [
|
|
50
|
-
{
|
|
50
|
+
{
|
|
51
|
+
text: `Formatting failed (${formatterName})`,
|
|
52
|
+
formatter: formatterName,
|
|
53
|
+
tone: "error" as const,
|
|
54
|
+
},
|
|
51
55
|
],
|
|
52
56
|
}),
|
|
53
57
|
};
|
|
54
58
|
} catch {
|
|
55
59
|
return {
|
|
56
|
-
diffStatuses: [
|
|
60
|
+
diffStatuses: [
|
|
61
|
+
{
|
|
62
|
+
text: "Formatting failed",
|
|
63
|
+
tone: "error" as const,
|
|
64
|
+
formattingStatus: "failed",
|
|
65
|
+
...(formatterName === undefined ? {} : { formatter: formatterName }),
|
|
66
|
+
},
|
|
67
|
+
],
|
|
57
68
|
formatting: {
|
|
58
69
|
status: "failed",
|
|
59
70
|
...(formatterName === undefined ? {} : { formatter: formatterName }),
|
package/dist/chunk-4XMY4H4V.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as k,e as S,h as m,i as M}from"./chunk-CWD4O5PM.js";import{a as p}from"./chunk-EI7MMDWY.js";import{Type as t}from"typebox";var T=t.Union([t.Literal("pending"),t.Literal("applied"),t.Literal("not-applied"),t.Literal("unknown")]),b=t.Object({source:t.String(),effect:T,state:t.Optional(t.Union([t.Literal("present"),t.Literal("absent"),t.Literal("unknown")]))},{additionalProperties:!1}),O={effect:T,files:t.Array(b)};function R(s){return t.Object({operation:t.Literal(s),...O,operationId:t.Optional(t.String()),...s==="delete"||s==="flush"?{}:{target:t.Optional(t.String()),targetUnavailable:t.Optional(t.String())}},{additionalProperties:!1})}p(R,"mutationDataSchema");function N(s){return S(R(s))}p(N,"mutationResultSchema");var U=t.Object({id:t.String(),operation:t.String(),effect:T,errors:t.Array(k)},{additionalProperties:!1}),D=t.Object({operation:t.Literal("flush"),...O,operations:t.Array(U)},{additionalProperties:!1}),_=S(D);function u(s){return typeof s=="object"&&s!==null}p(u,"record");function F(s,i,h=[]){let r=s.details,l=u(r)?r:{};if((u(r)&&u(r.nativeEditBatch)?r.nativeEditBatch:void 0)?.state==="accepted")return{status:"success",errors:[],data:{operation:i,effect:"pending",...i!=="delete"&&typeof r.metadata?.resultTarget=="string"?{target:r.metadata.resultTarget}:{},files:typeof l.source=="string"?[{source:l.source,effect:"pending"}]:[]}};let g=new Set(h.map(e=>e.resourceSource)),n=[],f=[],E=r.results;for(let e of E??[]){let o=e.data,y=[...new Set([...(o.files??[]).map(c=>c.path),...o.path?[o.path]:[]])];for(let c of y)f.push({source:c,...g.has(c)?{state:"present"}:{},effect:g.has(c)||o.ok===!0&&o.files?.some(L=>L.path===c)?"applied":r.effect??"unknown"});for(let c of o.errors??[])n.push({code:c.code??"MUTATION_FAILED",message:c.reason??"Mutation failed",source:c.path});o.ok===!1&&(o.errors?.length??0)===0&&n.push({code:"MUTATION_FAILED",message:"Mutation failed",...o.path?{source:o.path}:{}})}for(let e of g)f.some(o=>o.source===e)||f.push({source:e,effect:"applied",state:"present"});let a=u(r.metadata)&&u(r.metadata.semanticAction)?r.metadata.semanticAction:void 0;if(a){let e=a.effect==="not-applied"||a.effect==="unknown"?a.effect:a.ok===!1?"unknown":"applied",o=typeof a.source=="string"?a.source:void 0;o&&f.push({source:o,...a.kind==="file-operation"&&a.ok===!0?{state:i==="delete"||i==="move"?"absent":"present"}:{},effect:i==="copy"&&typeof a.target=="string"&&a.target!==o?"not-applied":e}),typeof a.target=="string"&&f.push({source:a.target,effect:e,...a.kind==="file-operation"&&a.ok===!0?{state:"present"}:{}}),u(a.error)&&n.push(m(a.error.message,typeof a.error.code=="string"?a.error.code:"MUTATION_FAILED",o)),typeof a.postProcessingError=="string"&&n.push(m(a.postProcessingError,"POST_EDIT_FAILED",o)),a.ok===!1&&n.length===0&&n.push(m("Resource operation failed","MUTATION_FAILED",o))}let d=[...new Map(f.map(e=>[e.source,e])).values()];if(Array.isArray(r.metadata?.resultFileStates))for(let e of r.metadata.resultFileStates){if(!u(e))continue;let o=d.find(y=>y.source===e.source);o&&(e.state==="present"||e.state==="absent")&&(o.state=e.state)}let A=d.some(e=>e.effect==="applied");s.isError&&n.length===0&&n.push({code:"MUTATION_FAILED",message:"Mutation failed"}),(E?.length??0)===0&&!a&&g.size===0&&n.length===0&&r.effect!=="not-applied"&&n.push({code:"UNKNOWN_RESULT",message:"Mutation effects were not reported"});let w=d.some(e=>e.effect==="unknown")||n.some(e=>e.code==="UNKNOWN_RESULT")?"unknown":A?"applied":"not-applied";return{status:n.length===0?"success":!a&&A&&d.some(e=>e.effect!=="applied")?"partial":"error",data:{operation:i,effect:w,files:d,...i!=="delete"&&typeof r.metadata?.resultTarget=="string"?{target:r.metadata.resultTarget}:{},...i!=="delete"&&typeof r.metadata?.targetUnavailable=="string"?{targetUnavailable:r.metadata.targetUnavailable}:{}},errors:n}}p(F,"mutationOutcome");function j(s,i,h=[],r){let l=F(s,i,h);return l.data&&r!==void 0&&(l.data.operationId=r),M(s,R(i),l)}p(j,"structuredMutation");export{R as a,N as b,D as c,_ as d,F as e,j as f};
|
package/dist/chunk-64M3SQPG.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{e as j}from"./chunk-PS2B6THP.js";import{i as T,o as m,t as L,u as C}from"./chunk-ZPT5D4VP.js";import{a as y}from"./chunk-ZC65Z3CK.js";import{a as d}from"./chunk-EI7MMDWY.js";function Te(e,n){let{lines:t,truncation:r,...i}=e,o=t?.map(a=>{let l=[a.lineNumber,L(a.content,n),a.lineEnding];return(a.presentation!==void 0||a.metadata!==void 0)&&l.push(a.presentation),a.metadata!==void 0&&l.push(a.metadata),l}),{content:s,...u}=r??{};return{...i,...o===void 0?{}:{storedLines:o},...r===void 0?{}:{truncation:u,truncatedText:L(s??"",n)}}}d(Te,"compactReadDetails");function H(e,n){let t=e;if(t.storedLines===void 0&&t.truncatedText===void 0)return e;let{storedLines:r,truncatedText:i,truncation:o,...s}=t;return{...s,...r===void 0?{}:{lines:r.map(([u,a,l,c,p])=>({lineNumber:u,content:C(a,n),lineEnding:l,...c==null?{}:{presentation:c},...p==null?{}:{metadata:p}}))},...o===void 0?{}:{truncation:{...o,content:C(i??"",n)}}}}d(H,"restoreReadDetails");import f from"node:path";import{homedir as G}from"node:os";import{createReadToolDefinition as X,getReadmePath as J}from"@earendil-works/pi-coding-agent";import{Text as Z}from"@earendil-works/pi-tui";var v=X(process.cwd()),K=new Set(["AGENTS.override.md","AGENTS.md","AGENTS.MD","CLAUDE.md","CLAUDE.MD"]);function $(e,n=process.cwd()){if(typeof e!="object"||e===null)return;let t=e,r=t.path;if(typeof r!="string"||r.length===0||r.includes("#")||!f.isAbsolute(r)&&/^[a-z][a-z\d+.-]*:/iu.test(r)||t.views!==void 0&&(!Array.isArray(t.views)||t.views.length>0)||t.offset!==void 0&&(typeof t.offset!="number"||!Number.isInteger(t.offset)||t.offset<1)||t.limit!==void 0&&(typeof t.limit!="number"||!Number.isInteger(t.limit)||t.limit<1))return;let i=r.startsWith("~/")?f.join(G(),r.slice(2)):r,o=f.resolve(n,i),s=f.basename(o),u=f.relative(f.dirname(J()),o),a=!f.isAbsolute(u)&&(u==="README.md"||u.startsWith(`docs${f.sep}`)||u.startsWith(`examples${f.sep}`));if(!(s!=="SKILL.md"&&!K.has(s)&&!a))return{path:r,...t.offset===void 0?{}:{offset:t.offset},...t.limit===void 0?{}:{limit:t.limit}}}d($,"nativeReadArguments");function A(e,n){return{...e,args:n,lastComponent:e.lastComponent instanceof Z?e.lastComponent:void 0}}d(A,"nativeReadContext");import{getLanguageFromPath as k,getMarkdownTheme as Y,highlightCode as E,keyHint as Q}from"@earendil-works/pi-coding-agent";import{Container as w,Markdown as _,Text as ee,truncateToWidth as S,visibleWidth as R,wrapTextWithAnsi as q}from"@earendil-works/pi-tui";var g=12;function ne(e,n,t){let r=typeof n=="number"?n:void 0,i=typeof t=="number"?t:void 0;if(r===void 0&&i===void 0)return{pathSuffix:"",qualifiers:[],details:[]};if(e==="inherited source"||e.includes("#")){let a=r??1,l=i===void 0?String(a):`${a}-${a+i-1}`;return{pathSuffix:"",qualifiers:[{text:`relative lines ${l}`}],details:[{label:"relative lines",value:l}]}}if(r!==void 0&&r<0)return{pathSuffix:"",qualifiers:[{text:`tail ${Math.abs(r)}`},...i===void 0?[]:[{text:`limit ${i}`}]],details:[{label:"tail",value:String(Math.abs(r))},...i===void 0?[]:[{label:"limit",value:String(i)}]]};let s=Math.max(1,r??1),u=i===void 0?String(s):`${s}-${s+i-1}`;return{pathSuffix:`:${u}`,qualifiers:[],details:[{label:"lines",value:u}]}}d(ne,"readWindowPresentation");function We(e,n,t){let r=$(e,t.cwd);if(r!==void 0)return y(v.renderCall)(r,n,A(t,r));if(typeof e.path=="string"&&e.path.startsWith("shell:"))return new w;let i=typeof e.path=="string"?e.path:"inherited source",o=ne(i,e.offset,e.limit),s=Array.isArray(e.views)?e.views.filter(l=>typeof l=="string"):[],u=[...o.qualifiers,...s.length===0?[]:[{text:`views ${s.join(",")}`}]],a=[...typeof e.path=="string"?[{label:"path",value:e.path}]:[],...o.details,...s.length===0?[]:[{label:"views",value:s.join(",")}]];return j(t.lastComponent,{tool:"read",primary:{text:`${i}${o.pathSuffix}`,color:typeof e.path=="string"?"accent":"muted",underline:typeof e.path=="string",truncate:"start"},qualifiers:u,details:a,expanded:t.expanded},n)}d(We,"renderReadCall");function je(e){let n=new WeakMap;return(t,r,i,o)=>{let s=e.nativeResources?$(o.args,o.cwd):void 0;if(s!==void 0&&!r.isPartial)return y(v.renderResult)({...t,details:{truncation:D(t.details).truncation}},r,i,A(o,s));if(r.isPartial||o.isError){let p=P(t),B=o.isError?"error":"dim";return new ee(i.fg(B,p),0,0)}let u=D(t.details).diagnosticCheck;if(u?.complete&&u.count===0)return new w;if(!me(t))return o.lastComponent instanceof w?o.lastComponent:new w;let a=n.get(t);a===void 0&&(a=H(D(t.details),P(t)),n.set(t,a));let c=(o.lastComponent instanceof b?o.lastComponent:void 0)??new b({result:t,details:a,options:e,expanded:r.expanded,theme:i});return c.update({result:t,details:a,options:e,expanded:r.expanded,theme:i}),c}}d(je,"createReadResultRenderer");var b=class{constructor(n){this.state=n}static{d(this,"ReadResultPanel")}cached;update(n){this.state.result===n.result&&this.state.details===n.details&&this.state.options===n.options&&this.state.expanded===n.expanded&&this.state.theme===n.theme||(this.state=n,this.invalidate())}render(n){if(this.cached?.width===n)return this.cached.lines;if(n<8){let c=[S(V(this.state,n),Math.max(1,n))];return this.cached={width:n,lines:c},c}let t=n-2,r=Math.max(1,t-2),i=oe(this.state,r),o=se(i.state,r).flatMap(c=>q(c,r)),s=ue(o,this.state.expanded,this.state.theme,i.hasHiddenRows),u=[le(this.state,t,this.state.theme)];for(let c of s)for(let p of q(c,r))u.push(I(p,t,this.state.theme));let a=fe(this.state.details,this.state.theme);a!==void 0&&u.push(I(a,t,this.state.theme)),u.push(this.state.theme.fg("borderMuted",`\u2570${"\u2500".repeat(t)}\u256F`));let l=u.map(c=>S(c,n));return this.cached={width:n,lines:l},l}invalidate(){this.cached=void 0}},te=100,re=g,ie=4;function oe(e,n){if(e.expanded)return{state:e,hasHiddenRows:!1};let t=N(e.details);if(t!==void 0&&t.length>te)return{state:{...e,details:{...e.details,lines:t.slice(0,re)}},hasHiddenRows:!0};if(t!==void 0)return{state:e,hasHiddenRows:!1};let r=Math.max(g,n*g*ie),i=e.result.content.map(s=>s.type!=="text"||s.text.length<=r?s:{...s,text:s.text.slice(0,r)}),o=i.some((s,u)=>{let a=e.result.content[u];return s.type==="text"&&a?.type==="text"&&s.text.length<a.text.length});return o?{state:{...e,result:{...e.result,content:i}},hasHiddenRows:o}:{state:e,hasHiddenRows:!1}}d(oe,"compactRenderInput");function se(e,n){let t=N(e.details),r=pe(e.result,t,e.details,!e.expanded);if(e.options.kind==="markdown"||Re(e.details,t,e.options.kind)){let a=new _(r,0,0,Y());return M(a.render(n),e.theme)}if(e.options.kind==="code-view"){let a=t===void 0?h(r).map(l=>O(l,e.theme,!1)):z(t)?ae(t,!e.expanded,e.theme):de(t,e.theme);return M(a,e.theme)}let i=t!==void 0&&z(t),o=t===void 0||i?h(r).map(x):t.map(({content:a})=>x(a)),s=W(e.details,t),u=s===void 0?o.map(a=>e.theme.fg("toolOutput",a)):i?U(t,s,!e.expanded,e.theme):E(o.join(`
|
|
2
|
-
`),s);return M(u,e.theme)}d(se,"renderContentRows");function U(e,n,t,r){return e.flatMap(i=>{let o=x(i.content),s=E(o,n)[0]??r.fg("toolOutput",o),u=!1,a=m({source:"",content:i.content,lines:[i]},{compact:t});return h(a).map(l=>{if(!u&&o.length>0){let c=l.indexOf(o);if(c>=0)return u=!0,`${r.fg("toolOutput",l.slice(0,c))}${s}${r.fg("toolOutput",l.slice(c+o.length))}`}return r.fg("toolOutput",l)})})}d(U,"renderHighlightedPresentedLines");function ae(e,n,t){return e.flatMap(r=>{let i=T(r);if(i===void 0){let s=m({source:"",content:r.content,lines:[r]},{compact:n});return h(s).map(u=>O(u,t,!1))}let o=k(i.source);if(o===void 0){let s=m({source:"",content:r.content,lines:[r]},{compact:n});return h(s).map(u=>t.fg("toolOutput",u))}return U([r],o,n,t)})}d(ae,"renderPresentedCodeViewLines");function de(e,n){return e.map(t=>{let r=T(t);if(r===void 0)return O(t.content,n);let i=k(r.source),o=x(F(t.content));return i===void 0?n.fg("toolOutput",o):E(o,i)[0]??n.fg("toolOutput",o)})}d(de,"renderCodeViewLines");function F(e){return e.replace(/(?:[ \t]{2,}<!--[ \t]+scope-(?:begin|end)-[^\s>]+[ \t]+-->)+[ \t]*$/u,"")}d(F,"stripScopeMarkers");function O(e,n,t=!0){let r=x(t?F(e):e);return/^#{2,3}\s/u.test(r)?n.fg("mdHeading",n.bold(r.replace(/^#{2,3}\s+/u,""))):/^(?:Lines|Reason|Recovery):/u.test(r)?n.fg("dim",r):/^[\p{L}][^:]*:$/u.test(r)?n.fg("accent",n.bold(r)):/^\s*[-*]\s/u.test(r)?n.fg("mdListBullet",r):n.fg("toolOutput",r)}d(O,"renderCodeViewLabel");function ue(e,n,t,r=!1){if(n||e.length<=g&&!r)return e;let i=e.slice(0,g-1),o=e.length-i.length,s=r?"more rows":`${String(o)} more ${o===1?"row":"rows"}`;return[...i,`${t.fg("dim",`\u2026 ${s} \xB7 `)}${Q("app.tools.expand","to expand")}`]}d(ue,"compactRows");function le(e,n,t){let r=d(s=>t.fg("borderMuted",s),"frame"),i=S(` ${V(e,Math.max(1,n-1))} `,Math.max(0,n-1),""),o="\u2500".repeat(Math.max(0,n-R(i)-1));return`${r("\u256D\u2500")}${i}${r(`${o}\u256E`)}`}d(le,"renderTopBorder");function V(e,n){let t=e.options.label??he(W(e.details,N(e.details))),r=e.details.source??"read result",i=ce(e.details),o=e.theme.fg("accent",e.theme.bold(t)),s=i===void 0?"":e.theme.fg("dim",` \xB7 ${i}`),u=Math.max(1,n-R(o)-R(s)-2),a=xe(r,u);return`${o} ${e.theme.fg("muted",a)}${s}`}d(V,"readTitle");function ce(e){if(!(e.startLine===void 0||e.endLine===void 0||e.totalLines===void 0||e.totalLines<=0))return`${String(e.startLine)}\u2013${String(e.endLine)} / ${String(e.totalLines)}`}d(ce,"sourceRange");function fe(e,n){let t=e.truncation;if(t?.firstLineExceedsLimit===!0)return n.fg("warning","First source line is larger than the saved read limit");if(t?.truncated===!0)return n.fg("warning",`Saved result contains ${String(t.outputLines)} of ${String(t.totalLines)} rendered rows`)}d(fe,"readStatus");function I(e,n,t){let r=Math.max(0,n-2),i=S(e,r),o=` ${i}${" ".repeat(Math.max(0,r-R(i)))} `,s=t.fg("borderMuted","\u2502");return`${s}${o}${s}`}d(I,"framed");function pe(e,n,t,r){if(n!==void 0)return m({source:t.source??"",content:"",lines:n},{compact:r});let i=P(e);return t.truncation===void 0&&!(t.totalLines!==void 0&&t.endLine!==void 0&&t.endLine<t.totalLines)?i:i.replace(/\n\n\[(?:Showing lines|Output truncated|\d+ more lines in source)[\s\S]*\]$/u,"")}d(pe,"cleanText");function z(e){return e.some(n=>n.presentation!==void 0)}d(z,"hasPresentation");function h(e){let n=e.split(/\r\n|\r|\n/u);return n.at(-1)===""&&/(?:\r\n|\r|\n)$/u.test(e)&&n.pop(),n}d(h,"splitTextRows");function P(e){return e.content.flatMap(n=>n.type==="text"?[n.text]:[]).join(`
|
|
3
|
-
`)}d(P,"textBlocks");function N(e){return e.lines}d(N,"readLines");function D(e){return typeof e=="object"&&e!==null?e:{}}d(D,"readDetails");function me(e){return e.content.some(n=>n.type==="text")}d(me,"hasTextContent");function W(e,n){let r=n?.map(T).find(i=>i!==void 0)?.source??e.source;return r===void 0?void 0:k(ge(r))}d(W,"languageFor");function Re(e,n,t){return t==="source"&&W(e,n)==="markdown"}d(Re,"isMarkdownSource");function ge(e){try{let n=new URL(e);return n.protocol==="file:"?n.pathname:`${n.pathname}${n.search}`}catch{return e.replace(/#[^/\\]*$/u,"").replace(/^[A-Za-z][A-Za-z\d+.-]*:(?=[/\\])/u,"")}}d(ge,"normalizeSourcePath");function x(e){let n="";for(let t of e.replaceAll(" "," ".repeat(4))){let r=y(t.codePointAt(0));n+=r<32||r===127?"\uFFFD":t}return n}d(x,"normalizeText");function he(e){return e===void 0?"TEXT":{javascript:"JS",json:"JSON",markdown:"MD",python:"PY",rust:"RS",typescript:"TS"}[e]??e.slice(0,4).toUpperCase()}d(he,"languageLabel");function M(e,n){return e.length===0?[n.fg("dim","Empty content")]:[...e]}d(M,"nonEmptyRows");function xe(e,n){return R(e)<=n?e:n<=1?"\u2026":`\u2026${e.slice(-(n-1))}`}d(xe,"truncateFromStart");export{Te as a,g as b,We as c,je as d};
|
package/dist/chunk-CWD4O5PM.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as i}from"./chunk-EI7MMDWY.js";import{AsyncLocalStorage as Ce}from"node:async_hooks";function oe(){return{pending:new Set,active:new Ce}}i(oe,"createSchedulerState");function ve(r,e){return r===void 0||e===void 0?!0:r.some(t=>e.some(n=>(t.mode==="write"||n.mode==="write")&&(t.resource==="*"||n.resource==="*"||t.resource===n.resource||t.recursive===!0&&n.resource.startsWith(t.resource.endsWith("/")?t.resource:`${t.resource}/`)||n.recursive===!0&&t.resource.startsWith(n.resource.endsWith("/")?n.resource:`${n.resource}/`))))}i(ve,"conflicts");function Re(r,e,t){if(e===void 0||!t&&e.some(o=>o.mode!=="read"))return!1;if(r===void 0)return!0;let n=new Map;for(let o of e){let s=o.group??o.resource;n.set(s,[...n.get(s)??[],o])}return[...n.values()].every(o=>o.some(s=>r.some(a=>(s.mode==="read"||a.mode==="write")&&(a.resource==="*"||s.resource===a.resource&&(s.recursive!==!0||a.recursive===!0)||a.recursive===!0&&s.resource.startsWith(a.resource.endsWith("/")?a.resource:`${a.resource}/`)))))}i(Re,"coveredAccess");async function we(r,e){if(e===void 0)return await r;e.throwIfAborted();let t,n=new Promise((o,s)=>{t=i(()=>s(e.reason),"abort"),e.addEventListener("abort",t,{once:!0})});try{return await Promise.race([r,n])}finally{e.removeEventListener("abort",t)}}i(we,"waitForDependencies");var U=class r{constructor(e=oe()){this.state=e}static{i(this,"ResourceScheduler")}run(e,t,n,o={}){let s=Promise.resolve(e),a=this.state.active.getStore();if(a?.open){let m=s.then(b=>{if(n?.throwIfAborted(),!Re(a.accesses,b,a.allowNestedWrites))throw Object.assign(new Error("Nested resource access must be covered by its parent reservation and permitted by its owner."),{code:"UNDECLARED_RESOURCE_ACCESS"});return b});a.nested??=new r;let y=a.nested.run(m,t,n,{allowNestedWrites:a.allowNestedWrites});return a.children.add(y),y.then(()=>a.children.delete(y),()=>a.children.delete(y)),y}let d=[...this.state.pending],u=s.catch(()=>{}),p,f=new Promise(m=>{p=m}),h={accesses:u,done:f};return this.state.pending.add(h),(async()=>{try{n?.throwIfAborted();let m=await we(s.then(async b=>(await Promise.all(d.map(q=>Promise.race([q.done,q.accesses.then(ye=>ve(b,ye)?q.done:void 0)]))),b)),n);n?.throwIfAborted();let y={accesses:m,children:new Set,open:!0,allowNestedWrites:o.allowNestedWrites===!0};try{return await this.state.active.run(y,t)}finally{for(;y.children.size>0;)await Promise.allSettled([...y.children]);y.open=!1}}finally{this.state.pending.delete(h),p()}})()}},Te=Symbol.for("pi-agent-resource.resource-scheduler-state"),be=globalThis,Ee=be[Te]??=oe(),Se=new U(Ee);import{realpath as xe,stat as Ae}from"node:fs/promises";import j from"node:path";import{fileURLToPath as Oe}from"node:url";async function se(r,e,t){if(/^[a-z][a-z\d+.-]*:/iu.test(r)&&!/^[a-z]:[\\/]/iu.test(r)&&!r.startsWith("file:"))return[{resource:r,mode:t}];let n=j.resolve(e,r.startsWith("file:")?Oe(r):r),[o,s]=await Promise.allSettled([xe(n),Ae(n,{bigint:!0})]),a;if(o.status==="fulfilled")a=o.value;else{let f=o.reason;if(!(f instanceof Error)||!("code"in f)||f.code!=="ENOENT")throw f;let h=j.dirname(n);if(h===n)a=n;else{let y=(await se(h,e,t)).find(b=>b.resource.startsWith("file:"));a=j.join(y?.resource.slice(5)??h,j.basename(n))}}let d=a.split(j.sep).join("/"),u=`file:${process.platform==="win32"?d.toLowerCase():d}`,p=[{resource:u,group:u,mode:t}];if(s.status==="fulfilled"){let f=s.value;f.isDirectory()&&(p[0]={resource:u,group:u,mode:t,recursive:!0}),f.ino!==0n&&p.push({resource:`inode:${f.dev}:${f.ino}`,group:u,mode:t,recursive:f.isDirectory()})}else{let f=s.reason;if(!(f instanceof Error)||!("code"in f)||f.code!=="ENOENT")throw f}return p}i(se,"resourceAccesses");import{Type as g}from"typebox";import{Value as ke}from"typebox/value";var D=g.Object({code:g.String(),message:g.String(),source:g.Optional(g.String())},{additionalProperties:!1});function ie(r){return{...g.Union([g.Object({status:g.Literal("success"),data:r,errors:g.Array(D,{maxItems:0})},{additionalProperties:!1}),g.Object({status:g.Union([g.Literal("error"),g.Literal("partial")]),data:g.Optional(r),errors:g.Array(D,{minItems:1})},{additionalProperties:!1})]),type:"object",properties:{status:g.Union([g.Literal("success"),g.Literal("error"),g.Literal("partial")]),data:g.Optional(r),errors:g.Array(D)},required:["status","errors"],additionalProperties:!1}}i(ie,"structuredResultSchema");var ae=1024*1024;function z(r){let e=new Set,t=i(n=>{if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(typeof n!="object"||e.has(n))throw new TypeError("Structured data must be finite, acyclic JSON");if(!Array.isArray(n)&&Object.getPrototypeOf(n)!==Object.prototype&&Object.getPrototypeOf(n)!==null)throw new TypeError("Structured data must not contain classes or raw byte buffers");e.add(n);for(let o of Array.isArray(n)?n:Object.values(n))t(o);e.delete(n)}},"visit");if(t(r),Buffer.byteLength(JSON.stringify(r))>ae)throw new RangeError("Structured data exceeds 1 MiB; return a smaller window or a full-result reference")}i(z,"assertJsonData");function ce(r,e="EXECUTION_FAILED",t){return{code:typeof r=="object"&&r!==null&&"code"in r&&typeof r.code=="string"?r.code:e,message:r instanceof Error?r.message:String(r),...t===void 0?{}:{source:t}}}i(ce,"resultError");function Ne(r,e,t){try{if(z(t),!ke.Check(ie(e),t))throw new TypeError("Result adapter returned data outside its public schema");return{...r,structuredContent:t,isError:t.status!=="success"}}catch(n){let o=ce(n,"INVALID_STRUCTURED_RESULT"),s={status:"error",errors:[o]};return z(s),{...r,content:[...r.content,{type:"text",text:o.message}],structuredContent:s,isError:!0}}}i(Ne,"withStructuredResult");function je(r,e){if(e.length===0)return;let t=r.trim();if(t.length===0||/[\r\n]/u.test(t))throw new TypeError("Content provider summary must be one non-empty line");return[t,...e.map(({description:n})=>n)].join(`
|
|
2
|
-
`)}i(je,"renderContentDescription");import{Type as l}from"typebox";import{Value as He}from"typebox/value";import{Type as c}from"typebox";import{Value as Pe}from"typebox/value";var C={additionalProperties:!0},P=c.Function([],c.Unknown()),v=c.String({minLength:1}),Ie=c.Object({type:c.Literal("text"),text:c.String(),textSignature:c.Optional(c.String())},C),_e=c.Object({type:c.Literal("image"),data:c.String(),mimeType:c.String()},C),Ue=c.Object({type:c.Literal("custom"),kind:v,data:c.Unknown()},C),De=c.Array(c.Union([Ie,_e,Ue]),{minItems:1}),ue=c.Union([c.Object({source:v,link:c.Optional(v),read:P,write:c.Optional(c.Never())},C),c.Object({source:v,link:c.Optional(v),read:c.Optional(c.Never()),write:P},C),c.Object({source:v,link:c.Optional(v),read:P,write:P},C)]),Le=c.Object({id:v,tryResolve:P},C),$e=c.Union([c.Object({kind:c.Literal("not-handled")},C),c.Object({kind:c.Literal("resolved"),resource:ue},C),c.Object({kind:c.Literal("failed"),error:c.Unknown()},C)]);function J(r){return L(De,r)?$(()=>r.every(e=>e.type!=="text"||!("textSignature"in e)||typeof e.textSignature=="string")):!1}i(J,"isAgentContent");function le(r){return L(ue,r)?$(()=>{let e=r,t=!("read"in e)||typeof e.read=="function",n=!("write"in e)||typeof e.write=="function";return t&&n}):!1}i(le,"isResource");function We(r){return L(Le,r)}i(We,"isResourceResolver");function Ve(r){return L($e,r)?$(()=>{let e=r;return e.kind!=="resolved"||le(e.resource)}):!1}i(Ve,"isResourceResolutionAttempt");function L(r,e){return $(()=>Pe.Check(r,e))}i(L,"safeCheck");function $(r){try{return r()}catch{return!1}}i($,"safeEvaluate");var R={additionalProperties:!0},Me=l.Function([],l.Unknown()),W=l.String({minLength:1}),Fe=l.Object({provider:W,capability:l.Union([l.Literal("read"),l.Literal("write")])},R),Ke=l.Object({source:W,bytes:l.Unknown(),mediaType:l.Optional(l.String())},R),qe=l.Object({signal:l.Optional(l.Unknown())},R),ze=l.Object({id:W,description:W,tryConvert:Me},R),Je=l.Union([l.Object({kind:l.Literal("not-handled")},R),l.Object({kind:l.Literal("converted"),content:l.Unknown()},R),l.Object({kind:l.Literal("failed"),error:l.Unknown()},R)]),Be=l.Object({target:l.Unknown(),converter:l.Unknown(),priority:l.Optional(l.Number())},R);function A(r){return O(Fe,r)&&S(()=>r.provider.trim().length>0)}i(A,"isContentTarget");function B(r){return O(Ke,r)?S(()=>{let e=r;return e.bytes instanceof Uint8Array&&(!("mediaType"in e)||typeof e.mediaType=="string")}):!1}i(B,"isContentInput");function Y(r){return O(qe,r)?S(()=>{let e=r;return!("signal"in e)||e.signal instanceof AbortSignal}):!1}i(Y,"isContentConversionContext");function de(r){return O(ze,r)?S(()=>{let e=r;return e.id.trim().length>0&&e.description.trim().length>0&&!/[\r\n]/u.test(e.description)}):!1}i(de,"isContentConverter");function G(r){return O(Je,r)?S(()=>{let e=r;return e.kind!=="converted"||J(e.content)}):!1}i(G,"isContentConversionAttempt");function E(r){return O(Be,r)?S(()=>{let e=r;return A(e.target)&&de(e.converter)&&(!("priority"in e)||typeof e.priority=="number"&&Number.isFinite(e.priority))}):!1}i(E,"isContentConverterRegistration");function O(r,e){return S(()=>He.Check(r,e))}i(O,"safeCheck");function S(r){try{return r()}catch{return!1}}i(S,"safeEvaluate");var V=class extends Error{static{i(this,"UnsupportedContentError")}source;target;constructor(e,t){super(`No content converter for ${e} in ${t.provider}/${t.capability}`),this.name="UnsupportedContentError",this.source=e,this.target=t}};function Q(r){if(!A(r))throw new TypeError("Invalid content target");let e={...r},t=[],n=i(()=>[...t].sort((o,s)=>o.priority-s.priority||o.order-s.order),"snapshotConverters");return{target:e,register(o){if(!E(o))throw new TypeError("Invalid content converter registration");if(!k(e,o.target))throw new Error(`Content converter ${o.converter.id} targets ${o.target.provider}/${o.target.capability}, not ${e.provider}/${e.capability}`);if(t.some(({converter:s})=>s.id===o.converter.id))throw new Error(`Content converter ${o.converter.id} is already registered for ${e.provider}/${e.capability}`);t.push({converter:o.converter,priority:o.priority??0,order:t.length})},listDescriptions(){return n().map(({converter:o})=>({id:o.id,description:o.description}))},async convert(o,s){if(!B(o))throw new TypeError("Invalid content input");if(!Y(s))throw new TypeError("Invalid content conversion context");X(s.signal);let a=n();for(let{converter:d}of a){X(s.signal);let u=await d.tryConvert(o,s);if(X(s.signal),!G(u))throw new TypeError(`Content converter ${d.id} returned an invalid outcome`);if(u.kind!=="not-handled"){if(u.kind==="failed")throw u.error;return u.content}}throw new V(o.source,e)}}}i(Q,"createContentRunner");function k(r,e){return r.provider===e.provider&&r.capability===e.capability}i(k,"targetsEqual");function X(r){r?.throwIfAborted()}i(X,"throwIfAborted");import{Type as w}from"typebox";import{Value as Ye}from"typebox/value";var N="pi-agent-resource/content-conversion",H=2,I=`${N}/host/ready`,_=`${N}/converter/register`,fe={additionalProperties:!0},Ge=w.Function([],w.Unknown()),Xe=w.Object({protocol:w.Literal(N),apiVersion:w.Literal(H),target:w.Unknown()},fe),Qe=w.Object({registration:w.Unknown(),accept:Ge},fe);function Z(r){return pe(Xe,r)&&te(()=>A(r.target))}i(Z,"isContentHostReady");function ee(r){return pe(Qe,r)&&te(()=>E(r.registration))}i(ee,"isContentConverterRegistrationRequest");function pe(r,e){return te(()=>Ye.Check(r,e))}i(pe,"safeCheck");function te(r){try{return r()}catch{return!1}}i(te,"safeEvaluate");function Ze(r,e){let t=Q(e),n=r.events.on(_,o=>{if(!ee(o))throw new Error("Invalid content converter registration request");if(!k(t.target,o.registration.target))return;let s;try{t.register(o.registration),s=Promise.resolve()}catch(a){s=Promise.reject(a instanceof Error?a:new Error("Content converter registration failed",{cause:a}))}o.accept(s)});return r.on("session_shutdown",n),r.events.emit(I,{protocol:N,apiVersion:H,target:t.target}),{target:t.target,listDescriptions(){return t.listDescriptions()},convert(o,s){return t.convert(o,s)}}}i(Ze,"createContentHost");function et(r,e){if(!E(e))throw new TypeError("Invalid content converter registration");let t=i(()=>{let s,a={registration:e,accept(d){if(s!==void 0)throw new Error(`Content converter ${e.converter.id} registration was accepted more than once`);s=d}};return r.events.emit(_,a),s},"announce"),n=i(()=>{},"unsubscribe");n=r.events.on(I,s=>{if(!Z(s))throw new Error("Invalid content conversion host readiness event");if(!k(e.target,s.target))return;let a=t();if(a===void 0)throw new Error(`${s.target.provider}/${s.target.capability} announced readiness without accepting content converter ${e.converter.id}`);n(),a.catch(()=>{})}),r.on("session_shutdown",n);let o=t();if(o!==void 0)return n(),o}i(et,"connectContentConverter");import{createHash as ge,randomUUID as re}from"node:crypto";import{statSync as tt}from"node:fs";import{readFile as rt}from"node:fs/promises";import T from"node:path";import{fileURLToPath as nt}from"node:url";import{Type as M}from"typebox";var ot=M.Union([M.String(),M.Array(M.String())]),x="RESULT#",he="pi-agent-resource:result-targets",K=class{static{i(this,"ResultTargetStore")}#e=new Map;#o=new Map;#n=new Map;#t=new Map;clear(){this.#e.clear(),this.#o.clear(),this.#n.clear(),this.#t.clear()}register(e,t,n=!0){for(let s of e)this.refresh(s.source,t);let o=`${x}${re()}`;return this.#e.set(o,{state:"ready",targets:ne(e),complete:n,cwd:T.resolve(t)}),o}reserve(e){let t=`${x}${re()}`;return this.#e.set(t,{state:"pending",cwd:T.resolve(e)}),t}confirm(e,t,n){let o=this.#e.get(e);if(o?.state!=="pending"||o.cwd!==T.resolve(n))throw new Error("Only a pending result in this worktree can be confirmed.");for(let s of t)this.refresh(s.source,n);this.#e.set(e,{state:"ready",cwd:o.cwd,targets:ne(t),complete:!0})}reject(e,t){let n=this.#e.get(e);n?.state==="pending"&&this.#e.set(e,{state:"rejected",cwd:n.cwd,reason:t})}resolve(e,t){e=this.source(e,t);let n=this.#r(e),o=[],s=!0;for(let a of n){let d=this.#e.get(a);if(d===void 0)throw new Error("Result target expired or unknown; repeat Read/Search.");if(d.cwd!==T.resolve(t))throw new Error("Result target belongs to another worktree.");if(d.state==="pending")throw new Error("Result target is pending; its write has not been confirmed.");if(d.state==="rejected")throw new Error(d.reason);for(let u of d.targets)this.refresh(u.source,t);if(!this.#e.has(a))throw new Error("Result target expired after its snapshot changed; repeat Read/Search.");s&&=d.complete,o.push(...d.targets)}return{targets:ne(o),complete:s}}resolveOrdered(e,t){let n=this.resolve(e,t),o=[],s=new Set;for(let a of new Set(this.#r(this.source(e,t))))for(let d of this.resolve(a,t).targets)for(let u of d.ranges){let p=JSON.stringify([d.source,u]);s.has(p)||(s.add(p),o.push({...d,ranges:[u]}))}return{targets:o,complete:n.complete}}async verify(e,t){try{await me(e,t)}catch(n){if(!t?.aborted)for(let o of e.targets)this.invalidate(o.source);throw n}}publish(e,t,n,o=[]){let s=re();for(let p of o)this.refresh(p,n);let a=[];try{a=this.#r(e)}catch{}let d=`<system-result note="Internal reference; not part of the file. Do not edit."><uuid>${s}</uuid></system-result>
|
|
3
|
-
${t}`,u=e!==null&&typeof e=="object"&&"status"in e&&e.status==="success";if(u&&"data"in e){let p=e.data;if(p!==null&&typeof p=="object"&&"matches"in p&&Array.isArray(p.matches)){let f=p.matches;for(let h of f){if(h===null||typeof h!="object"||!("target"in h)||typeof h.target!="string"||!this.#e.has(h.target)||!("references"in h))continue;let m=h.references;m!==null&&typeof m=="object"&&"match"in m&&typeof m.match=="string"&&/^SEARCH#[A-F\d]+:\d+:match$/u.test(m.match)&&this.#o.set(m.match,h.target)}}}return this.#t.set(s,{cwd:T.resolve(n),digest:ge("sha256").update(d).digest("hex"),consumable:u,references:a,resources:o}),d}source(e,t,n=!1){if(Array.isArray(e))return e.map(f=>this.source(f,t,n));if(typeof e!="string")return e;let o=this.#o.get(e);if(o)return this.source(o,t,n);let s=/^<system-result\b[^>]*><uuid>([a-f\d-]{36})<\/uuid><\/system-result>(?:\n|$)/u.exec(e),a=s?.[1]??(e.startsWith(x)?e.slice(x.length):e),d=/^[a-f\d]{8}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{12}$/u.test(a);if(!s&&!d){if(e.startsWith("<system-result"))throw new Error("Invalid system result reference.");return e}let u=this.#t.get(a);if(!u&&!s&&e.startsWith(x)&&this.#e.has(e))return e;if(!u)throw new Error("Result reference expired or unknown; repeat the source tool.");if(u.cwd!==T.resolve(t))throw new Error("Result belongs to another worktree.");if(s&&ge("sha256").update(e).digest("hex")!==u.digest)throw new Error("Result text changed; pass the original result or its UUID.");for(let f of u.resources)this.refresh(f,t);if(!this.#t.has(a))throw new Error("Result reference expired; repeat the source tool.");if(!u.consumable)throw new Error("Only successful source results can be consumed.");for(let f of u.references)if(!this.#e.has(f))throw this.#t.delete(a),new Error("Result reference expired; repeat the source tool.");if(u.references.length===1)return u.references[0];if(u.references.length>1)return u.references;let p=u.resources.length===1?u.resources[0]:void 0;if(p&&(n===!0||n==="live"&&/^(?:shell|debug):/u.test(p)))return p;throw new Error("This result has no reusable text selection.")}invalidate(e){let t=new Set;for(let[n,o]of this.#e)o.state==="ready"&&o.targets.some(s=>F(s.source,o.cwd)===e)&&(this.#e.delete(n),t.add(n));for(let[n,o]of this.#t)(o.resources.some(s=>F(s,o.cwd)===e)||o.references.some(s=>t.has(s)))&&this.#t.delete(n)}refresh(e,t){let n=F(e,t),o=JSON.stringify([T.resolve(t),n]),s=st(e,t),a=this.#n.get(o);a&&a.stamp!==s&&this.invalidate(n),this.#n.set(o,{source:e,cwd:t,stamp:s})}refreshAll(){for(let e of[...this.#n.values()])this.refresh(e.source,e.cwd)}#r(e){if(typeof e=="string"&&e.startsWith(x))return[e];if(Array.isArray(e))return e.flatMap(n=>this.#r(n));if(e===null||typeof e!="object")throw new Error("Unsupported result input.");let t=e;if("status"in t){if(t.status!=="success")throw new Error("Only successful source results can be consumed.");return this.#r(t.data)}if(typeof t.target=="string"&&t.target.startsWith(x))return[t.target];if(t.kind==="resources"&&Array.isArray(t.resources))return this.#r(t.resources);throw new Error("This result has no supported source target; do not use preview text as a source.")}};function F(r,e){let t=r.startsWith("raw:")?r.slice(4):r;if(t.startsWith("file:"))try{return nt(t)}catch{}return T.resolve(e,t)}i(F,"sourcePath");function st(r,e){try{let t=tt(F(r,e),{bigint:!0});return`${t.dev}:${t.ino}:${t.size}:${t.mtimeNs}:${t.ctimeNs}`}catch{return}}i(st,"fileStamp");async function me(r,e){let t=new Map;for(let n of r.targets){e?.throwIfAborted();let o=t.get(n.source);if(o===void 0&&(o=await rt(n.source,{encoding:"utf8",signal:e}),t.set(n.source,o)),o!==n.expectedContent)throw new Error("Result target is stale; repeat Read/Search.")}}i(me,"verifyResultTargets");function ne(r){let e=new Map;for(let t of r){let n=e.get(t.source);if(n!==void 0&&n.expectedContent!==t.expectedContent)throw new Error("Result targets refer to different snapshots of the same source.");let o=n??{source:t.source,expectedContent:t.expectedContent,ranges:[],seen:new Set};for(let s of t.ranges){let a=JSON.stringify(s);o.seen.has(a)||(o.seen.add(a),o.ranges.push(structuredClone(s)))}e.set(t.source,o)}return[...e.values()].filter(t=>t.ranges.length>0).map(({seen:t,...n})=>({...n,ranges:n.ranges.sort((o,s)=>o.start.lineNumber-s.start.lineNumber||o.start.column-s.start.column||o.end.lineNumber-s.end.lineNumber||o.end.column-s.end.column)}))}i(ne,"combineTargets");function it(r){let e;if(r.events.emit(he,{accept:i(o=>{e=o},"accept")}),e!==void 0)return e;let t=new K,n=r.events.on(he,o=>{o!==null&&typeof o=="object"&&"accept"in o&&typeof o.accept=="function"&&o.accept(t)});return r.on("session_start",()=>{t.clear()}),r.on("session_shutdown",()=>{t.clear(),n()}),t}i(it,"connectResultTargets");export{U as a,Se as b,se as c,D as d,ie as e,ae as f,z as g,ce as h,Ne as i,je as j,J as k,le as l,We as m,Ve as n,A as o,B as p,Y as q,de as r,G as s,E as t,V as u,Q as v,k as w,N as x,H as y,I as z,_ as A,Z as B,ee as C,Ze as D,et as E,ot as F,K as G,me as H,it as I};
|
package/dist/chunk-D3WTDA6V.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{e as m,i as g,m as x}from"./chunk-CWD4O5PM.js";import{a as i}from"./chunk-EI7MMDWY.js";import{Type as n}from"typebox";import{Value as y}from"typebox/value";import{Type as d}from"typebox";var c=d.Object({path:d.Optional(d.String({description:"What to read: a supported resource such as a file or directory path, URL, returned temp: reference, SEARCH# or RESULT# reference, or registered protocol source. Supply a path; an empty call cannot select a source."})),offset:d.Optional(d.Number({description:"For raw: sources, use a zero-based byte offset; negative offsets count from the file end. For other sources: first line to return, numbered from 1. Omit or use 0 to start at line 1; -1 starts at the last line, -10 at the tenth line from the end. For path#anchor, SEARCH or RESULT# selections, count from its containing line instead: 0 or 1 starts there, 2 starts one line later, -1 one line earlier. For image and sequence views, offset is a zero-based row-major grid cell index and requires limit."})),limit:d.Optional(d.Number({description:"For raw: sources, use a non-negative byte count (0 reads no bytes). Otherwise, maximum lines from the selected starting position. Output is bounded; omit for the default read. For image and sequence views, limit is the square grid cell size in pixels; omit offset to select cell 0, or omit both for the bounded full image."})),views:d.Optional(d.Array(d.String(),{description:`Optional source-specific presentations. Combine views when both presentations are needed, for example ["anchors", "ast"]. Omit for the source's default presentation.`}))}),O={path:"What to read: a resource path, unchanged source result or its UUID. Pass the whole result to compose tools. Supply a source; an empty call cannot select one. temp:<id> reads saved complete output until this runtime is disposed. raw:<local-file> reads original bytes from a regular file (relative, absolute or file:// path); raw: does not accept views.",offset:"For raw: sources, a zero-based integer byte offset; negative offsets count from the file end. For text sources, the first line to return, numbered from 1. Omit or use 0 to start at line 1; -1 starts at the last line, -10 at the tenth line from the end.",limit:"For raw: sources, a non-negative integer byte count (0 reads no bytes). For text sources, the maximum lines from the selected starting position. Omit for the bounded default read. Explicit ranges on other content require a source-specific handler; otherwise they fail.",views:"Optional source-specific presentations. Omit for the source's default presentation. Values may include settings after a colon; use the syntax below. Combine views only when their contracts allow it. Unknown views can be ignored and reported in ignoredViews; they do not add capabilities. raw: sources reject views."};function H(e){let r=i((o,u)=>({...o,description:[O[u],e[u]].filter(R=>R!==void 0).join(`
|
|
2
|
-
`)}),"describe");return{...c,properties:{path:r(c.properties.path,"path"),offset:r(c.properties.offset,"offset"),limit:r(c.properties.limit,"limit"),views:r(c.properties.views,"views")}}}i(H,"describeReadParameters");import{Type as t}from"typebox";var w=t.Object({value:t.String(),kind:t.String(),state:t.Optional(t.String())},{additionalProperties:!1}),k=t.Object({lineNumber:t.Integer(),content:t.String(),lineEnding:t.String(),anchors:t.Optional(t.Array(t.String()))},{additionalProperties:!1}),L=t.Object({path:t.String(),offset:t.Integer()},{additionalProperties:!1}),f={source:t.String(),truncated:t.Boolean(),continuation:t.Optional(L),fullResult:t.Optional(t.String())},h=t.Object({...f,kind:t.Literal("text"),target:t.Optional(t.String()),lines:t.Array(k),startLine:t.Integer(),endLine:t.Integer(),totalLines:t.Integer(),references:t.Optional(t.Array(w))},{additionalProperties:!1}),b=t.Object({...f,kind:t.Literal("bytes"),bytes:t.Array(t.Integer({minimum:0,maximum:255})),byteOffset:t.Integer(),byteLength:t.Integer(),totalBytes:t.Integer()},{additionalProperties:!1}),P=t.Union([t.Object({type:t.Literal("text"),text:t.String()},{additionalProperties:!1}),t.Object({type:t.Literal("image"),mimeType:t.String()},{additionalProperties:!1})]),S=t.Object({...f,kind:t.Literal("native"),blocks:t.Array(P)},{additionalProperties:!1}),p=t.Union([t.Object({kind:t.Literal("recovery"),source:t.String(),candidates:t.Array(t.Object({path:t.String()},{additionalProperties:!1}))},{additionalProperties:!1}),h,b,S,t.Object({kind:t.Literal("resources"),source:t.Optional(t.String()),resources:t.Array(t.Union([h,b,S])),truncated:t.Boolean(),fullResult:t.Optional(t.String())},{additionalProperties:!1})]),v=m(p);function C(e){return{lineNumber:e.lineNumber,content:e.content,lineEnding:e.lineEnding,...e.anchors===void 0?{}:{anchors:[...e.anchors]}}}i(C,"publicLine");function T(e){if(e.kind==="resources"){let a=e.resources.map(s=>T(s));return{kind:e.kind,...e.source===void 0?{}:{source:e.source},resources:a,truncated:a.some(s=>typeof s=="object"&&s!==null&&"truncated"in s&&s.truncated===!0)}}if(e.kind==="bytes"){let a=e.bytes.slice(0,32768),s=e.truncated===!0||a.length<e.bytes.length;return{kind:e.kind,source:e.source,bytes:a,byteOffset:e.byteOffset,byteLength:a.length,totalBytes:e.totalBytes,truncated:s,...e.byteOffset+a.length<e.totalBytes?{continuation:{path:e.source,offset:e.byteOffset+a.length}}:{}}}if(e.kind==="native")return{kind:e.kind,source:e.source,truncated:!1,blocks:e.blocks.map(a=>{if(a.type==="text")return{type:a.type,text:a.text};if(a.type==="image")return{type:a.type,mimeType:a.mimeType};throw new TypeError("Custom content requires a structured adapter")})};let r=[],o=0;for(let a of e.lines){let s=C(a);if(o+=Buffer.byteLength(JSON.stringify(s)),r.length>=2e3||o>512*1024)break;r.push(s)}if(r.length===0&&e.lines.length>0)throw new RangeError("Selected line exceeds the structured window; use a raw byte range or a source-specific view");let u=r.length<e.lines.length,R=r.at(-1)?.lineNumber??e.startLine-1;return{kind:e.kind,source:e.source,lines:r,startLine:r[0]?.lineNumber??0,endLine:r.at(-1)?.lineNumber??0,totalLines:e.totalLines,truncated:u,...e.target===void 0?{}:{target:e.target},...e.references===void 0?{}:{references:e.references},...u||R<e.totalLines?{continuation:{path:e.source,offset:R+1}}:{}}}i(T,"publicData");function E(e){let r=e.details.failure;if(e.isError||r!==void 0)return g(e,p,{status:"error",...r?.candidates?.length&&r.source!==void 0?{data:{kind:"recovery",source:r.source,candidates:r.candidates}}:{},errors:[{code:r?.code??"READ_FAILED",message:r?.message??"Read failed",...r?.source===void 0?{}:{source:r.source}}]});try{if(e.script===void 0)throw new TypeError("Read handler must return structured script data");let o=T(e.script);return g(e,p,{status:"success",data:e.details.temporarySource!==void 0&&typeof o=="object"&&o!==null?{...o,fullResult:e.details.temporarySource}:o,errors:[]})}catch(o){return g(e,p,{status:"error",errors:[{code:o instanceof RangeError?"STRUCTURED_RESULT_TOO_LARGE":"STRUCTURED_ADAPTER_REQUIRED",message:o instanceof Error?o.message:String(o)}]})}}i(E,"structuredRead");var l=n.Function([],n.Unknown()),D=n.Object({resolver:n.Unknown(),matchesCall:n.Optional(l),renderCall:n.Optional(l),priority:n.Optional(n.Number()),renderResult:n.Optional(l),preserveTruncatedOutput:n.Optional(n.Boolean())}),A=n.Object({resolver:n.Unknown(),priority:n.Optional(n.Number())}),F=n.Object({id:n.String({pattern:"\\S"}),priority:n.Optional(n.Number()),resolve:l}),N=n.Object({view:n.String({pattern:"\\S"}),includes:n.Optional(n.Array(n.String({pattern:"\\S"}))),presenter:n.Object({id:n.String(),present:l}),priority:n.Optional(n.Number())}),U=n.Object({resolvedBy:n.String({pattern:"\\S"}),contentKind:n.Union([n.Literal("text"),n.Literal("any")])}),j=n.Union([n.Object({stage:n.Literal("pre-read"),handler:l}),n.Object({stage:n.Literal("read"),when:U,handler:l}),n.Object({stage:n.Literal("post-read"),handler:l})]);function J(e){if(!y.Check(A,e))return!1;let r=e,o=r.resolver;return typeof o.id=="string"&&o.id.length>0&&typeof o.tryResolve=="function"&&(!("priority"in r)||typeof r.priority=="number")}i(J,"isTextTargetResolverRegistration");function Y(e){if(!y.Check(D,e))return!1;let r=e;return x(r.resolver)?r.resolver.id!=="any"&&(!("priority"in r)||typeof r.priority=="number")&&(!("matchesCall"in r)||typeof r.matchesCall=="function")&&(!("renderCall"in r)||typeof r.renderCall=="function")&&"matchesCall"in r=="renderCall"in r&&(!("renderResult"in r)||typeof r.renderResult=="function"):!1}i(Y,"isResourceResolverRegistration");function X(e){return y.Check(j,e)}i(X,"isReadHandlerRegistration");function Z(e){return y.Check(N,e)}i(Z,"isReadViewRegistration");function $(e){return y.Check(F,e)}i($,"isFragmentResolverRegistration");function ee(e){return I(e)?e.kind==="not-handled"?!0:e.kind==="failed"?typeof e.message=="string"&&e.message.length>0:e.kind==="resolved"&&typeof e.originLine=="number":!1}i(ee,"isReadFragmentResolution");function I(e){return typeof e=="object"&&e!==null}i(I,"isRecord");export{c as a,H as b,p as c,v as d,E as e,J as f,Y as g,X as h,Z as i,$ as j,ee as k};
|
package/dist/chunk-EAZGN5ND.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{a as d}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";var f=class i{static{s(this,"FileRange")}start;end;constructor(e,t=e){t.lineNumber<e.lineNumber&&([e,t]=[t,e]),this.start=e,this.end=t}static fromLines(e,t){let r=t??e;return new i({lineNumber:e},{lineNumber:r})}},l=class i{static{s(this,"FileMutationResult")}data;constructor(e){this.data=e??{}}get ok(){return this.data.ok??!1}get isPartial(){return this.data.isPartial??!1}get diffs(){return this.data.diffs??[]}get files(){return this.data.files??[]}get warnings(){return this.data.warnings??[]}get errors(){return this.data.errors??[]}get lintViolations(){return this.data.lintViolations??[]}get hints(){return this.data.hints??[]}get syntaxErrorSummary(){return this.data.syntaxErrorSummary}get path(){return this.data.path}get editRange(){let e=this.data.activeEdits,t=e?.[0];if(t?.range){let r=t.range.start,a=d(e).at(-1)?.range?.end??r;return new f(r,a)}return this.data.editRange}get resolvedStartLine(){return this.editRange?.start.lineNumber}get resolvedEndLine(){return this.editRange?.end.lineNumber}get freshAnchors(){return this.data.freshAnchors}get failurePoint(){return this.data.failurePoint}get recovery(){return this.data.recovery}get expectedAnchor(){return this.data.expectedAnchor}get currentAnchor(){return this.data.currentAnchor}get internalErrorType(){return this.data.internalErrorType}get internalErrorMessage(){return this.data.internalErrorMessage}get editCount(){return this.data.editCount}get editRanges(){return this.data.editRanges}get addedLines(){return this.data.addedLines}get removedLines(){return this.data.removedLines}get appliedPaths(){return this.data.appliedPaths}get beforeContentMap(){return this.data.beforeContentMap}get afterContent(){return this.data.afterContent}get skipCount(){return this.data.skipCount??0}get staleEdits(){return this.data.staleEdits??[]}get proposedDiff(){return this.data.proposedDiff}get editIndex(){return this.data.editIndex}get editIndices(){return this.data.editIndices}get staleDiagnostic(){return this.data.staleDiagnostic}get fileChangedStatement(){return this.data.fileChangedStatement}get affectedPaths(){let e=new Set;for(let t of this.files)e.add(t.path);for(let t of this.errors)t.path&&e.add(t.path);for(let t of this.warnings)t.file&&e.add(t.file);return[...e]}get didChange(){return this.ok&&(this.files.length>0||this.diffs.length>0)}get createdFiles(){return this.files.filter(e=>e.action==="created")}get overwrittenFiles(){return this.files.filter(e=>e.action==="overwritten"||e.action==="edited")}get staleCount(){return this.staleEdits.length}get summary(){if(!this.ok){let n=this.errors[0];return n?`Failed: ${n.code??"ERROR"}${n.reason?` \u2014 ${n.reason}`:""}`:"Mutation failed"}if(this.files.length===0&&this.diffs.length===0){let n=this.appliedPaths;return n&&n.length>0?`${n.length} path${n.length===1?"":"s"} affected`:"No changes"}let e=this.createdFiles.length,t=this.overwrittenFiles.length,r=[];if(e>0&&r.push(`Created ${e} ${e===1?"file":"files"}`),t>0&&r.push(`Edited ${t} ${t===1?"file":"files"}`),this.diffs.length>0){let n=0,a=0;for(let o of this.diffs)for(let u of o.split(`
|
|
2
|
-
`))u.startsWith("+")&&!u.startsWith("+++")?n++:u.startsWith("-")&&!u.startsWith("---")&&a++;(n>0||a>0)&&r.push(`+${n}/-${a} lines`)}return r.join(", ")}getFileChange(e){return this.files.find(t=>t.path===e)}getDiffFor(e){let t=g(e);for(let r of this.diffs){let n=r.match(/^---\s+(.+)$/m);if(n&&(g(d(n[1]))===t||n[1]===e))return r}}getErrorsFor(e){return this.errors.filter(t=>t.path===e)}getWarningsFor(e){return this.warnings.filter(t=>t.file===e)}static fromFailureOptions(e){return new i({ok:!1,path:e.path,errors:[{path:e.path,code:e.code,reason:e.reason}],failurePoint:e.failurePoint,recovery:e.recovery,expectedAnchor:e.expectedAnchor,currentAnchor:e.currentAnchor,freshAnchors:e.freshLines?[...e.freshLines]:void 0,internalErrorType:e.internalError instanceof Error?e.internalError.name:void 0,internalErrorMessage:e.internalError instanceof Error?e.internalError.message:void 0})}static ensure(e){if(e instanceof i)return e;if(e&&typeof e=="object"){let t=e;return t.data&&typeof t.data=="object"?(Object.setPrototypeOf(t,i.prototype),t):new i(t)}return new i}};function g(i){return i.replace(/\\/g,"/").replace(/^a\//,"").replace(/^b\//,"")}s(g,"normalisePath");import{createTwoFilesPatch as p,diffLines as c}from"diff";function D(i,e,t,r=i){return{diff:p(i,r,e,t,"","",{context:3}).replace(/^(?:Index: .*\n)?={3,}\n?/m,"").trimEnd(),stats:m(e,t)}}s(D,"createUnifiedDiff");function m(i,e){let t=0,r=0;for(let n of c(i,e)){let a=h(n.value);n.removed&&(t+=a),n.added&&(r+=a)}return{removed:t,added:r}}s(m,"computeStats");function h(i){if(i.length===0)return 0;let e=i.replaceAll(`\r
|
|
3
|
-
`,`
|
|
4
|
-
`);return e.endsWith(`
|
|
5
|
-
`)?e.slice(0,-1).split(`
|
|
6
|
-
`).length:e.split(`
|
|
7
|
-
`).length}s(h,"countDiffLines");function y(i,e){let t=c(i,e),r=[],n=0;for(let a of t){let o=h(a.value);o!==0&&(a.removed||(a.added&&r.push({start:n+1,end:n+o}),n+=o))}return E(r)}s(y,"computeChangedRanges");function E(i){if(i.length===0)return[];let e=[...i].sort((r,n)=>r.start-n.start),t=[d(e[0])];for(let r=1;r<e.length;r++){let n=d(t.at(-1)),a=d(e[r]);a.start<=n.end+1?n.end=Math.max(n.end,a.end):t.push(a)}return t}s(E,"mergeAdjacentRanges");export{f as a,l as b,D as c,y as d};
|
package/dist/chunk-GXEGY7GV.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{F as d,e as c}from"./chunk-CWD4O5PM.js";import{a as s}from"./chunk-EI7MMDWY.js";import{Type as t}from"typebox";var y=t.Object({query:t.String({minLength:1,description:"Text to find, a Boolean expression, or a prefixed query described below, such as files:*.ts. Quote text to keep it literal, or use regex:<pattern> for regular-expression matching."}),path:t.Optional({...d,description:"File, directory, URL, unchanged Read/Search/Select/edit result, its UUID, or an array of such results. Results select only their registered ranges unless symbols: navigation follows external references."}),navigation:t.Optional(t.Literal("references",{description:"Only for symbols: queries. Explicitly follow symbols represented inside path to their references outside that scope. Without navigation, all returned ranges stay inside path."})),include:t.Optional(t.String({description:"Optional include glob for local search"})),exclude:t.Optional(t.String({description:"Optional exclude glob for local search"})),caseSensitive:t.Optional(t.Boolean({description:"Match letter case"})),wholeWord:t.Optional(t.Boolean({description:"Match complete words"})),limit:t.Optional(t.Integer({minimum:1,maximum:1e3,description:"Maximum detailed results returned to the agent (default 50)"}))},{additionalProperties:!1});import{Type as e}from"typebox";var u=e.Object({startLine:e.Integer(),startColumn:e.Integer(),endLine:e.Integer(),endColumn:e.Integer()},{additionalProperties:!1}),m=e.Object({line:e.Optional(e.String()),match:e.Optional(e.String())},{additionalProperties:!1}),p={source:e.String(),target:e.Optional(e.String()),range:u,matchedText:e.Optional(e.String()),textTruncated:e.Optional(e.Boolean()),references:e.Optional(m)},f=e.Object({...p,captures:e.Optional(e.Record(e.String(),e.Array(e.Object(p,{additionalProperties:!1})))),role:e.Optional(e.Union([e.Literal("definition"),e.Literal("reference")])),symbol:e.Optional(e.Object({id:e.String(),name:e.String(),kind:e.String(),source:e.String(),range:u},{additionalProperties:!1}))},{additionalProperties:!1}),g={target:e.Optional(e.String()),kind:e.Literal("matches"),truncated:e.Optional(e.Boolean()),fullResult:e.Optional(e.String()),complete:e.Boolean(),matches:e.Array(f),all:e.Optional(m),notices:e.Optional(e.Array(e.String()))},h=e.Object({status:e.Union([e.Literal("ready"),e.Literal("skipped")]),message:e.Optional(e.String()),candidates:e.Array(e.Object({identifier:e.String(),kind:e.Union([e.Literal("normalized"),e.Literal("component"),e.Literal("typo")]),reason:e.String(),matchCount:e.Integer(),fileCount:e.Integer(),selection:e.Object(g,{additionalProperties:!1})},{additionalProperties:!1}))},{additionalProperties:!1}),O=e.Union([e.Object({...g,fuzzy:e.Optional(h)},{additionalProperties:!1}),e.Object({kind:e.Literal("files"),complete:e.Boolean(),files:e.Array(e.String())},{additionalProperties:!1}),e.Object({kind:e.Literal("custom"),resolverId:e.String(),value:e.Unknown()},{additionalProperties:!1})]),P=c(O);function T(o,l,r,i){return{kind:"matches",...i?.target===void 0?{}:{target:i.target},truncated:o.length>100,complete:l,matches:o.slice(0,100).map((n,a)=>({source:n.source,...i?.matchTargets?.[a]===void 0?{}:{target:i.matchTargets[a]},range:{startLine:n.lineNumber,startColumn:n.startColumn,endLine:n.endLineNumber??n.lineNumber,endColumn:n.endColumn},...Buffer.byteLength(n.matchedText)<=4096?{matchedText:n.matchedText}:{textTruncated:!0},...r===void 0?{}:{references:{line:`SEARCH#${r}:${a+1}:line`,match:`SEARCH#${r}:${a+1}:match`}}})),...l&&r!==void 0?{all:{line:`SEARCH#${r}:all:line`,match:`SEARCH#${r}:all:match`}}:{}}}s(T,"selectionData");export{y as a,h as b,O as c,P as d,T as e};
|
package/dist/chunk-MBUXFKIW.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as n}from"./chunk-EI7MMDWY.js";function o(e,t){let r=e.context===void 0?"":`
|
|
2
|
-
|
|
3
|
-
${e.context}`;return`[SYSTEM] ${e.toolName} blocked: ${e.field} anchor "${e.anchor}" is stale. If the required line is represented by one of the context lines below, use that anchor. Otherwise, reread only the relevant section of "${e.path}" and regenerate the anchor. (${t})${r}`}n(o,"formatStaleAnchorMessage");export{o as a};
|
package/dist/chunk-PGIVHICI.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as x,e as y,k as E}from"./chunk-4GCWGE2C.js";import{a as g,c as m}from"./chunk-CWD4O5PM.js";import{a as o}from"./chunk-EI7MMDWY.js";import{AsyncLocalStorage as T}from"node:async_hooks";var u=new T,f=new T;function S(t){let e=f.getStore();e?e.push(t):t()}o(S,"afterPostEditScope");async function R(t){if(f.getStore())return t();let e=[];try{return await f.run(e,t)}finally{for(let r of e)r()}}o(R,"collectPostEditNotifications");function A(t,e){let r=u.getStore();return r?(r.set(t,e),!0):!1}o(A,"deferPostEdit");function v(t){return u.getStore()?.has(t)??!1}o(v,"hasDeferredPostEdit");function H(t){u.getStore()?.delete(t)}o(H,"forgetDeferredPostEdit");function j(t=process.cwd()){let e=new Map;return{run(r){return u.run(e,r)},forget(r){e.delete(r)},sources(){return[...e.keys()]},async finish(r){let c=[...e];e.clear();let a=[],i=[];if(await R(async()=>{let s=new g,P=await Promise.allSettled(c.map(([d,p])=>s.run(m(d,t,"write"),p)));for(let d of P){if(d.status==="rejected"){i.push(d.reason);continue}a.push(d.value);try{r?.(d.value)}catch(p){i.push(p)}}}),i.length>0)throw new AggregateError(i,`Some final post-processing failed; completed edits remain applied. ${i.map(s=>s instanceof Error?s.message:String(s)).join("; ")}`);return a}}}o(j,"createPostEditScope");import{Type as n}from"typebox";import{Value as l}from"typebox/value";var b=`${x}/post-edit/register`;function L(t){return l.Check(n.Object({formatting:n.Object({status:n.Union(["disabled","unavailable","skipped-syntax","unchanged","changed","failed","not-reported","deferred"].map(e=>n.Literal(e))),formatter:n.Optional(n.String())})}),t)}o(L,"isFormattingContribution");function z(t){return l.Check(n.Object({diffStatuses:n.Array(n.Object({text:n.String({minLength:1}),formatter:n.Optional(n.String()),tone:n.Optional(n.Union(["muted","success","warning","error"].map(e=>n.Literal(e))))}))}),t)}o(z,"isDiffStatusContribution");var h=n.Function([],n.Unknown()),w=n.Object({id:n.String({minLength:1}),handler:h}),k=n.Object({registration:w,accept:h});function C(t){return l.Check(w,t)}o(C,"isTextPostEditHandlerRegistration");function N(t){return l.Check(k,t)}o(N,"isTextPostEditHandlerRegistrationRequest");function U(t){if(typeof t!="object"||t===null)return!1;let e=t;return Array.isArray(e.hints)&&typeof e.scopeMarkers=="object"&&e.scopeMarkers!==null&&Array.isArray(e.warnings)}o(U,"isTextMutationResultContributionData");function V(t,e){if(!C(e))throw new TypeError("Invalid text editor post-edit handler registration");let r,c=o(()=>{let i={registration:e,accept(s){if(r!==void 0)throw new Error(`Post-edit handler ${e.id} was accepted more than once`);r=s}};return t.events.emit(b,i),r!==void 0},"announce"),a=o(()=>{},"unsubscribeReady");a=t.events.on(y,i=>{if(!E(i))throw new Error("Invalid pi-agent-text-editor core readiness event");if(!c())throw new Error("pi-agent-text-editor core announced readiness without accepting the post-edit handler");a()}),t.on("session_shutdown",()=>{a(),r?.()}),c()&&a()}o(V,"connectTextEditorPostEditHandler");export{S as a,R as b,A as c,v as d,H as e,j as f,b as g,L as h,z as i,C as j,N as k,U as l,V as m};
|
package/dist/chunk-VMTR74FF.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{e as E,f as b}from"./chunk-T7I2VX3J.js";import{d as M}from"./chunk-PGIVHICI.js";import"./chunk-4GCWGE2C.js";import"./chunk-NNCZYO4Q.js";import{d as q}from"./chunk-64M3SQPG.js";import{a as T}from"./chunk-BU7IZLKB.js";import{a as N,b as O}from"./chunk-S5PL5DFQ.js";import"./chunk-PS2B6THP.js";import"./chunk-CWD4O5PM.js";import{e as h,f as w,g as P,h as k,i as y,l as I}from"./chunk-KVHDMIZS.js";import"./chunk-ZPT5D4VP.js";import{a as A}from"./chunk-QDLTO5PH.js";import{a as v,b as C}from"./chunk-QIK2E64R.js";import"./chunk-KINKBPPX.js";import"./chunk-ZC65Z3CK.js";import{a as l}from"./chunk-EI7MMDWY.js";import H from"node:path";var S="diagnostics",L=q({kind:"code-view",label:"Diagnostics"});async function V(r){b(r,[await E({id:"diagnostics",description:"Diagnostic resources, readiness, and verification",triggers:[{tool:"read",resourcePrefixes:["diagnostics:"]}]})]);let i,t=l((c,f,e)=>{if(i===void 0)throw new Error("IDE diagnostics are not connected");return i(c,{cwd:f,...e})},"collect"),s={protocol:v,apiVersion:4,id:"diagnostics",setup(c){i=c.readDiagnostics}},o=new WeakMap,n=new WeakMap,a=new WeakMap,u=new WeakMap,W={protocol:N,apiVersion:O,id:"diagnostics",setup(c){c.addResolver({resolver:j(t,n),renderResult:L});let f=I();c.addView({view:"diagnostics",priority:100,presenter:B(t,u)}),c.addHandler({stage:"read",when:{resolvedBy:"any",contentKind:"text"},handler(e){if(e.state?.resolvedBy==="diagnostics"){let p=e.state.content[0],g=n.get(p);return g&&o.set(e.request,g),f(e)}return e.state?.contentKind==="text"&&e.request.views?.includes("diagnostics")&&a.set(e.request,e.state.text),{kind:"continue",context:e}}}),c.addHandler({stage:"post-read",handler(e){let p=o.get(e.request);if(p&&e.result)return{kind:"continue",context:e,transform:l(d=>({...d,details:{...d.details,diagnosticCheck:p}}),"transform")};let g=a.get(e.request),m=g&&u.get(g),D=e.result,_=D?.content[0];return!m||!D||_?.type!=="text"?{kind:"continue",context:e}:{kind:"continue",context:e,transform(d){let R=d.content[0];return R?.type!=="text"?d:{...d,content:[{...R,text:`${m}
|
|
2
|
-
${R.text}`},...d.content.slice(1)]}}}}}),c.describe({path:"diagnostics:<path> \u2014 lint and language-server diagnostics with reporting tool and readiness. Pending results and snapshots are not completed checks.",views:"diagnostics \u2014 diagnostics alongside source text, with reporting tool and readiness. Pending results and snapshots are not completed checks."})}};await Promise.all([A(r,s),T(r,W)])}l(V,"registerDiagnostics");function j(r,i){return{id:"diagnostics",tryResolve(t,s){return Promise.resolve(x(t,s.cwd,r,i,{signal:s.signal,...s.audience==="script"&&{mode:"complete"}}))}}}l(j,"createDiagnosticResolver");function x(r,i,t,s,o){let n;try{n=h(r,S,i)}catch(a){return{kind:"failed",error:a}}return n===void 0?{kind:"not-handled"}:{kind:"resolved",resource:{source:w(S,n),async read(){let a=await t(n,i,o),u=P(n,a.content,a.results);return s.set(u,u.diagnosticCheck),[u]}}}}l(x,"resolveDiagnosticSource");function B(r,i){return{id:"diagnostics",async present(t,s){if(s.purpose!=="read"||!H.isAbsolute(t.source))return t;let o=s.audience==="script"&&!s.requestedViews?.includes("diagnostics");if(o&&M(t.source))return t;let n=await r(t.source,s.cwd,{signal:s.signal,...s.audience==="script"&&{mode:o?"snapshot":"complete"}}).catch(a=>{if(s.signal?.throwIfAborted(),!o)throw a});if(n===void 0||o&&n.content!==t.content)return t;if(n.content!==t.content)throw new Error("File changed during diagnostic read; read it again for current source lines.");return i.set(t,y(n.results)),k(t,n.results)}}}l(B,"createDiagnosticPresenter");export{V as default};
|
package/dist/chunk-WU6ZK6YD.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as g,d as p}from"./chunk-YP46DVVP.js";import{a as c}from"./chunk-EI7MMDWY.js";import b from"node:path";import{pathToFileURL as C}from"node:url";function S(e,r){let o=new Map;for(let n of e){let t=o.get(n.source)??[];t.push(n),o.set(n.source,t)}let i=new Set,a=e.length,s=[...o].sort(([n,t],[h,l])=>l.length-t.length||n.localeCompare(h));for(let[n,t]of s){if(a<=r)break;i.add(n),a-=t.length}return{files:[...o].sort(([n],[t])=>n.localeCompare(t)).map(([n,t])=>{if(!i.has(n))return{kind:"detailed",source:n,matches:t};let h=new Map;for(let l of t)h.set(l.lineText,(h.get(l.lineText)??0)+1);return{kind:"compacted",source:n,matchCount:t.length,uniqueLineCount:h.size,groups:o.size===1?[...h].sort(([l,d],[m,R])=>R-d||l.localeCompare(m)).slice(0,r).map(([l,d])=>({text:l,matchCount:d})):[]}})}}c(S,"planSearchPresentation");function F(e,r,o,i,a,s=50){let n=S(r,s).files.map(t=>t.kind==="detailed"?k(t.source,t.matches,i):{path:z(t.source,i),link:C(t.source).href,matchCount:t.matchCount,uniqueLineCount:t.uniqueLineCount,groups:t.groups,lines:[]});return{...a!==void 0&&{sessionId:a},query:e,matchCount:r.length,fileCount:n.length,complete:o,files:n}}c(F,"createSearchToolDetails");function D(e,r){return{fileCount:new Set(e.flatMap(o=>o.matches.map(i=>i.source))).size,groups:e.map(o=>{let a=F(o.identifier,o.matches.slice(0,g.previewMatches),o.complete,r).files.map(s=>{let u=s.lines.map(n=>{let t=Math.max(0,(n.ranges[0]?.from??0)-64),h=Math.min(n.text.length,(n.ranges[0]?.to??0)+64),l=t>0?"\u2026":"",d=n.ranges.filter(m=>m.from>=t&&m.to<=h).map(m=>({from:m.from-t+l.length,to:m.to-t+l.length}));return{...n,text:l+n.text.slice(t,h)+(h<n.text.length?"\u2026":""),ranges:d,matchCount:d.length}});return{...s,lines:u,matchCount:u.reduce((n,t)=>n+t.matchCount,0)}});return{identifier:o.identifier,files:a}})}}c(D,"createFuzzyPresentation");function M(e){return f(e)&&y(e.fileCount)&&Array.isArray(e.groups)&&e.groups.every(r=>f(r)&&typeof r.identifier=="string"&&Array.isArray(r.files)&&r.files.every(x))}c(M,"isFuzzyPresentation");function G(e){if(!f(e)||typeof e.query!="string"||!y(e.matchCount)||!y(e.fileCount)||typeof e.complete!="boolean"||e.sessionId!==void 0&&typeof e.sessionId!="string"||e.fuzzy!==void 0&&!p(e.fuzzy)||e.fuzzyPresentation!==void 0&&!M(e.fuzzyPresentation)||!Array.isArray(e.files)||!e.files.every(x))return!1;let r=e.files;return e.fileCount===r.length&&e.matchCount===r.reduce((o,i)=>o+i.matchCount,0)}c(G,"isSearchToolDetails");function k(e,r,o){let i=new Map;for(let s of r){let u=i.get(s.lineNumber);if(u!==void 0&&u.text!==s.lineText)throw new Error(`Search results disagree about line ${String(s.lineNumber)} in ${e}.`);let n=u??{lineNumber:s.lineNumber,text:s.lineText,ranges:[]};n.ranges.push({from:s.startColumn,to:s.endColumn}),i.set(s.lineNumber,n)}let a=[...i.values()].sort((s,u)=>s.lineNumber-u.lineNumber).map(s=>{let u=[...s.ranges].sort((n,t)=>n.from-t.from||n.to-t.to);return{lineNumber:s.lineNumber,text:s.text,matchCount:u.length,ranges:u}});return{path:z(e,o),link:C(e).href,matchCount:r.length,lines:a}}c(k,"createSearchResultFile");function x(e){if(!f(e)||typeof e.path!="string"||typeof e.link!="string"||!y(e.matchCount)||!Array.isArray(e.lines)||!e.lines.every(w))return!1;let r=e.lines,o=e.groups,i=new Set(r.flatMap(a=>a.logicalMatchIds??[]));return(o===void 0||Array.isArray(o)&&o.every(a=>f(a)&&typeof a.text=="string"&&y(a.matchCount)))&&(e.uniqueLineCount===void 0||y(e.uniqueLineCount))&&(r.length===0||(i.size>0?i.size===e.matchCount:e.matchCount===r.reduce((a,s)=>a+s.matchCount,0)))}c(x,"isSearchResultFile");function w(e){return f(e)&&Number.isSafeInteger(e.lineNumber)&&e.lineNumber>=1&&typeof e.text=="string"&&y(e.matchCount)&&Array.isArray(e.ranges)&&e.ranges.length===e.matchCount&&(e.logicalMatchIds===void 0||Array.isArray(e.logicalMatchIds)&&e.logicalMatchIds.every(r=>typeof r=="string"))&&e.ranges.every(r=>L(r,e.text))}c(w,"isSearchResultLine");function L(e,r){return f(e)&&Number.isSafeInteger(e.from)&&Number.isSafeInteger(e.to)&&e.from>=0&&e.to>e.from&&e.to<=r.length}c(L,"isSearchResultRange");function f(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}c(f,"isRecord");function y(e){return Number.isSafeInteger(e)&&e>=0}c(y,"isCount");function z(e,r){let o=b.relative(r,e);return o.length>0&&!o.startsWith("..")&&!b.isAbsolute(o)?o:e}c(z,"displaySource");export{S as a,F as b,D as c,G as d};
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
3
|
-
import { tmpdir } from "node:os";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
|
|
6
|
-
import type { AgentContent, ResourceResolutionAttempt, ResourceResolver } from "pi-agent-resource";
|
|
7
|
-
|
|
8
|
-
export interface TempResourceStoreOptions {
|
|
9
|
-
/** Parent folder for this store's private temporary directory. */
|
|
10
|
-
readonly parentDirectory?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/** Keeps temporary text resources isolated and readable until the owning runtime disposes it. */
|
|
14
|
-
export class TempResourceStore {
|
|
15
|
-
readonly resolver: ResourceResolver;
|
|
16
|
-
readonly #entries = new Map<string, string>();
|
|
17
|
-
readonly #pendingSaves = new Set<Promise<string>>();
|
|
18
|
-
readonly #parentDirectory: string;
|
|
19
|
-
#directoryReady: Promise<string> | undefined;
|
|
20
|
-
#disposal: Promise<void> | undefined;
|
|
21
|
-
|
|
22
|
-
constructor(options: TempResourceStoreOptions = {}) {
|
|
23
|
-
this.#parentDirectory = options.parentDirectory ?? tmpdir();
|
|
24
|
-
this.resolver = {
|
|
25
|
-
id: "temp",
|
|
26
|
-
tryResolve: (source) => Promise.resolve(this.#resolve(source)),
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** Saves text and returns a reference owned by this store. Rejects after disposal starts. */
|
|
31
|
-
async save(text: string): Promise<string> {
|
|
32
|
-
if (this.#disposal !== undefined) {
|
|
33
|
-
throw new Error("Temporary resource store is closed");
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const saving = this.#save(text);
|
|
37
|
-
this.#pendingSaves.add(saving);
|
|
38
|
-
try {
|
|
39
|
-
return await saving;
|
|
40
|
-
} finally {
|
|
41
|
-
this.#pendingSaves.delete(saving);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** Closes the store, waits for pending saves, and removes its private directory. */
|
|
46
|
-
dispose(): Promise<void> {
|
|
47
|
-
this.#disposal ??= this.#dispose();
|
|
48
|
-
return this.#disposal;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async #save(text: string): Promise<string> {
|
|
52
|
-
const directory = await this.#getDirectory();
|
|
53
|
-
const id = randomUUID();
|
|
54
|
-
const source = `temp:${id}`;
|
|
55
|
-
const filePath = path.join(directory, `${id}.txt`);
|
|
56
|
-
await writeFile(filePath, text, { encoding: "utf8", flag: "wx" });
|
|
57
|
-
this.#entries.set(source, filePath);
|
|
58
|
-
return source;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async #dispose(): Promise<void> {
|
|
62
|
-
await Promise.allSettled(this.#pendingSaves);
|
|
63
|
-
this.#entries.clear();
|
|
64
|
-
if (this.#directoryReady !== undefined) {
|
|
65
|
-
await rm(await this.#directoryReady, { recursive: true, force: true });
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
#resolve(source: string): ResourceResolutionAttempt {
|
|
70
|
-
if (!source.startsWith("temp:")) {
|
|
71
|
-
return { kind: "not-handled" };
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (this.#disposal !== undefined || !this.#entries.has(source)) {
|
|
75
|
-
return {
|
|
76
|
-
kind: "failed",
|
|
77
|
-
error: new Error(`Temporary resource ${source} does not exist in this runtime`),
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return {
|
|
82
|
-
kind: "resolved",
|
|
83
|
-
resource: {
|
|
84
|
-
source,
|
|
85
|
-
read: () => this.#read(source),
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
async #read(source: string): Promise<AgentContent> {
|
|
91
|
-
const filePath = this.#entries.get(source);
|
|
92
|
-
if (this.#disposal !== undefined || filePath === undefined) {
|
|
93
|
-
throw new Error(`Temporary resource ${source} does not exist in this runtime`);
|
|
94
|
-
}
|
|
95
|
-
return [{ type: "text", text: await readFile(filePath, "utf8") }];
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
async #getDirectory(): Promise<string> {
|
|
99
|
-
this.#directoryReady ??= (async () => {
|
|
100
|
-
await mkdir(this.#parentDirectory, { recursive: true });
|
|
101
|
-
return mkdtemp(path.join(this.#parentDirectory, "pi-agent-read-"));
|
|
102
|
-
})();
|
|
103
|
-
return this.#directoryReady;
|
|
104
|
-
}
|
|
105
|
-
}
|