pi-agent-ide 0.2.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/README.md +13 -8
- package/dist/chunk-3SE372WC.js +3 -0
- package/dist/chunk-5MSNYFDE.js +1 -0
- package/dist/chunk-5VSE5X5R.js +2 -0
- package/dist/chunk-6DZA4CLO.js +4 -0
- package/dist/chunk-6EYWFBNG.js +0 -0
- package/dist/{chunk-ORAPGW7W.js → chunk-72EEL2DW.js} +1 -1
- package/dist/chunk-7JYQMAEL.js +14 -0
- package/dist/{chunk-T2RPMEM2.js → chunk-7UGNGK7Y.js} +1 -1
- package/dist/{chunk-STUZZM5B.js → chunk-AADJ2KIB.js} +1 -1
- package/dist/{chunk-XF5PVZOS.js → chunk-B5KB2I7J.js} +1 -1
- package/dist/chunk-DQF5QMJ2.js +1 -0
- package/dist/chunk-EJ5OACQM.js +1 -0
- package/dist/chunk-GFW5QPQV.js +2 -0
- package/dist/{chunk-LQYZG62K.js → chunk-GUTQ3PWL.js} +1 -1
- package/dist/chunk-HGPUI7F3.js +1 -0
- package/dist/{chunk-OBWZ5RYN.js → chunk-HKMBQLEK.js} +1 -1
- package/dist/chunk-ITSNK5YG.js +7 -0
- package/dist/chunk-J34VKQGJ.js +1 -0
- package/dist/chunk-KAB3AYA2.js +1 -0
- package/dist/{chunk-76WHES5H.js → chunk-M5L42DWE.js} +5 -5
- package/dist/chunk-M5MJP7Z2.js +1 -0
- package/dist/chunk-NMFQGKPE.js +2 -0
- package/dist/chunk-NTYXZ3EL.js +3 -0
- package/dist/{chunk-P6T3Q7LB.js → chunk-QDST6VIU.js} +1 -1
- package/dist/chunk-ROXXK6TW.js +0 -0
- package/dist/{chunk-WNMGUALD.js → chunk-TI5GMJ7Q.js} +1 -1
- package/dist/{chunk-4ZTEPMJO.js → chunk-TPIHQYK2.js} +1 -1
- package/dist/chunk-XSTHESNR.js +25 -0
- package/dist/{chunk-THSCUT2L.js → chunk-Y7ZMR4LT.js} +1 -1
- package/dist/chunk-YHADTHQM.js +1 -0
- package/dist/{chunk-KZBAJFCV.js → chunk-Z3VC3S2T.js} +1 -1
- package/dist/{chunk-ZXN3TWWW.js → chunk-ZM4L5AGN.js} +1 -1
- package/dist/{chunk-E2RESHYR.js → chunk-ZTYWHL2F.js} +1 -1
- package/dist/entry-0.js +1 -1
- package/dist/entry-1.js +1 -1
- package/dist/entry-10.js +1 -1
- package/dist/entry-12.js +1 -1
- package/dist/entry-13.js +1 -1
- package/dist/entry-14.js +1 -1
- package/dist/entry-2.js +1 -1
- package/dist/entry-21.js +1 -1
- package/dist/entry-24.js +1 -1
- package/dist/entry-25.js +1 -1
- package/dist/entry-26.js +10 -5
- package/dist/entry-28.js +1 -1
- package/dist/entry-29.js +1 -1
- package/dist/entry-31.js +3 -3
- package/dist/entry-32.js +6 -5
- package/dist/entry-36.js +1 -1
- package/dist/entry-37.js +1 -1
- package/dist/entry-38.js +1 -1
- package/dist/entry-39.js +1 -1
- package/dist/entry-4.js +1 -1
- package/dist/entry-40.js +12 -8
- package/dist/entry-42.js +1 -1
- package/dist/entry-43.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +4 -4
- package/dist/entry-46.js +10 -10
- package/dist/entry-47.js +1 -1
- package/dist/entry-48.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +1 -1
- package/dist/entry-51.js +1 -1
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-54.js +1 -0
- package/dist/entry-55.js +0 -1
- package/dist/entry-56.js +1 -0
- package/dist/entry-57.js +0 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-59.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-61.js +1 -1
- package/dist/entry-62.js +1 -1
- package/dist/entry-63.js +1 -0
- package/dist/entry-64.js +0 -1
- package/dist/entry-65.js +1 -0
- package/dist/entry-66.js +0 -1
- package/dist/entry-67.js +1 -1
- package/dist/entry-68.js +1 -1
- package/dist/entry-69.js +1 -59
- package/dist/entry-70.js +123 -4
- package/dist/entry-71.js +30 -1
- package/dist/entry-72.js +2 -29
- package/dist/entry-73.js +1 -2
- package/dist/entry-74.js +1 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-76.js +3 -1
- package/dist/entry-77.js +1 -3
- package/dist/entry-78.js +1 -1
- package/dist/entry-79.js +1 -1
- package/dist/pi-agent-ide.js +3 -2
- package/docs/configuration.md +32 -11
- package/docs/tools.md +17 -0
- package/node_modules/pi-agent-doctor/package.json +1 -1
- package/node_modules/pi-agent-filesystem/package.json +6 -6
- package/node_modules/pi-agent-filesystem-image/package.json +3 -3
- package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
- package/node_modules/pi-agent-filesystem-text/package.json +3 -3
- package/node_modules/pi-agent-ide-ast/package.json +9 -9
- package/node_modules/pi-agent-ide-ast/src/extension.ts +4 -3
- package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +68 -45
- package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +8 -1
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +83 -5
- package/node_modules/pi-agent-ide-changes/index.ts +21 -5
- package/node_modules/pi-agent-ide-changes/package.json +6 -6
- package/node_modules/pi-agent-ide-changes/src/last-text-transaction-store.ts +10 -0
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +4 -2
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-formatter/src/formatter.ts +26 -8
- package/node_modules/pi-agent-ide-formatter/src/registry.ts +9 -1
- package/node_modules/pi-agent-ide-languages/package.json +2 -2
- package/node_modules/pi-agent-ide-lint/index.ts +46 -17
- package/node_modules/pi-agent-ide-lint/package.json +7 -7
- package/node_modules/pi-agent-ide-lint/src/registry.ts +9 -1
- package/node_modules/pi-agent-ide-lsp/index.ts +126 -8
- package/node_modules/pi-agent-ide-lsp/package.json +9 -8
- package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +61 -0
- package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +18 -3
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +4 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +40 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +21 -32
- package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +15 -2
- package/node_modules/pi-agent-ide-lsp/src/lsp/rename.ts +1 -1
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +32 -5
- package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +138 -0
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +9 -2
- package/node_modules/pi-agent-image/package.json +2 -2
- package/node_modules/pi-agent-invariant/package.json +1 -1
- package/node_modules/pi-agent-pdf/package.json +2 -2
- package/node_modules/pi-agent-read/package.json +6 -6
- package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +1 -1
- package/node_modules/pi-agent-read/src/api/read-parameters.ts +29 -0
- package/node_modules/pi-agent-read/src/api/tools/read.ts +73 -1
- package/node_modules/pi-agent-read/src/core/read-core.ts +26 -2
- package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +1 -1
- package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +113 -0
- package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +64 -14
- package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +15 -0
- package/node_modules/pi-agent-read/src/core/tools/read/temp-resource-store.ts +35 -126
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +73 -44
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/resolver.ts +2 -0
- package/node_modules/pi-agent-resource/src/resource.ts +2 -0
- package/node_modules/pi-agent-search/package.json +3 -3
- package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +1 -1
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +25 -0
- package/node_modules/pi-agent-search/src/api/search.ts +55 -1
- package/node_modules/pi-agent-search/src/core/extension.ts +2 -23
- package/node_modules/pi-agent-search/src/core/search-core.ts +28 -3
- package/node_modules/pi-agent-search-text/index.ts +44 -4
- package/node_modules/pi-agent-search-text/package.json +6 -6
- package/node_modules/pi-agent-search-text/src/search-session.ts +65 -25
- package/node_modules/pi-agent-text/package.json +2 -2
- package/node_modules/pi-agent-text/src/text-document.ts +5 -0
- package/node_modules/pi-agent-text/src/text-target.ts +4 -0
- package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +1 -0
- package/node_modules/pi-agent-text-editor/index.ts +1 -3
- package/node_modules/pi-agent-text-editor/package.json +34 -24
- package/node_modules/pi-agent-text-editor/runtime/entry-69.js +0 -1
- package/node_modules/pi-agent-text-editor/src/api/apply-renderer.ts +3 -0
- package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +15 -0
- package/node_modules/pi-agent-text-editor/src/api/last-resolved-resource.ts +5 -0
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +15 -1
- package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +3 -0
- package/node_modules/pi-agent-text-editor/src/api/tool-renderer.ts +3 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +237 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/final-mutations.ts +50 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/format-source.ts +11 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +208 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +39 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +216 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +45 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/queue.ts +25 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +324 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/results.ts +133 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +112 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +132 -0
- package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +205 -0
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +6 -0
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +76 -0
- package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +153 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/diff.ts +5 -2
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +1 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +6 -1
- package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +73 -0
- package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +10 -2
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +17 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +212 -51
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +273 -11
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +1 -1
- package/node_modules/pi-agent-text-editor-renderer/index.ts +88 -1
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +42 -25
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +20 -12
- package/node_modules/pi-agent-text-editor-renderer/src/status-summary.ts +33 -0
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-73.js +1 -0
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-web/package.json +7 -7
- package/node_modules/pi-agent-web/runtime/entry-75.js +2 -0
- package/node_modules/pi-agent-web/src/browser-loader.ts +1 -0
- package/node_modules/pi-agent-web-html/package.json +3 -3
- package/node_modules/pi-agent-web-image/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/package.json +41 -38
- package/src/api/plugin-protocol.ts +10 -2
- package/src/api/tool-config.ts +73 -2
- package/src/code-view/diagnostic-view.ts +22 -3
- package/src/composite/builtin-extensions.ts +10 -15
- package/src/composite/extensions-config.ts +59 -0
- package/src/composite/feature-flags.ts +32 -0
- package/src/composite/module-labels.ts +59 -0
- package/src/composite/module-settings-store.ts +60 -0
- package/src/composite/module-settings.ts +162 -0
- package/src/composite/preferences.ts +26 -0
- package/src/composite/selection.ts +4 -4
- package/src/composite/settings-panel.ts +103 -0
- package/src/core/diagnostic-delivery.ts +29 -0
- package/src/core/diagnostic-entry.ts +51 -3
- package/src/core/diagnostic-store.ts +56 -5
- package/src/core/extension.ts +34 -33
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +6 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-76.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-75.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/browser-loader.ts +1 -0
- package/src/extensions/pi-agent-read/package.json +6 -6
- package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +29 -0
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +73 -1
- package/src/extensions/pi-agent-read/src/core/read-core.ts +26 -2
- package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +1 -1
- package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +113 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +64 -14
- package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +15 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/temp-resource-store.ts +35 -126
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +73 -44
- package/src/extensions/pi-agent-search/package.json +3 -3
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +44 -4
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +6 -6
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +65 -25
- package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +1 -1
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +25 -0
- package/src/extensions/pi-agent-search/src/api/search.ts +55 -1
- package/src/extensions/pi-agent-search/src/core/extension.ts +2 -23
- package/src/extensions/pi-agent-search/src/core/search-core.ts +28 -3
- package/src/extensions/pi-agent-text-editor/index.ts +1 -3
- package/src/extensions/pi-agent-text-editor/package.json +34 -24
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/read-handler.ts +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +88 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +42 -25
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +20 -12
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/status-summary.ts +33 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/runtime/entry-69.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-70.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/apply-renderer.ts +3 -0
- package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +15 -0
- package/src/extensions/pi-agent-text-editor/src/api/last-resolved-resource.ts +5 -0
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +15 -1
- package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +3 -0
- package/src/extensions/pi-agent-text-editor/src/api/tool-renderer.ts +3 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +237 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/final-mutations.ts +50 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/format-source.ts +11 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +208 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +39 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +216 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +45 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/queue.ts +25 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +324 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/results.ts +133 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +112 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +132 -0
- package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +205 -0
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +6 -0
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +76 -0
- package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +153 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/diff.ts +5 -2
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +1 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +6 -1
- package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +73 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +10 -2
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +17 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +212 -51
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +273 -11
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +1 -1
- package/src/pi-agent-ide.ts +43 -8
- package/src/plugins/pi-agent-ide-ast/package.json +9 -9
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +4 -3
- package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +68 -45
- package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +8 -1
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +83 -5
- package/src/plugins/pi-agent-ide-changes/index.ts +21 -5
- package/src/plugins/pi-agent-ide-changes/package.json +6 -6
- package/src/plugins/pi-agent-ide-changes/src/last-text-transaction-store.ts +10 -0
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +4 -2
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +62 -11
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +26 -8
- package/src/plugins/pi-agent-ide-formatter/src/registry.ts +9 -1
- package/src/plugins/pi-agent-ide-languages/package.json +2 -2
- package/src/plugins/pi-agent-ide-lint/index.ts +46 -17
- package/src/plugins/pi-agent-ide-lint/package.json +7 -7
- package/src/plugins/pi-agent-ide-lint/src/registry.ts +9 -1
- package/src/plugins/pi-agent-ide-lsp/index.ts +126 -8
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -8
- package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +61 -0
- package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +18 -3
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +4 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +40 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +21 -32
- package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +15 -2
- package/src/plugins/pi-agent-ide-lsp/src/lsp/rename.ts +1 -1
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +32 -5
- package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +138 -0
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +9 -2
- package/src/plugins/pi-agent-ide-terminal/index.ts +34 -0
- package/src/plugins/pi-agent-ide-terminal/src/renderer.ts +238 -0
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +461 -0
- package/src/plugins/pi-agent-ide-terminal/src/screen-image.ts +127 -0
- package/src/plugins/pi-agent-ide-terminal/src/search.ts +159 -0
- package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +529 -0
- package/src/plugins/pi-agent-ide-terminal/src/shell-profile.ts +56 -0
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +157 -0
- package/src/plugins/pi-agent-ide-terminal/src/types.ts +66 -0
- package/src/plugins/pi-agent-ide-terminal/src/ui.ts +336 -0
- package/src/post-edit/gate.ts +15 -2
- package/dist/chunk-4U6KGABH.js +0 -1
- package/dist/chunk-6ACQQBUY.js +0 -7
- package/dist/chunk-GFWDXTOB.js +0 -4
- package/dist/chunk-JASLOB2X.js +0 -1
- package/dist/chunk-JJVXUL5U.js +0 -2
- package/dist/chunk-KCEOTU5Z.js +0 -3
- package/dist/chunk-KVGQG43U.js +0 -1
- package/dist/chunk-QJFRAMK7.js +0 -2
- package/dist/chunk-RAZOACDD.js +0 -2
- package/dist/chunk-RIGRP3FD.js +0 -1
- package/dist/chunk-VCCMVQXU.js +0 -1
- package/dist/chunk-X6MPU7UO.js +0 -3
- package/dist/chunk-YPHXLAQF.js +0 -1
- package/dist/entry-80.js +0 -1
- package/node_modules/pi-agent-text-editor/src/core/tool-description.ts +0 -14
- package/node_modules/pi-agent-text-editor-argument-order/index.ts +0 -26
- package/node_modules/pi-agent-text-editor-argument-order/package.json +0 -16
- package/node_modules/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +0 -100
- package/node_modules/pi-agent-text-editor-overwrite/index.ts +0 -365
- package/node_modules/pi-agent-text-editor-overwrite/package.json +0 -17
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +0 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-75.js +0 -1
- package/node_modules/pi-agent-web-text/runtime/entry-80.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-80.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-76.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/index.ts +0 -26
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/package.json +0 -16
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/runtime/entry-70.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +0 -100
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/index.ts +0 -365
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +0 -17
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +0 -2
- package/src/extensions/pi-agent-text-editor/src/core/tool-description.ts +0 -14
- /package/dist/{chunk-3H2EU7VQ.js → chunk-4U2GUKNJ.js} +0 -0
- /package/node_modules/{pi-agent-text-editor-argument-order → pi-agent-text-editor}/runtime/entry-70.js +0 -0
- /package/node_modules/{pi-agent-text-editor-overwrite → pi-agent-text-editor-renderer}/runtime/entry-71.js +0 -0
- /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-72.js +0 -0
- /package/node_modules/{pi-agent-tool-call-interception → pi-agent-tool-ui}/runtime/entry-74.js +0 -0
- /package/node_modules/{pi-agent-web → pi-agent-web-html}/runtime/entry-76.js +0 -0
- /package/node_modules/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-77.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-78.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-79.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-77.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-78.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-79.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-overwrite → pi-agent-text-editor-renderer}/runtime/entry-71.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-72.js +0 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import os from "node:os";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
import type { ShellProfile } from "#src/plugins/pi-agent-ide-terminal/src/types.js";
|
|
5
|
+
|
|
6
|
+
/** Resolve the shell configured for the current user and describe its command syntax. */
|
|
7
|
+
export function resolveShellProfile(
|
|
8
|
+
platform: NodeJS.Platform = process.platform,
|
|
9
|
+
environment: NodeJS.ProcessEnv = process.env,
|
|
10
|
+
): ShellProfile {
|
|
11
|
+
if (platform === "win32") {
|
|
12
|
+
const executable = environment.SHELL?.trim() || "powershell.exe";
|
|
13
|
+
const basename = path.win32.basename(executable).toLowerCase();
|
|
14
|
+
if (basename === "cmd" || basename === "cmd.exe") {
|
|
15
|
+
return {
|
|
16
|
+
executable,
|
|
17
|
+
displayName: "Command Prompt",
|
|
18
|
+
family: "cmd",
|
|
19
|
+
commandArgs: (command) => ["/d", "/s", "/c", command],
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
executable,
|
|
24
|
+
displayName: basename.startsWith("pwsh") ? "PowerShell" : "Windows PowerShell",
|
|
25
|
+
family: "powershell",
|
|
26
|
+
commandArgs: (command) => ["-NoLogo", "-NoProfile", "-Command", command],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const executable =
|
|
31
|
+
environment.SHELL?.trim() ||
|
|
32
|
+
os.userInfo().shell ||
|
|
33
|
+
(platform === "darwin" ? "/bin/zsh" : "/bin/bash");
|
|
34
|
+
const basename = path.basename(executable);
|
|
35
|
+
return {
|
|
36
|
+
executable,
|
|
37
|
+
displayName: basename === "zsh" ? "zsh" : basename === "bash" ? "Bash" : basename,
|
|
38
|
+
family: "posix",
|
|
39
|
+
commandArgs: (command) => ["-c", command],
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Return concise syntax guidance for the shell exposed to the agent. */
|
|
44
|
+
export function shellSyntaxGuidance(profile: ShellProfile): string {
|
|
45
|
+
switch (profile.family) {
|
|
46
|
+
case "powershell": {
|
|
47
|
+
return "Write PowerShell syntax. Use PowerShell cmdlets, `$env:NAME` for environment variables, and `;` or pipelines to compose commands.";
|
|
48
|
+
}
|
|
49
|
+
case "cmd": {
|
|
50
|
+
return "Write Command Prompt syntax. Use `%NAME%` for environment variables and `&&` to chain successful commands.";
|
|
51
|
+
}
|
|
52
|
+
case "posix": {
|
|
53
|
+
return `Write ${profile.displayName} syntax. Use POSIX-style paths, \`$NAME\` for environment variables, and \`&&\` or pipelines to compose commands.`;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { stripVTControlCharacters } from "node:util";
|
|
3
|
+
|
|
4
|
+
import { defineTool, type ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
5
|
+
import { Type } from "typebox";
|
|
6
|
+
|
|
7
|
+
import { COMPACT_READ_ROWS } from "#src/extensions/pi-agent-read/src/core/tools/read/read-renderer.js";
|
|
8
|
+
import { renderRunCall, renderRunResult } from "#src/plugins/pi-agent-ide-terminal/src/renderer.js";
|
|
9
|
+
|
|
10
|
+
import { shellSyntaxGuidance } from "#src/plugins/pi-agent-ide-terminal/src/shell-profile.js";
|
|
11
|
+
import type { TerminalSessionManager } from "#src/plugins/pi-agent-ide-terminal/src/session-manager.js";
|
|
12
|
+
import type { TerminalUi } from "#src/plugins/pi-agent-ide-terminal/src/ui.js";
|
|
13
|
+
import type {
|
|
14
|
+
ShellProfile,
|
|
15
|
+
TerminalSessionSnapshot,
|
|
16
|
+
} from "#src/plugins/pi-agent-ide-terminal/src/types.js";
|
|
17
|
+
|
|
18
|
+
const runParameters = Type.Object(
|
|
19
|
+
{
|
|
20
|
+
command: Type.String({
|
|
21
|
+
minLength: 1,
|
|
22
|
+
description: "Command written in the syntax of the configured system shell",
|
|
23
|
+
}),
|
|
24
|
+
background: Type.Optional(
|
|
25
|
+
Type.Boolean({
|
|
26
|
+
description: "Return immediately while the terminal session continues. Defaults to false.",
|
|
27
|
+
}),
|
|
28
|
+
),
|
|
29
|
+
cwd: Type.Optional(
|
|
30
|
+
Type.String({
|
|
31
|
+
description: "Working directory. Relative paths resolve from the current workspace.",
|
|
32
|
+
}),
|
|
33
|
+
),
|
|
34
|
+
cols: Type.Optional(
|
|
35
|
+
Type.Integer({ minimum: 20, maximum: 300, description: "Virtual terminal width in cells" }),
|
|
36
|
+
),
|
|
37
|
+
rows: Type.Optional(
|
|
38
|
+
Type.Integer({ minimum: 5, maximum: 120, description: "Virtual terminal height in cells" }),
|
|
39
|
+
),
|
|
40
|
+
},
|
|
41
|
+
{ additionalProperties: false },
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
/** Register terminal process lifecycle tools with platform-specific shell guidance. */
|
|
45
|
+
export function registerTerminalTools(
|
|
46
|
+
pi: ExtensionAPI,
|
|
47
|
+
manager: TerminalSessionManager,
|
|
48
|
+
profile: ShellProfile,
|
|
49
|
+
ui: Pick<TerminalUi, "bind">,
|
|
50
|
+
): void {
|
|
51
|
+
pi.registerTool(
|
|
52
|
+
defineTool<typeof runParameters, TerminalSessionSnapshot>({
|
|
53
|
+
name: "run",
|
|
54
|
+
label: `${profile.displayName} run`,
|
|
55
|
+
promptSnippet: `Run ${profile.displayName} commands in synchronous or background terminal sessions`,
|
|
56
|
+
promptGuidelines: [
|
|
57
|
+
`Write commands for ${profile.displayName}; commands are not translated between shell languages.`,
|
|
58
|
+
"Use background for servers, watchers, long builds, and work that can finish while you continue. Use the returned shell: source with read, write, insert, and delete.",
|
|
59
|
+
],
|
|
60
|
+
description: `Use run to execute a command in the user's configured ${profile.displayName} shell (${profile.executable}). Every call creates an addressable terminal session. Set background to true to continue without waiting; completion is delivered automatically and wakes the agent. ${shellSyntaxGuidance(profile)}`,
|
|
61
|
+
parameters: runParameters,
|
|
62
|
+
async execute(_toolCallId, input, signal, onUpdate, context) {
|
|
63
|
+
ui.bind(context);
|
|
64
|
+
const cwd = input.cwd === undefined ? context.cwd : path.resolve(context.cwd, input.cwd);
|
|
65
|
+
const session = manager.start({
|
|
66
|
+
command: input.command,
|
|
67
|
+
background: input.background ?? false,
|
|
68
|
+
cwd,
|
|
69
|
+
shell: profile,
|
|
70
|
+
...(input.cols === undefined ? {} : { cols: input.cols }),
|
|
71
|
+
...(input.rows === undefined ? {} : { rows: input.rows }),
|
|
72
|
+
});
|
|
73
|
+
if (input.background === true && session.status !== "failed") {
|
|
74
|
+
await captureInitialBackgroundPreview(manager, session, onUpdate);
|
|
75
|
+
if (session.status !== "running") session.completionDelivered = true;
|
|
76
|
+
return terminalResult(manager.snapshot(session));
|
|
77
|
+
}
|
|
78
|
+
if (session.status === "failed") return terminalResult(manager.snapshot(session));
|
|
79
|
+
const completed = await manager.wait(session.source, signal);
|
|
80
|
+
return terminalResult(manager.snapshot(completed));
|
|
81
|
+
},
|
|
82
|
+
renderCall(args, theme) {
|
|
83
|
+
const command = typeof args.command === "string" ? args.command : "";
|
|
84
|
+
const cwd =
|
|
85
|
+
typeof args.cwd === "string" ? path.resolve(process.cwd(), args.cwd) : process.cwd();
|
|
86
|
+
return renderRunCall(command, args.background === true, cwd, profile, theme);
|
|
87
|
+
},
|
|
88
|
+
renderResult(result, options, theme) {
|
|
89
|
+
return renderRunResult(
|
|
90
|
+
result.details as Partial<TerminalSessionSnapshot>,
|
|
91
|
+
options.expanded,
|
|
92
|
+
theme,
|
|
93
|
+
);
|
|
94
|
+
},
|
|
95
|
+
}),
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function terminalResult(snapshot: TerminalSessionSnapshot) {
|
|
100
|
+
const excerpt = outputExcerpt(snapshot.output);
|
|
101
|
+
const lines = [
|
|
102
|
+
`session: ${snapshot.source}`,
|
|
103
|
+
`status: ${snapshot.status}`,
|
|
104
|
+
`shell: ${snapshot.shell}`,
|
|
105
|
+
`cwd: ${snapshot.cwd}`,
|
|
106
|
+
`elapsedMs: ${snapshot.elapsedMs}`,
|
|
107
|
+
snapshot.exitCode === undefined ? undefined : `exitCode: ${snapshot.exitCode}`,
|
|
108
|
+
snapshot.signal === undefined ? undefined : `signal: ${snapshot.signal}`,
|
|
109
|
+
snapshot.error === undefined ? undefined : `error: ${snapshot.error}`,
|
|
110
|
+
`outputRange: ${snapshot.outputStart}-${snapshot.outputEnd}`,
|
|
111
|
+
snapshot.truncated ? "output: truncated; use read for the retained log" : undefined,
|
|
112
|
+
excerpt.length === 0 ? "output: (empty)" : `output:\n${excerpt}`,
|
|
113
|
+
].filter((line): line is string => line !== undefined);
|
|
114
|
+
return {
|
|
115
|
+
content: [{ type: "text" as const, text: lines.join("\n") }],
|
|
116
|
+
details: snapshot,
|
|
117
|
+
isError: snapshot.status === "failed" || snapshot.status === "lost",
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function outputExcerpt(output: string): string {
|
|
122
|
+
const plain = stripVTControlCharacters(output).trimEnd();
|
|
123
|
+
return plain.length <= 8_000 ? plain : `[earlier output omitted]\n${plain.slice(-8_000)}`;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async function captureInitialBackgroundPreview(
|
|
127
|
+
manager: TerminalSessionManager,
|
|
128
|
+
session: ReturnType<TerminalSessionManager["start"]>,
|
|
129
|
+
onUpdate: ((result: ReturnType<typeof terminalResult>) => void) | undefined,
|
|
130
|
+
): Promise<void> {
|
|
131
|
+
await new Promise<void>((resolve) => {
|
|
132
|
+
let settled = false;
|
|
133
|
+
let timeout: ReturnType<typeof setTimeout>;
|
|
134
|
+
let unsubscribe = (): void => {};
|
|
135
|
+
const finish = (): void => {
|
|
136
|
+
if (settled) return;
|
|
137
|
+
settled = true;
|
|
138
|
+
clearTimeout(timeout);
|
|
139
|
+
unsubscribe();
|
|
140
|
+
resolve();
|
|
141
|
+
};
|
|
142
|
+
const publish = (): void => {
|
|
143
|
+
const snapshot = manager.snapshot(session);
|
|
144
|
+
onUpdate?.(terminalResult(snapshot));
|
|
145
|
+
const rows = stripVTControlCharacters(snapshot.output)
|
|
146
|
+
.replaceAll("\r", "")
|
|
147
|
+
.split("\n")
|
|
148
|
+
.filter((line) => line.length > 0).length;
|
|
149
|
+
if (rows >= COMPACT_READ_ROWS || snapshot.status !== "running") finish();
|
|
150
|
+
};
|
|
151
|
+
unsubscribe = manager.onDidChange((changed) => {
|
|
152
|
+
if (changed.id === session.id) publish();
|
|
153
|
+
});
|
|
154
|
+
timeout = setTimeout(finish, 2_000);
|
|
155
|
+
publish();
|
|
156
|
+
});
|
|
157
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { IPty } from "node-pty";
|
|
2
|
+
import type { Terminal } from "@xterm/headless";
|
|
3
|
+
|
|
4
|
+
export type TerminalSessionStatus =
|
|
5
|
+
| "running"
|
|
6
|
+
| "completed"
|
|
7
|
+
| "failed"
|
|
8
|
+
| "stopping"
|
|
9
|
+
| "stopped"
|
|
10
|
+
| "cancelled"
|
|
11
|
+
| "lost";
|
|
12
|
+
|
|
13
|
+
export interface ShellProfile {
|
|
14
|
+
readonly executable: string;
|
|
15
|
+
readonly displayName: string;
|
|
16
|
+
readonly family: "posix" | "powershell" | "cmd";
|
|
17
|
+
readonly commandArgs: (command: string) => readonly string[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface TerminalSession {
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly source: string;
|
|
23
|
+
readonly command: string;
|
|
24
|
+
readonly background: boolean;
|
|
25
|
+
readonly cwd: string;
|
|
26
|
+
readonly shell: ShellProfile;
|
|
27
|
+
readonly startedAt: number;
|
|
28
|
+
readonly cols: number;
|
|
29
|
+
readonly rows: number;
|
|
30
|
+
readonly process?: IPty;
|
|
31
|
+
readonly screen: Terminal;
|
|
32
|
+
status: TerminalSessionStatus;
|
|
33
|
+
endedAt?: number;
|
|
34
|
+
exitCode?: number;
|
|
35
|
+
signal?: number;
|
|
36
|
+
error?: string;
|
|
37
|
+
output: string;
|
|
38
|
+
outputStart: number;
|
|
39
|
+
screenReady: Promise<void>;
|
|
40
|
+
completion: Promise<TerminalSession>;
|
|
41
|
+
resolveCompletion: (session: TerminalSession) => void;
|
|
42
|
+
completionDelivered: boolean;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface TerminalSessionSnapshot {
|
|
46
|
+
readonly id: string;
|
|
47
|
+
readonly source: string;
|
|
48
|
+
readonly command: string;
|
|
49
|
+
readonly cwd: string;
|
|
50
|
+
readonly shell: string;
|
|
51
|
+
readonly shellFamily: ShellProfile["family"];
|
|
52
|
+
readonly background: boolean;
|
|
53
|
+
readonly status: TerminalSessionStatus;
|
|
54
|
+
readonly startedAt: number;
|
|
55
|
+
readonly endedAt?: number;
|
|
56
|
+
readonly elapsedMs: number;
|
|
57
|
+
readonly exitCode?: number;
|
|
58
|
+
readonly signal?: number;
|
|
59
|
+
readonly error?: string;
|
|
60
|
+
readonly output: string;
|
|
61
|
+
readonly outputStart: number;
|
|
62
|
+
readonly outputEnd: number;
|
|
63
|
+
readonly truncated: boolean;
|
|
64
|
+
readonly cols: number;
|
|
65
|
+
readonly rows: number;
|
|
66
|
+
}
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DynamicBorder,
|
|
3
|
+
type ExtensionAPI,
|
|
4
|
+
type ExtensionContext,
|
|
5
|
+
} from "@earendil-works/pi-coding-agent";
|
|
6
|
+
import {
|
|
7
|
+
Box,
|
|
8
|
+
Container,
|
|
9
|
+
Key,
|
|
10
|
+
matchesKey,
|
|
11
|
+
SelectList,
|
|
12
|
+
Text,
|
|
13
|
+
truncateToWidth,
|
|
14
|
+
type SelectItem,
|
|
15
|
+
} from "@earendil-works/pi-tui";
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
renderTerminalResult,
|
|
19
|
+
renderTerminalWidgetLines,
|
|
20
|
+
} from "#src/plugins/pi-agent-ide-terminal/src/renderer.js";
|
|
21
|
+
import type { TerminalSessionManager } from "#src/plugins/pi-agent-ide-terminal/src/session-manager.js";
|
|
22
|
+
import type {
|
|
23
|
+
TerminalSession,
|
|
24
|
+
TerminalSessionSnapshot,
|
|
25
|
+
} from "#src/plugins/pi-agent-ide-terminal/src/types.js";
|
|
26
|
+
|
|
27
|
+
const COMPLETION_DELAY_MS = 120;
|
|
28
|
+
|
|
29
|
+
/** Keeps background terminal status and completion rendering separate from agent result data. */
|
|
30
|
+
export class TerminalUi {
|
|
31
|
+
readonly #pending = new Map<string, TerminalSession>();
|
|
32
|
+
#context: ExtensionContext | undefined;
|
|
33
|
+
#deliveryTimer: ReturnType<typeof setTimeout> | undefined;
|
|
34
|
+
#elapsedTimer: ReturnType<typeof setInterval> | undefined;
|
|
35
|
+
#closed = false;
|
|
36
|
+
|
|
37
|
+
public constructor(
|
|
38
|
+
private readonly pi: ExtensionAPI,
|
|
39
|
+
private readonly manager: TerminalSessionManager,
|
|
40
|
+
private readonly activityMode: "detailed" | "compact" | "off",
|
|
41
|
+
) {
|
|
42
|
+
pi.registerMessageRenderer("terminal-completion", (message, { expanded }, theme) => {
|
|
43
|
+
const content = new Container();
|
|
44
|
+
for (const session of completionSnapshots(message.details)) {
|
|
45
|
+
content.addChild(renderTerminalResult(session, expanded, theme));
|
|
46
|
+
}
|
|
47
|
+
const card = new Box(1, 1, (line) => theme.bg("toolSuccessBg", line));
|
|
48
|
+
card.addChild(content);
|
|
49
|
+
return card;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
manager.onDidChange(() => this.#renderActive());
|
|
53
|
+
manager.onDidComplete((session) => {
|
|
54
|
+
if (session.background) this.#queueCompletion(session);
|
|
55
|
+
this.#renderActive();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
pi.registerCommand("terminals", {
|
|
59
|
+
description: "Show active and recent terminal sessions",
|
|
60
|
+
handler: async (_args, context) => {
|
|
61
|
+
this.bind(context);
|
|
62
|
+
if (context.mode !== "tui") {
|
|
63
|
+
context.ui.notify("The terminal session overlay requires the TUI.", "info");
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
await this.#showOverlay(context);
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public bind(context: ExtensionContext): void {
|
|
72
|
+
if (this.#closed) return;
|
|
73
|
+
this.#context = context;
|
|
74
|
+
this.#renderActive();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public dispose(): void {
|
|
78
|
+
this.#closed = true;
|
|
79
|
+
if (this.#deliveryTimer !== undefined) clearTimeout(this.#deliveryTimer);
|
|
80
|
+
if (this.#elapsedTimer !== undefined) clearInterval(this.#elapsedTimer);
|
|
81
|
+
this.#deliveryTimer = undefined;
|
|
82
|
+
this.#elapsedTimer = undefined;
|
|
83
|
+
this.#context?.ui.setWidget("agent-terminal", undefined);
|
|
84
|
+
this.#context?.ui.setStatus("agent-terminal", undefined);
|
|
85
|
+
this.#pending.clear();
|
|
86
|
+
this.#context = undefined;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
#queueCompletion(session: TerminalSession): void {
|
|
90
|
+
if (this.#closed || session.completionDelivered) return;
|
|
91
|
+
this.#pending.set(session.id, session);
|
|
92
|
+
if (this.#deliveryTimer !== undefined) return;
|
|
93
|
+
this.#deliveryTimer = setTimeout(() => {
|
|
94
|
+
this.#deliveryTimer = undefined;
|
|
95
|
+
const sessions = [...this.#pending.values()].filter(
|
|
96
|
+
(session) => !session.completionDelivered,
|
|
97
|
+
);
|
|
98
|
+
this.#pending.clear();
|
|
99
|
+
if (this.#closed || sessions.length === 0) return;
|
|
100
|
+
for (const completed of sessions) completed.completionDelivered = true;
|
|
101
|
+
const snapshots = sessions.map((completed) => this.manager.snapshot(completed));
|
|
102
|
+
const content = formatCompletionMessage(snapshots);
|
|
103
|
+
this.pi.sendMessage(
|
|
104
|
+
{
|
|
105
|
+
customType: "terminal-completion",
|
|
106
|
+
display: true,
|
|
107
|
+
content,
|
|
108
|
+
details: { sessions: snapshots },
|
|
109
|
+
},
|
|
110
|
+
{ triggerTurn: true, deliverAs: "steer" },
|
|
111
|
+
);
|
|
112
|
+
}, COMPLETION_DELAY_MS);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
#renderActive(): void {
|
|
116
|
+
const context = this.#context;
|
|
117
|
+
if (this.#closed || context === undefined || !context.hasUI) return;
|
|
118
|
+
const active = this.manager
|
|
119
|
+
.list()
|
|
120
|
+
.filter((session) => session.status === "running" || session.status === "stopping");
|
|
121
|
+
if (this.activityMode === "off") {
|
|
122
|
+
context.ui.setWidget("agent-terminal", undefined);
|
|
123
|
+
context.ui.setStatus("agent-terminal", undefined);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (active.length === 0) {
|
|
127
|
+
context.ui.setWidget("agent-terminal", undefined);
|
|
128
|
+
context.ui.setStatus("agent-terminal", undefined);
|
|
129
|
+
if (this.#elapsedTimer !== undefined) clearInterval(this.#elapsedTimer);
|
|
130
|
+
this.#elapsedTimer = undefined;
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (this.activityMode === "compact") {
|
|
134
|
+
context.ui.setWidget("agent-terminal", undefined);
|
|
135
|
+
context.ui.setStatus("agent-terminal", `terminals: ${active.length}`);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
context.ui.setStatus("agent-terminal", undefined);
|
|
139
|
+
context.ui.setWidget(
|
|
140
|
+
"agent-terminal",
|
|
141
|
+
(_tui, theme) => ({
|
|
142
|
+
invalidate() {},
|
|
143
|
+
render: (width: number) => renderTerminalWidgetLines(active, width, theme),
|
|
144
|
+
}),
|
|
145
|
+
{ placement: "belowEditor" },
|
|
146
|
+
);
|
|
147
|
+
if (this.#elapsedTimer === undefined) {
|
|
148
|
+
this.#elapsedTimer = setInterval(() => this.#renderActive(), 1_000);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async #showOverlay(context: ExtensionContext): Promise<void> {
|
|
153
|
+
for (;;) {
|
|
154
|
+
const sessions = this.manager
|
|
155
|
+
.list()
|
|
156
|
+
.filter((session) => session.status === "running" || session.status === "stopping");
|
|
157
|
+
if (sessions.length === 0) {
|
|
158
|
+
context.ui.notify("No active terminal sessions.", "info");
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const action = await context.ui.custom<TerminalOverlayAction | null>(
|
|
162
|
+
(tui, theme, _keybindings, done) => {
|
|
163
|
+
const items: SelectItem[] = sessions.map((session) => ({
|
|
164
|
+
value: session.source,
|
|
165
|
+
label: `${session.status} ${formatElapsed(session.elapsedMs)} ${session.shell}`,
|
|
166
|
+
description: shortCommand(session.command, 90),
|
|
167
|
+
}));
|
|
168
|
+
const list = new SelectList(items, Math.min(items.length, 12), {
|
|
169
|
+
selectedPrefix: (text) => theme.fg("accent", text),
|
|
170
|
+
selectedText: (text) => theme.fg("accent", text),
|
|
171
|
+
description: (text) => theme.fg("muted", text),
|
|
172
|
+
scrollInfo: (text) => theme.fg("dim", text),
|
|
173
|
+
noMatch: (text) => theme.fg("warning", text),
|
|
174
|
+
});
|
|
175
|
+
let page: "list" | "detail" | "confirm" = "list";
|
|
176
|
+
let selectedSource: string | undefined;
|
|
177
|
+
list.onSelect = (item) => {
|
|
178
|
+
selectedSource = item.value;
|
|
179
|
+
page = "detail";
|
|
180
|
+
};
|
|
181
|
+
list.onCancel = () => done(null);
|
|
182
|
+
return {
|
|
183
|
+
render: (width: number) => {
|
|
184
|
+
const container = new Container();
|
|
185
|
+
container.addChild(new DynamicBorder((text: string) => theme.fg("accent", text)));
|
|
186
|
+
if (page === "list") {
|
|
187
|
+
container.addChild(
|
|
188
|
+
new Text(theme.fg("accent", theme.bold("Terminal sessions")), 1, 0),
|
|
189
|
+
);
|
|
190
|
+
container.addChild(list);
|
|
191
|
+
container.addChild(
|
|
192
|
+
new Text(theme.fg("dim", "enter view · d delete · esc close"), 1, 0),
|
|
193
|
+
);
|
|
194
|
+
} else {
|
|
195
|
+
const session =
|
|
196
|
+
selectedSource === undefined ? undefined : this.manager.get(selectedSource);
|
|
197
|
+
if (session === undefined) {
|
|
198
|
+
container.addChild(
|
|
199
|
+
new Text(theme.fg("warning", "Terminal is no longer available."), 1, 0),
|
|
200
|
+
);
|
|
201
|
+
} else {
|
|
202
|
+
const snapshot = this.manager.snapshot(session);
|
|
203
|
+
container.addChild(
|
|
204
|
+
new Text(theme.fg("accent", theme.bold(`${snapshot.shell} terminal`)), 1, 0),
|
|
205
|
+
);
|
|
206
|
+
container.addChild(
|
|
207
|
+
new Text(
|
|
208
|
+
theme.fg(
|
|
209
|
+
"muted",
|
|
210
|
+
truncateToWidth(
|
|
211
|
+
`${snapshot.status} · ${formatElapsed(snapshot.elapsedMs)} · ${snapshot.cwd}`,
|
|
212
|
+
Math.max(1, width - 2),
|
|
213
|
+
),
|
|
214
|
+
),
|
|
215
|
+
1,
|
|
216
|
+
0,
|
|
217
|
+
),
|
|
218
|
+
);
|
|
219
|
+
container.addChild(new Text(theme.fg("text", `$ ${snapshot.command}`), 1, 0));
|
|
220
|
+
const rows = visibleScreenTail(this.manager.screenRows(session), 24);
|
|
221
|
+
container.addChild(
|
|
222
|
+
new Text(
|
|
223
|
+
rows.map((row) => theme.fg("toolOutput", row || " ")).join("\n"),
|
|
224
|
+
1,
|
|
225
|
+
0,
|
|
226
|
+
),
|
|
227
|
+
);
|
|
228
|
+
container.addChild(
|
|
229
|
+
new Text(
|
|
230
|
+
theme.fg(
|
|
231
|
+
page === "confirm" ? "warning" : "dim",
|
|
232
|
+
page === "confirm"
|
|
233
|
+
? "Delete this terminal session? y confirm · n/esc cancel"
|
|
234
|
+
: "esc back · d delete",
|
|
235
|
+
),
|
|
236
|
+
1,
|
|
237
|
+
0,
|
|
238
|
+
),
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
container.addChild(new DynamicBorder((text: string) => theme.fg("accent", text)));
|
|
243
|
+
return container.render(width);
|
|
244
|
+
},
|
|
245
|
+
handleInput: (data: string) => {
|
|
246
|
+
if (page === "list") {
|
|
247
|
+
if (data === "d") {
|
|
248
|
+
selectedSource = list.getSelectedItem()?.value;
|
|
249
|
+
if (selectedSource !== undefined) page = "confirm";
|
|
250
|
+
} else {
|
|
251
|
+
list.handleInput(data);
|
|
252
|
+
}
|
|
253
|
+
} else if (page === "detail") {
|
|
254
|
+
if (matchesKey(data, Key.escape)) page = "list";
|
|
255
|
+
else if (data === "d") page = "confirm";
|
|
256
|
+
} else if (data === "y" && selectedSource !== undefined) {
|
|
257
|
+
done({ kind: "delete", source: selectedSource });
|
|
258
|
+
} else if (data === "n" || matchesKey(data, Key.escape)) {
|
|
259
|
+
page = "detail";
|
|
260
|
+
}
|
|
261
|
+
tui.requestRender();
|
|
262
|
+
},
|
|
263
|
+
invalidate: () => list.invalidate(),
|
|
264
|
+
};
|
|
265
|
+
},
|
|
266
|
+
{ overlay: true, overlayOptions: { width: "75%", maxHeight: "80%", minWidth: 52 } },
|
|
267
|
+
);
|
|
268
|
+
if (action === null) return;
|
|
269
|
+
await this.manager.delete(action.source);
|
|
270
|
+
context.ui.notify("Terminal session deleted.", "info");
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function visibleScreenTail(rows: readonly string[], limit: number): readonly string[] {
|
|
276
|
+
const first = rows.findIndex((row) => row.length > 0);
|
|
277
|
+
if (first === -1) return ["(no visible output)"];
|
|
278
|
+
let last = rows.length - 1;
|
|
279
|
+
while (last > first && rows[last]?.length === 0) last -= 1;
|
|
280
|
+
return rows.slice(Math.max(first, last - limit + 1), last + 1);
|
|
281
|
+
}
|
|
282
|
+
type TerminalOverlayAction = { readonly kind: "delete"; readonly source: string };
|
|
283
|
+
function completionSnapshots(details: unknown): readonly TerminalSessionSnapshot[] {
|
|
284
|
+
if (!isRecord(details) || !Array.isArray(details.sessions)) return [];
|
|
285
|
+
return details.sessions.filter(isTerminalSessionSnapshot);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function isTerminalSessionSnapshot(value: unknown): value is TerminalSessionSnapshot {
|
|
289
|
+
return (
|
|
290
|
+
isRecord(value) &&
|
|
291
|
+
typeof value.id === "string" &&
|
|
292
|
+
typeof value.source === "string" &&
|
|
293
|
+
typeof value.command === "string" &&
|
|
294
|
+
typeof value.cwd === "string" &&
|
|
295
|
+
typeof value.shell === "string" &&
|
|
296
|
+
(value.shellFamily === "posix" ||
|
|
297
|
+
value.shellFamily === "powershell" ||
|
|
298
|
+
value.shellFamily === "cmd") &&
|
|
299
|
+
typeof value.background === "boolean" &&
|
|
300
|
+
typeof value.status === "string" &&
|
|
301
|
+
typeof value.startedAt === "number" &&
|
|
302
|
+
typeof value.elapsedMs === "number" &&
|
|
303
|
+
typeof value.output === "string" &&
|
|
304
|
+
typeof value.outputStart === "number" &&
|
|
305
|
+
typeof value.outputEnd === "number" &&
|
|
306
|
+
typeof value.truncated === "boolean" &&
|
|
307
|
+
typeof value.cols === "number" &&
|
|
308
|
+
typeof value.rows === "number"
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function formatCompletionMessage(sessions: readonly TerminalSessionSnapshot[]): string {
|
|
313
|
+
const heading =
|
|
314
|
+
sessions.length === 1 ? "Background terminal completed:" : "Background terminals completed:";
|
|
315
|
+
return `${heading}\n${sessions
|
|
316
|
+
.map((session) => {
|
|
317
|
+
const exit = session.exitCode === undefined ? "" : `, exit ${session.exitCode}`;
|
|
318
|
+
const excerpt = session.output.trimEnd().slice(-2_000);
|
|
319
|
+
return `- ${session.source}: ${session.status}${exit}, ${formatElapsed(session.elapsedMs)}\n${excerpt || "(no output)"}`;
|
|
320
|
+
})
|
|
321
|
+
.join("\n")}`;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function shortCommand(command: string, max = 60): string {
|
|
325
|
+
const singleLine = command.replaceAll(/\s+/gu, " ").trim();
|
|
326
|
+
return singleLine.length <= max ? singleLine : `${singleLine.slice(0, max - 1)}…`;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function formatElapsed(milliseconds: number): string {
|
|
330
|
+
if (milliseconds < 1_000) return `${milliseconds}ms`;
|
|
331
|
+
return `${(milliseconds / 1_000).toFixed(milliseconds < 10_000 ? 1 : 0)}s`;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
335
|
+
return typeof value === "object" && value !== null;
|
|
336
|
+
}
|
package/src/post-edit/gate.ts
CHANGED
|
@@ -36,11 +36,24 @@ export async function runIdePostEditGate(
|
|
|
36
36
|
formatter: formatterName,
|
|
37
37
|
},
|
|
38
38
|
...(result.ok
|
|
39
|
-
? {
|
|
40
|
-
|
|
39
|
+
? {
|
|
40
|
+
diffStatuses: [
|
|
41
|
+
{
|
|
42
|
+
text: `Formatted (${formatterName})`,
|
|
43
|
+
tone: "success" as const,
|
|
44
|
+
formatter: formatterName,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
}
|
|
48
|
+
: {
|
|
49
|
+
diffStatuses: [
|
|
50
|
+
{ text: `Formatting failed (${formatterName})`, tone: "error" as const },
|
|
51
|
+
],
|
|
52
|
+
}),
|
|
41
53
|
};
|
|
42
54
|
} catch {
|
|
43
55
|
return {
|
|
56
|
+
diffStatuses: [{ text: "Formatting failed", tone: "error" as const }],
|
|
44
57
|
formatting: {
|
|
45
58
|
status: "failed",
|
|
46
59
|
...(formatterName === undefined ? {} : { formatter: formatterName }),
|
package/dist/chunk-4U6KGABH.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d}from"./chunk-S3ZPXWX7.js";import{a as n}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as a}from"typebox/value";var o=e.Function([],e.Unknown()),l=e.Object({resolver:e.Unknown(),priority:e.Optional(e.Number()),renderResult:e.Optional(o),preserveTruncatedOutput:e.Optional(e.Boolean())}),s=e.Object({resolver:e.Unknown(),priority:e.Optional(e.Number())}),R=e.Object({id:e.String({pattern:"\\S"}),priority:e.Optional(e.Number()),resolve:o}),p=e.Object({view:e.String({pattern:"\\S"}),includes:e.Optional(e.Array(e.String({pattern:"\\S"}))),presenter:e.Object({id:e.String(),present:o}),priority:e.Optional(e.Number())}),u=e.Object({resolvedBy:e.String({pattern:"\\S"}),contentKind:e.Union([e.Literal("text"),e.Literal("any")])}),y=e.Union([e.Object({stage:e.Literal("pre-read"),handler:o}),e.Object({stage:e.Literal("read"),when:u,handler:o}),e.Object({stage:e.Literal("post-read"),handler:o})]);function v(t){if(!a.Check(s,t))return!1;let r=t,i=r.resolver;return typeof i.id=="string"&&i.id.length>0&&typeof i.tryResolve=="function"&&(!("priority"in r)||typeof r.priority=="number")}n(v,"isTextTargetResolverRegistration");function f(t){if(!a.Check(l,t))return!1;let r=t;return d(r.resolver)?r.resolver.id!=="any"&&(!("priority"in r)||typeof r.priority=="number")&&(!("renderResult"in r)||typeof r.renderResult=="function"):!1}n(f,"isResourceResolverRegistration");function T(t){return a.Check(y,t)}n(T,"isReadHandlerRegistration");function S(t){return a.Check(p,t)}n(S,"isReadViewRegistration");function P(t){return a.Check(R,t)}n(P,"isFragmentResolverRegistration");function k(t){return c(t)?t.kind==="not-handled"?!0:t.kind==="failed"?typeof t.message=="string"&&t.message.length>0:t.kind==="resolved"&&typeof t.originLine=="number":!1}n(k,"isReadFragmentResolution");function c(t){return typeof t=="object"&&t!==null}n(c,"isRecord");export{v as a,f as b,T as c,S as d,P as e,k as f};
|
package/dist/chunk-6ACQQBUY.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})}},g=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=l(e);for(let r of this.diffs){let n=r.match(/^---\s+(.+)$/m);if(n&&(l(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 l(i){return i.replace(/\\/g,"/").replace(/^a\//,"").replace(/^b\//,"")}s(l,"normalisePath");import{createTwoFilesPatch as p,diffLines as c}from"diff";function D(i,e,t){return{diff:p(i,i,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,g as b,D as c,y as d};
|