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
|
@@ -2,6 +2,8 @@ import path from "node:path";
|
|
|
2
2
|
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
4
|
|
|
5
|
+
import { inspectRecipeEvidence } from "pi-agent-doctor/api/evidence";
|
|
6
|
+
import type { ToolRecipe } from "pi-agent-doctor/api/catalog";
|
|
5
7
|
import { hasConfiguredExecutable, loadLayeredToolConfig } from "pi-agent-ide/api/tool-config";
|
|
6
8
|
|
|
7
9
|
import { buildLanguageLookup, type LanguageLookup } from "./language-map.js";
|
|
@@ -38,7 +40,7 @@ export class LspServerRegistry {
|
|
|
38
40
|
*/
|
|
39
41
|
static async fromPackageDir(
|
|
40
42
|
packageDir: string,
|
|
41
|
-
options: LayeredToolConfigOptions = {},
|
|
43
|
+
options: LayeredToolConfigOptions & { readonly recipes?: readonly ToolRecipe[] } = {},
|
|
42
44
|
): Promise<LspServerRegistry> {
|
|
43
45
|
const effective = await loadLayeredToolConfig(
|
|
44
46
|
packageDir,
|
|
@@ -55,9 +57,20 @@ export class LspServerRegistry {
|
|
|
55
57
|
available: await hasConfiguredExecutable(entry.config, packageDir, environment),
|
|
56
58
|
})),
|
|
57
59
|
);
|
|
60
|
+
const evidence = options.requireBuiltInEvidence
|
|
61
|
+
? await inspectRecipeEvidence(packageDir, options.recipes ?? [])
|
|
62
|
+
: undefined;
|
|
58
63
|
return new LspServerRegistry(
|
|
59
64
|
effective.entries,
|
|
60
|
-
new Set(
|
|
65
|
+
new Set(
|
|
66
|
+
available
|
|
67
|
+
.filter(
|
|
68
|
+
(entry) =>
|
|
69
|
+
entry.available &&
|
|
70
|
+
(evidence === undefined || (evidence.get(entry.id)?.score ?? 0) > 0),
|
|
71
|
+
)
|
|
72
|
+
.map((entry) => entry.id),
|
|
73
|
+
),
|
|
61
74
|
path.resolve(packageDir),
|
|
62
75
|
);
|
|
63
76
|
}
|
|
@@ -2,7 +2,7 @@ import type { LspClient } from "./client.js";
|
|
|
2
2
|
import type { LspPosition, LspTextEdit } from "./types.js";
|
|
3
3
|
|
|
4
4
|
export interface LspDocumentChange {
|
|
5
|
-
textDocument: { uri: string };
|
|
5
|
+
textDocument: { uri: string; version?: number | null };
|
|
6
6
|
edits: LspTextEdit[];
|
|
7
7
|
}
|
|
8
8
|
|
|
@@ -6,6 +6,32 @@ import { LspManager } from "./manager.js";
|
|
|
6
6
|
import { requestReferences } from "./navigation.js";
|
|
7
7
|
import { type LspWorkspaceSymbol, requestWorkspaceSymbols } from "./symbols.js";
|
|
8
8
|
|
|
9
|
+
/** Restrict symbol definitions and references before applying the result limit. */
|
|
10
|
+
export interface SymbolSearchScope {
|
|
11
|
+
readonly path?: string;
|
|
12
|
+
readonly include?: string;
|
|
13
|
+
readonly exclude?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function withinScope(file: string, cwd: string, scope: SymbolSearchScope): boolean {
|
|
17
|
+
const relative = path.relative(path.resolve(cwd, scope.path ?? "."), file);
|
|
18
|
+
// oxlint-disable-next-line repo/no-parent-paths -- reject results outside the requested scope.
|
|
19
|
+
if (relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative))
|
|
20
|
+
return false;
|
|
21
|
+
const candidate = path.relative(cwd, file).split(path.sep).join("/");
|
|
22
|
+
const matches = (patterns: string) =>
|
|
23
|
+
patterns.split(",").some((value) => {
|
|
24
|
+
const glob = value.trim();
|
|
25
|
+
return (
|
|
26
|
+
glob.length > 0 &&
|
|
27
|
+
path.matchesGlob(glob.includes("/") ? candidate : path.basename(file), glob)
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
return (
|
|
31
|
+
(scope.include === undefined || matches(scope.include)) &&
|
|
32
|
+
(scope.exclude === undefined || !matches(scope.exclude))
|
|
33
|
+
);
|
|
34
|
+
}
|
|
9
35
|
export interface SymbolHit {
|
|
10
36
|
filePath: string;
|
|
11
37
|
lineNumber: number;
|
|
@@ -50,13 +76,14 @@ export async function searchSymbols(
|
|
|
50
76
|
cwd: string,
|
|
51
77
|
limit: number,
|
|
52
78
|
signal?: AbortSignal,
|
|
79
|
+
scope: SymbolSearchScope = {},
|
|
80
|
+
manager = LspManager.getInstance(),
|
|
53
81
|
): Promise<SymbolHit[]> {
|
|
54
82
|
if (signal?.aborted) {
|
|
55
83
|
throw new Error("Operation aborted");
|
|
56
84
|
}
|
|
57
85
|
|
|
58
|
-
const
|
|
59
|
-
const clients = await manager.prepareWorkspaceSymbols(cwd);
|
|
86
|
+
const clients = await manager.prepareWorkspaceSymbols(cwd, scope.path ?? cwd);
|
|
60
87
|
const definitions: LspWorkspaceSymbol[] = [];
|
|
61
88
|
|
|
62
89
|
for (const client of clients) {
|
|
@@ -65,7 +92,7 @@ export async function searchSymbols(
|
|
|
65
92
|
}
|
|
66
93
|
|
|
67
94
|
try {
|
|
68
|
-
definitions.push(...(await requestWorkspaceSymbols(client, query,
|
|
95
|
+
definitions.push(...(await requestWorkspaceSymbols(client, query, Number.MAX_SAFE_INTEGER)));
|
|
69
96
|
} catch {
|
|
70
97
|
// A server without workspace/symbol support cannot contribute results.
|
|
71
98
|
}
|
|
@@ -93,7 +120,7 @@ export async function searchSymbols(
|
|
|
93
120
|
);
|
|
94
121
|
const definitionKey = `${definitionHit.filePath}:${definitionHit.lineNumber}:${definitionHit.column}`;
|
|
95
122
|
|
|
96
|
-
if (!seen.has(definitionKey)) {
|
|
123
|
+
if (withinScope(uriToFilePath(definition.uri), cwd, scope) && !seen.has(definitionKey)) {
|
|
97
124
|
seen.add(definitionKey);
|
|
98
125
|
hits.push(definitionHit);
|
|
99
126
|
}
|
|
@@ -125,7 +152,7 @@ export async function searchSymbols(
|
|
|
125
152
|
);
|
|
126
153
|
const key = `${hit.filePath}:${hit.lineNumber}:${hit.column}`;
|
|
127
154
|
|
|
128
|
-
if (!seen.has(key)) {
|
|
155
|
+
if (withinScope(uriToFilePath(reference.uri), cwd, scope) && !seen.has(key)) {
|
|
129
156
|
seen.add(key);
|
|
130
157
|
hits.push(hit);
|
|
131
158
|
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { readFile, stat } from "node:fs/promises";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { parseCodeViewReference, resolveCodeViewPath } from "pi-agent-ide/api/code-view";
|
|
4
|
+
import type { TextEditPlan, TextPreEditState } from "pi-agent-text-editor/api/edit-pipeline";
|
|
5
|
+
import type { LspManagerProvider } from "./code-view-resolvers.js";
|
|
6
|
+
import { resolveLspRenameTarget } from "./lsp/code-views.js";
|
|
7
|
+
import { requestRename } from "./lsp/rename.js";
|
|
8
|
+
import type { LspPosition } from "./lsp/types.js";
|
|
9
|
+
|
|
10
|
+
function offset(content: string, position: LspPosition): number {
|
|
11
|
+
const lines = content.split("\n");
|
|
12
|
+
const line = lines[position.line];
|
|
13
|
+
if (
|
|
14
|
+
!Number.isInteger(position.line) ||
|
|
15
|
+
position.line < 0 ||
|
|
16
|
+
line === undefined ||
|
|
17
|
+
!Number.isInteger(position.character) ||
|
|
18
|
+
position.character < 0 ||
|
|
19
|
+
position.character > line.replace(/\r$/u, "").length
|
|
20
|
+
)
|
|
21
|
+
throw new Error("The language server returned an invalid text position.");
|
|
22
|
+
return (
|
|
23
|
+
lines.slice(0, position.line).reduce((total, value) => total + value.length + 1, 0) +
|
|
24
|
+
position.character
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Prepare server rename edits for the shared guarded editor, never a textual rename fallback. */
|
|
29
|
+
export async function prepareSymbolRename(
|
|
30
|
+
state: TextPreEditState,
|
|
31
|
+
managerFor: LspManagerProvider,
|
|
32
|
+
): Promise<TextPreEditState | undefined> {
|
|
33
|
+
const input = state.input as Record<string, unknown>;
|
|
34
|
+
if (
|
|
35
|
+
typeof input.path !== "string" ||
|
|
36
|
+
!input.path.startsWith("symbol:") ||
|
|
37
|
+
!input.path.endsWith("#name")
|
|
38
|
+
)
|
|
39
|
+
return undefined;
|
|
40
|
+
if (
|
|
41
|
+
typeof input.text !== "string" ||
|
|
42
|
+
input.text.trim() === "" ||
|
|
43
|
+
input.start !== undefined ||
|
|
44
|
+
input.end !== undefined
|
|
45
|
+
)
|
|
46
|
+
throw new Error(
|
|
47
|
+
"Rename needs a symbol #name path and a non-empty new name in text, without start/end.",
|
|
48
|
+
);
|
|
49
|
+
const reference = parseCodeViewReference(input.path.slice(0, -5), "symbol");
|
|
50
|
+
if (reference?.selector === undefined)
|
|
51
|
+
throw new Error("Rename needs an exact symbol selector before #name.");
|
|
52
|
+
const source = resolveCodeViewPath(reference.path, state.cwd);
|
|
53
|
+
const target = await resolveLspRenameTarget(
|
|
54
|
+
await managerFor(state.cwd),
|
|
55
|
+
source,
|
|
56
|
+
reference.selector,
|
|
57
|
+
state.cwd,
|
|
58
|
+
state.signal,
|
|
59
|
+
);
|
|
60
|
+
// TypeScript can answer rename before loading unopened project files.
|
|
61
|
+
// Its advertised project query loads them before requesting workspace edits.
|
|
62
|
+
if (target.client.supportsCommand("typescript.tsserverRequest")) {
|
|
63
|
+
const project = await target.client.sendRequest<{ success?: boolean } | null>(
|
|
64
|
+
"workspace/executeCommand",
|
|
65
|
+
{
|
|
66
|
+
command: "typescript.tsserverRequest",
|
|
67
|
+
arguments: [
|
|
68
|
+
"projectInfo",
|
|
69
|
+
{ file: source, needFileNameList: true },
|
|
70
|
+
{ isAsync: false, expectsResult: true },
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
);
|
|
74
|
+
if (project?.success !== true)
|
|
75
|
+
throw new Error("TypeScript could not load the project for rename. No edits applied.");
|
|
76
|
+
}
|
|
77
|
+
const requestedAt = Date.now();
|
|
78
|
+
const edit = await requestRename(target.client, target.uri, target.position, input.text);
|
|
79
|
+
state.signal?.throwIfAborted();
|
|
80
|
+
if (edit === null)
|
|
81
|
+
throw new Error(
|
|
82
|
+
"The language server did not provide rename edits. No text fallback was applied.",
|
|
83
|
+
);
|
|
84
|
+
const entries = new Map(Object.entries(edit.changes ?? {}));
|
|
85
|
+
for (const change of edit.documentChanges ?? []) {
|
|
86
|
+
if (!("textDocument" in change) || !("edits" in change))
|
|
87
|
+
throw new Error("Rename returned a file operation that is not supported; no edits applied.");
|
|
88
|
+
if (
|
|
89
|
+
change.textDocument.version != null &&
|
|
90
|
+
change.textDocument.version !== target.client.documentVersion(change.textDocument.uri)
|
|
91
|
+
)
|
|
92
|
+
throw new Error(
|
|
93
|
+
"Rename refers to an unavailable document revision. Refresh the source before retrying.",
|
|
94
|
+
);
|
|
95
|
+
if (entries.has(change.textDocument.uri))
|
|
96
|
+
throw new Error("Rename returned duplicate document edits.");
|
|
97
|
+
entries.set(change.textDocument.uri, change.edits);
|
|
98
|
+
}
|
|
99
|
+
const files: TextEditPlan["files"][number][] = [];
|
|
100
|
+
for (const [uri, edits] of entries) {
|
|
101
|
+
const file = fileURLToPath(uri);
|
|
102
|
+
const before = await stat(file);
|
|
103
|
+
const content = await readFile(file, "utf8");
|
|
104
|
+
const after = await stat(file);
|
|
105
|
+
const synchronized = target.client.documentContent(uri);
|
|
106
|
+
if (synchronized !== undefined && synchronized !== content)
|
|
107
|
+
throw new Error(
|
|
108
|
+
"The language server has stale text for a rename target. Read that symbol again before retrying.",
|
|
109
|
+
);
|
|
110
|
+
if (
|
|
111
|
+
before.mtimeMs > requestedAt ||
|
|
112
|
+
before.mtimeMs !== after.mtimeMs ||
|
|
113
|
+
before.size !== after.size ||
|
|
114
|
+
(file === source && content !== target.content)
|
|
115
|
+
)
|
|
116
|
+
throw new Error(
|
|
117
|
+
"A rename source changed during the language-server request. Retry from a fresh symbol read.",
|
|
118
|
+
);
|
|
119
|
+
files.push({
|
|
120
|
+
source: file,
|
|
121
|
+
expectedContent: content,
|
|
122
|
+
changes: edits.map((change) => ({
|
|
123
|
+
from: offset(content, change.range.start),
|
|
124
|
+
to: offset(content, change.range.end),
|
|
125
|
+
insert: change.newText,
|
|
126
|
+
})),
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
...state,
|
|
131
|
+
editPlan: { files },
|
|
132
|
+
metadata: {
|
|
133
|
+
...state.metadata,
|
|
134
|
+
semanticEdit: { mode: "lsp-rename", server: target.client.serverId, referencesUpdated: true },
|
|
135
|
+
diffStatuses: [{ text: "Renamed through LSP", tone: "success" }],
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
}
|
|
@@ -20,8 +20,15 @@ export function createLspSearchResolver(
|
|
|
20
20
|
return { kind: "failed", error: new Error("symbols: query must not be empty") };
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
await managerFor(context.cwd);
|
|
24
|
-
const hits = await searchSymbols(
|
|
23
|
+
const manager = await managerFor(context.cwd);
|
|
24
|
+
const hits = await searchSymbols(
|
|
25
|
+
query,
|
|
26
|
+
context.cwd,
|
|
27
|
+
request.limit ?? 100,
|
|
28
|
+
context.signal,
|
|
29
|
+
request,
|
|
30
|
+
manager,
|
|
31
|
+
);
|
|
25
32
|
return { kind: "resolved", payload: { query, hits } };
|
|
26
33
|
},
|
|
27
34
|
format(payload) {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import {
|
|
3
|
+
readPiAgentIdeExtensionsConfig,
|
|
4
|
+
resolvePiAgentIdeExtensionsConfigPaths,
|
|
5
|
+
} from "#src/composite/extensions-config.js";
|
|
6
|
+
|
|
7
|
+
import { registerTerminalResources } from "#src/plugins/pi-agent-ide-terminal/src/resources.js";
|
|
8
|
+
import { registerTerminalSearch } from "#src/plugins/pi-agent-ide-terminal/src/search.js";
|
|
9
|
+
import { TerminalSessionManager } from "#src/plugins/pi-agent-ide-terminal/src/session-manager.js";
|
|
10
|
+
import { resolveShellProfile } from "#src/plugins/pi-agent-ide-terminal/src/shell-profile.js";
|
|
11
|
+
import { registerTerminalTools } from "#src/plugins/pi-agent-ide-terminal/src/tools.js";
|
|
12
|
+
import { TerminalUi } from "#src/plugins/pi-agent-ide-terminal/src/ui.js";
|
|
13
|
+
|
|
14
|
+
/** Register the platform-aware terminal runner and shell session resources. */
|
|
15
|
+
export default async function registerTerminal(pi: ExtensionAPI): Promise<void> {
|
|
16
|
+
const manager = new TerminalSessionManager();
|
|
17
|
+
const profile = resolveShellProfile();
|
|
18
|
+
const config = await readPiAgentIdeExtensionsConfig(resolvePiAgentIdeExtensionsConfigPaths());
|
|
19
|
+
const activity = terminalActivityMode(config.preferences?.["terminal.activity"]);
|
|
20
|
+
const ui = new TerminalUi(pi, manager, activity);
|
|
21
|
+
|
|
22
|
+
await Promise.all([registerTerminalResources(pi, manager), registerTerminalSearch(pi, manager)]);
|
|
23
|
+
registerTerminalTools(pi, manager, profile, ui);
|
|
24
|
+
|
|
25
|
+
pi.on("session_start", (_event, context) => ui.bind(context));
|
|
26
|
+
pi.on("session_shutdown", async () => {
|
|
27
|
+
ui.dispose();
|
|
28
|
+
await manager.dispose();
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function terminalActivityMode(value: string | undefined): "detailed" | "compact" | "off" {
|
|
33
|
+
return value === "compact" || value === "off" ? value : "detailed";
|
|
34
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { stripVTControlCharacters } from "node:util";
|
|
3
|
+
|
|
4
|
+
import type { Theme, ThemeColor } from "@earendil-works/pi-coding-agent";
|
|
5
|
+
import { Text, truncateToWidth, visibleWidth, type Component } from "@earendil-works/pi-tui";
|
|
6
|
+
|
|
7
|
+
import { COMPACT_READ_ROWS } from "#src/extensions/pi-agent-read/src/core/tools/read/read-renderer.js";
|
|
8
|
+
import type {
|
|
9
|
+
ShellProfile,
|
|
10
|
+
TerminalSessionSnapshot,
|
|
11
|
+
TerminalSessionStatus,
|
|
12
|
+
} from "#src/plugins/pi-agent-ide-terminal/src/types.js";
|
|
13
|
+
|
|
14
|
+
type TerminalTheme = Pick<Theme, "fg">;
|
|
15
|
+
|
|
16
|
+
/** Render a stable shell prompt for a run tool call. */
|
|
17
|
+
export function renderRunCall(
|
|
18
|
+
command: string,
|
|
19
|
+
background: boolean,
|
|
20
|
+
cwd: string,
|
|
21
|
+
profile: ShellProfile,
|
|
22
|
+
theme: TerminalTheme,
|
|
23
|
+
): Component {
|
|
24
|
+
const mode = background ? "background" : "wait";
|
|
25
|
+
const heading = `${theme.fg("toolTitle", profile.displayName.toLocaleLowerCase())} ${theme.fg("muted", `· ${shortCwd(cwd)} · ${mode}`)}`;
|
|
26
|
+
return new Text(
|
|
27
|
+
`${heading}\n${theme.fg("accent", promptMarker(profile.family))} ${command}`,
|
|
28
|
+
0,
|
|
29
|
+
0,
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Render only the outcome below an already-visible terminal action call. */
|
|
34
|
+
export function renderTerminalActionResult(
|
|
35
|
+
action: "write" | "insert" | "delete",
|
|
36
|
+
changedLines: readonly string[],
|
|
37
|
+
theme: TerminalTheme,
|
|
38
|
+
): Component {
|
|
39
|
+
const lines = changedLines.map((line) => ` ${theme.fg("dim", line)}`);
|
|
40
|
+
lines.push(theme.fg("success", action === "delete" ? "✓ stopped" : "✓ sent"));
|
|
41
|
+
return new Text(lines.join("\n"), 0, 0);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Render a terminal resource action without exposing its internal shell address. */
|
|
45
|
+
export function renderTerminalAction(
|
|
46
|
+
snapshot: Partial<TerminalSessionSnapshot>,
|
|
47
|
+
action: "read" | "write" | "insert" | "delete" | "search",
|
|
48
|
+
value: string,
|
|
49
|
+
changedLines: readonly string[],
|
|
50
|
+
theme: TerminalTheme,
|
|
51
|
+
): Component {
|
|
52
|
+
const lines = [terminalIdentity(snapshot, theme), theme.fg("accent", `${action} ${value}`)];
|
|
53
|
+
if (changedLines.length > 0)
|
|
54
|
+
lines.push(...changedLines.map((line) => ` ${theme.fg("dim", line)}`));
|
|
55
|
+
return new Text(lines.join("\n"), 0, 0);
|
|
56
|
+
}
|
|
57
|
+
/** Render a terminal result as a compact or expanded pseudo-terminal card. */
|
|
58
|
+
export function renderTerminalResult(
|
|
59
|
+
snapshot: Partial<TerminalSessionSnapshot>,
|
|
60
|
+
expanded: boolean,
|
|
61
|
+
theme: TerminalTheme,
|
|
62
|
+
action?: string,
|
|
63
|
+
): Component {
|
|
64
|
+
const lines = terminalCardLines(
|
|
65
|
+
snapshot,
|
|
66
|
+
expanded ? Number.POSITIVE_INFINITY : COMPACT_READ_ROWS,
|
|
67
|
+
theme,
|
|
68
|
+
);
|
|
69
|
+
if (action !== undefined) lines.splice(1, 1, theme.fg("accent", action));
|
|
70
|
+
return new Text(lines.join("\n"), 0, 0);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Render the result beneath the already-visible run prompt without repeating the command. */
|
|
74
|
+
export function renderRunResult(
|
|
75
|
+
snapshot: Partial<TerminalSessionSnapshot>,
|
|
76
|
+
expanded: boolean,
|
|
77
|
+
theme: TerminalTheme,
|
|
78
|
+
): Component {
|
|
79
|
+
if (expanded) return renderTerminalResult(snapshot, true, theme);
|
|
80
|
+
const window = outputWindow(snapshot.output ?? "", COMPACT_READ_ROWS);
|
|
81
|
+
const lines = [
|
|
82
|
+
...(window.omitted > 0 ? [` ${theme.fg("muted", `… ${window.omitted} earlier lines`)}`] : []),
|
|
83
|
+
...window.lines.map((line) => ` ${theme.fg("dim", line)}`),
|
|
84
|
+
];
|
|
85
|
+
lines.push(statusLine(snapshot, (name, text) => theme.fg(name, text)));
|
|
86
|
+
return new Text(lines.join("\n"), 0, 0);
|
|
87
|
+
}
|
|
88
|
+
/** Render one live below-editor mini-card with changing state only at its tail. */
|
|
89
|
+
export function renderActiveTerminal(
|
|
90
|
+
snapshot: TerminalSessionSnapshot,
|
|
91
|
+
theme?: TerminalTheme,
|
|
92
|
+
): string {
|
|
93
|
+
const color = (name: ThemeColor, text: string): string => theme?.fg(name, text) ?? text;
|
|
94
|
+
const heading = `${color("accent", snapshot.shell.toLocaleLowerCase())} ${color("muted", `· ${shortCwd(snapshot.cwd)} · ${snapshot.background ? "background" : "wait"}`)}`;
|
|
95
|
+
const lines = [
|
|
96
|
+
heading,
|
|
97
|
+
`${color("accent", promptMarker(snapshot.shellFamily))} ${oneLine(snapshot.command, 84)}`,
|
|
98
|
+
];
|
|
99
|
+
const tail = outputTail(snapshot.output, 2);
|
|
100
|
+
if (tail.length > 0) lines.push(...tail.map((line) => ` ${color("dim", oneLine(line, 90))}`));
|
|
101
|
+
lines.push(statusLine(snapshot, color));
|
|
102
|
+
return lines.join("\n");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Build a concise completion or result card from immutable session data. */
|
|
106
|
+
export function terminalCardLines(
|
|
107
|
+
snapshot: Partial<TerminalSessionSnapshot>,
|
|
108
|
+
outputLines: number,
|
|
109
|
+
theme: TerminalTheme,
|
|
110
|
+
): string[] {
|
|
111
|
+
const shell = (snapshot.shell ?? "terminal").toLocaleLowerCase();
|
|
112
|
+
const mode = snapshot.background === true ? "background" : "wait";
|
|
113
|
+
const cwd = snapshot.cwd === undefined ? "workspace" : shortCwd(snapshot.cwd);
|
|
114
|
+
const family = snapshot.shellFamily ?? "posix";
|
|
115
|
+
const lines = [
|
|
116
|
+
`${theme.fg("accent", shell)} ${theme.fg("muted", `· ${cwd} · ${mode}`)}`,
|
|
117
|
+
`${theme.fg("accent", promptMarker(family))} ${snapshot.command ?? ""}`,
|
|
118
|
+
];
|
|
119
|
+
const window = outputWindow(snapshot.output ?? "", outputLines);
|
|
120
|
+
if (window.omitted > 0) lines.push(` ${theme.fg("muted", `… ${window.omitted} earlier lines`)}`);
|
|
121
|
+
if (window.lines.length > 0)
|
|
122
|
+
lines.push(...window.lines.map((line) => ` ${theme.fg("dim", line)}`));
|
|
123
|
+
lines.push(statusLine(snapshot, (name, text) => theme.fg(name, text)));
|
|
124
|
+
return lines;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Render bordered mini-cards modeled after the Herdr subagent activity widget. */
|
|
128
|
+
export function renderTerminalWidgetLines(
|
|
129
|
+
snapshots: readonly TerminalSessionSnapshot[],
|
|
130
|
+
width: number,
|
|
131
|
+
theme: TerminalTheme,
|
|
132
|
+
): string[] {
|
|
133
|
+
if (snapshots.length === 0) return [];
|
|
134
|
+
const accent = (text: string): string => theme.fg("accent", text);
|
|
135
|
+
const lines = [borderTop("Terminals", `${snapshots.length} active`, width, accent)];
|
|
136
|
+
for (const snapshot of snapshots) {
|
|
137
|
+
const card = renderActiveTerminal(snapshot, theme).split("\n");
|
|
138
|
+
for (const line of card) lines.push(borderLine(` ${line} `, width, accent));
|
|
139
|
+
if (snapshot !== snapshots.at(-1)) lines.push(borderLine("", width, accent));
|
|
140
|
+
}
|
|
141
|
+
lines.push(borderBottom(width, accent));
|
|
142
|
+
return lines;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function borderTop(
|
|
146
|
+
title: string,
|
|
147
|
+
info: string,
|
|
148
|
+
width: number,
|
|
149
|
+
accent: (text: string) => string,
|
|
150
|
+
): string {
|
|
151
|
+
if (width <= 1) return accent("╭");
|
|
152
|
+
const inner = width - 2;
|
|
153
|
+
const left = `─ ${title} `;
|
|
154
|
+
const right = ` ${info} ─`;
|
|
155
|
+
const fill = "─".repeat(Math.max(0, inner - visibleWidth(left) - visibleWidth(right)));
|
|
156
|
+
return accent(`╭${truncateToWidth(`${left}${fill}${right}`, inner).padEnd(inner, "─")}╮`);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function borderLine(line: string, width: number, accent: (text: string) => string): string {
|
|
160
|
+
if (width <= 1) return accent("│");
|
|
161
|
+
const inner = width - 2;
|
|
162
|
+
const clipped = truncateToWidth(line, inner);
|
|
163
|
+
return `${accent("│")}${clipped}${" ".repeat(Math.max(0, inner - visibleWidth(clipped)))}${accent("│")}`;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function borderBottom(width: number, accent: (text: string) => string): string {
|
|
167
|
+
return accent(width <= 1 ? "╰" : `╰${"─".repeat(width - 2)}╯`);
|
|
168
|
+
}
|
|
169
|
+
export function outputTail(output: string, count: number): readonly string[] {
|
|
170
|
+
return outputWindow(output, count).lines;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function outputWindow(
|
|
174
|
+
output: string,
|
|
175
|
+
count: number,
|
|
176
|
+
): { readonly lines: readonly string[]; readonly omitted: number } {
|
|
177
|
+
const lines = stripVTControlCharacters(output)
|
|
178
|
+
.replaceAll("\r", "")
|
|
179
|
+
.split("\n")
|
|
180
|
+
.map((line) => line.trimEnd());
|
|
181
|
+
if (lines.at(-1) === "") lines.pop();
|
|
182
|
+
const limit = Number.isFinite(count) ? Math.max(0, count) : lines.length;
|
|
183
|
+
const omitted = Math.max(0, lines.length - limit);
|
|
184
|
+
return { lines: lines.slice(omitted), omitted };
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function statusLine(
|
|
188
|
+
snapshot: Partial<TerminalSessionSnapshot>,
|
|
189
|
+
color: (name: ThemeColor, text: string) => string,
|
|
190
|
+
): string {
|
|
191
|
+
const status = snapshot.status ?? "running";
|
|
192
|
+
const icon = statusIcon(status);
|
|
193
|
+
const tone: ThemeColor =
|
|
194
|
+
status === "completed" ? "success" : status === "running" ? "accent" : "error";
|
|
195
|
+
const parts = [`${icon} ${status}`, formatElapsed(snapshot.elapsedMs ?? 0)];
|
|
196
|
+
if (snapshot.exitCode !== undefined) parts.push(`exit ${snapshot.exitCode}`);
|
|
197
|
+
else if (snapshot.signal !== undefined) parts.push(`signal ${snapshot.signal}`);
|
|
198
|
+
return color(tone, parts.join(" · "));
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function statusIcon(status: TerminalSessionStatus): string {
|
|
202
|
+
if (status === "completed") return "✓";
|
|
203
|
+
if (status === "running") return "●";
|
|
204
|
+
if (status === "stopping") return "◌";
|
|
205
|
+
return "✗";
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function promptMarker(family: ShellProfile["family"]): string {
|
|
209
|
+
return family === "powershell" ? "PS>" : family === "cmd" ? ">" : "$";
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function terminalIdentity(
|
|
213
|
+
snapshot: Partial<TerminalSessionSnapshot>,
|
|
214
|
+
theme: TerminalTheme,
|
|
215
|
+
): string {
|
|
216
|
+
const shell = (snapshot.shell ?? "terminal").toLocaleLowerCase();
|
|
217
|
+
const cwd = snapshot.cwd === undefined ? "workspace" : shortCwd(snapshot.cwd);
|
|
218
|
+
const mode = snapshot.background === true ? "background" : "wait";
|
|
219
|
+
const command = oneLine(snapshot.command ?? "process", 48);
|
|
220
|
+
return `${theme.fg("toolTitle", shell)} ${theme.fg("muted", `· ${cwd} · ${mode} · ${command}`)}`;
|
|
221
|
+
}
|
|
222
|
+
function shortCwd(cwd: string): string {
|
|
223
|
+
const home = process.env.HOME;
|
|
224
|
+
if (home !== undefined && (cwd === home || cwd.startsWith(`${home}${path.sep}`))) {
|
|
225
|
+
return `~${cwd.slice(home.length)}`;
|
|
226
|
+
}
|
|
227
|
+
return cwd;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function oneLine(value: string, max: number): string {
|
|
231
|
+
const line = value.replaceAll(/\s+/gu, " ").trim();
|
|
232
|
+
return line.length <= max ? line : `${line.slice(0, max - 1)}…`;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function formatElapsed(milliseconds: number): string {
|
|
236
|
+
if (milliseconds < 1_000) return `${milliseconds}ms`;
|
|
237
|
+
return `${(milliseconds / 1_000).toFixed(milliseconds < 10_000 ? 1 : 0)}s`;
|
|
238
|
+
}
|