pi-agent-ide 0.2.1 → 0.3.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 +56 -0
- package/README.md +12 -8
- package/dist/{chunk-XNXQYPVT.js → chunk-4LUW26BX.js} +1 -1
- package/dist/chunk-5MSNYFDE.js +1 -0
- package/dist/chunk-5VSE5X5R.js +2 -0
- package/dist/chunk-6EYWFBNG.js +0 -0
- package/dist/{chunk-ORAPGW7W.js → chunk-72EEL2DW.js} +1 -1
- package/dist/{chunk-T2RPMEM2.js → chunk-7UGNGK7Y.js} +1 -1
- package/dist/{chunk-STUZZM5B.js → chunk-AADJ2KIB.js} +1 -1
- package/dist/{chunk-SMSIT3CE.js → chunk-B5KB2I7J.js} +1 -1
- package/dist/chunk-BHSO2MDK.js +6 -0
- package/dist/chunk-BMOJTJJJ.js +3 -0
- package/dist/{chunk-EEH4WYI7.js → chunk-CEKXBS55.js} +1 -1
- package/dist/chunk-CW53ZTU3.js +2 -0
- package/dist/chunk-EWNWKDMP.js +4 -0
- package/dist/{chunk-VSP2QQPQ.js → chunk-GIRAEVUJ.js} +1 -1
- package/dist/{chunk-MTTKFJV6.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-KAB3AYA2.js +1 -0
- package/dist/{chunk-266RH77Z.js → chunk-LRYE2WCN.js} +1 -1
- package/dist/chunk-M5L42DWE.js +7 -0
- package/dist/chunk-M5MJP7Z2.js +1 -0
- package/dist/chunk-NMFQGKPE.js +2 -0
- package/dist/chunk-NTYXZ3EL.js +3 -0
- package/dist/{chunk-PETQCA7G.js → chunk-QDST6VIU.js} +1 -1
- package/dist/chunk-QIJMV2P2.js +2 -0
- package/dist/chunk-RHV5STR3.js +3 -0
- package/dist/chunk-ROXXK6TW.js +0 -0
- package/dist/chunk-S3ZPXWX7.js +2 -0
- package/dist/chunk-SSHZEWWV.js +1 -0
- package/dist/chunk-TPIHQYK2.js +14 -0
- package/dist/chunk-VZJIZXSH.js +14 -0
- package/dist/chunk-YHADTHQM.js +1 -0
- package/dist/{chunk-KZBAJFCV.js → chunk-Z3VC3S2T.js} +1 -1
- package/dist/{chunk-SJYDLHEF.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-11.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 +2 -1
- package/dist/entry-22.js +1 -1
- package/dist/entry-23.js +1 -1
- package/dist/entry-24.js +1 -1
- package/dist/entry-25.js +1 -1
- package/dist/entry-26.js +12 -1
- package/dist/entry-28.js +1 -1
- package/dist/entry-29.js +1 -1
- package/dist/entry-30.js +1 -1
- package/dist/entry-31.js +4 -1
- package/dist/entry-32.js +9 -1
- package/dist/entry-33.js +1 -1
- package/dist/entry-35.js +1 -1
- 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 +18 -1
- package/dist/entry-41.js +1 -1
- 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 +7 -1
- package/dist/entry-46.js +11 -1
- 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 -1
- package/dist/entry-70.js +123 -1
- package/dist/entry-71.js +30 -1
- package/dist/entry-72.js +2 -1
- package/dist/entry-73.js +1 -1
- 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 -1
- package/dist/entry-78.js +1 -1
- package/dist/entry-79.js +1 -1
- package/dist/pi-agent-ide.js +3 -13
- package/docs/configuration.md +57 -11
- package/docs/extensions.md +4 -2
- package/docs/tools.md +7 -1
- package/node_modules/pi-agent-doctor/package.json +1 -1
- package/node_modules/pi-agent-filesystem/index.ts +2 -2
- 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/ast/outline.ts +89 -19
- package/node_modules/pi-agent-ide-ast/src/extension.ts +11 -15
- package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +83 -0
- package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +8 -1
- package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +83 -5
- package/node_modules/pi-agent-ide-changes/index.ts +22 -10
- 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 +5 -9
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +1 -5
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-formatter/src/formatter.ts +36 -13
- 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 +49 -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 +127 -20
- 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 +25 -7
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +12 -1
- 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-image/src/image-converter.ts +1 -1
- 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-pdf/src/pdf-converter.ts +1 -1
- 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/rendering.ts +3 -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 +32 -28
- package/node_modules/pi-agent-read/src/core/tools/read/native-resource-renderer.ts +74 -0
- 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 +87 -19
- 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 +87 -53
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/content-conversion/content-description.ts +1 -8
- package/node_modules/pi-agent-resource/src/resolver.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 +8 -27
- package/node_modules/pi-agent-search/src/core/search-core.ts +38 -3
- package/node_modules/pi-agent-search-text/index.ts +82 -33
- package/node_modules/pi-agent-search-text/package.json +6 -6
- package/node_modules/pi-agent-search-text/src/file-search.ts +9 -1
- package/node_modules/pi-agent-search-text/src/resolvers.ts +1 -1
- package/node_modules/pi-agent-search-text/src/search-recipe.ts +2 -0
- package/node_modules/pi-agent-search-text/src/search-session.ts +112 -24
- package/node_modules/pi-agent-text/package.json +2 -2
- package/node_modules/pi-agent-text/src/text-converter.ts +1 -1
- 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/index.ts +2 -6
- 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/mutation-result.ts +3 -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 +74 -1
- 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/builtin-edit-filter.ts +4 -12
- 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 +13 -9
- 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 +28 -2
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +43 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +81 -0
- 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-anchor-registry.ts +5 -2
- 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 +40 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +178 -58
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +313 -21
- package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +45 -43
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +18 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +7 -4
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +13 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +18 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -1
- package/node_modules/pi-agent-text-editor-renderer/index.ts +93 -2
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +7 -0
- package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +1 -1
- package/node_modules/pi-agent-text-editor-renderer/src/diff-viewport.ts +11 -2
- package/node_modules/pi-agent-text-editor-renderer/src/frozen-viewport.ts +140 -52
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +69 -4
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-result.ts +53 -1
- package/node_modules/pi-agent-text-editor-renderer/src/persisted-result.ts +8 -2
- package/node_modules/pi-agent-text-editor-renderer/src/render-resource.ts +10 -0
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +24 -13
- 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-call-interception/src/index.ts +3 -0
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-web/index.ts +1 -6
- 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-html/src/html-converter.ts +1 -1
- 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 +38 -38
- package/src/api/plugin-protocol.ts +12 -2
- package/src/api/text-editor.ts +7 -0
- package/src/api/tool-config.ts +77 -2
- package/src/code-view/diagnostic-view.ts +22 -3
- package/src/composite/builtin-extensions.ts +138 -67
- package/src/composite/extensions-config.ts +59 -0
- package/src/composite/feature-flags.ts +32 -0
- package/src/composite/module-labels.ts +55 -0
- package/src/composite/module-settings-store.ts +44 -0
- package/src/composite/module-settings.ts +132 -0
- package/src/composite/selection.ts +4 -4
- package/src/composite/settings-panel.ts +71 -0
- package/src/core/diagnostic-delivery.ts +29 -0
- package/src/core/diagnostic-entry.ts +142 -0
- package/src/core/diagnostic-store.ts +96 -23
- package/src/core/extension.ts +45 -22
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +2 -2
- 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/index.ts +1 -6
- 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-html/src/html-converter.ts +1 -1
- 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/rendering.ts +3 -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 +32 -28
- package/src/extensions/pi-agent-read/src/core/tools/read/native-resource-renderer.ts +74 -0
- 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 +87 -19
- 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 +87 -53
- package/src/extensions/pi-agent-search/package.json +3 -3
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +82 -33
- 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/file-search.ts +9 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +1 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +2 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +112 -24
- 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 +8 -27
- package/src/extensions/pi-agent-search/src/core/search-core.ts +38 -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/index.ts +2 -6
- 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 +93 -2
- 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/diff-model.ts +7 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +1 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-viewport.ts +11 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/frozen-viewport.ts +140 -52
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +69 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-result.ts +53 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/persisted-result.ts +8 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/render-resource.ts +10 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +24 -13
- 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/mutation-result.ts +3 -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 +74 -1
- 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/builtin-edit-filter.ts +4 -12
- 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 +13 -9
- 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 +28 -2
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +43 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +81 -0
- 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-anchor-registry.ts +5 -2
- 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 +40 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +178 -58
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +313 -21
- package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +45 -43
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +18 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +7 -4
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +13 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +18 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -1
- package/src/pi-agent-ide.ts +45 -0
- package/src/plugins/pi-agent-ide-ast/package.json +9 -9
- package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +89 -19
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +11 -15
- package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +83 -0
- package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +8 -1
- package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +83 -5
- package/src/plugins/pi-agent-ide-changes/index.ts +22 -10
- 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 +5 -9
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +1 -5
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +62 -26
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +36 -13
- 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 +49 -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 +127 -20
- 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 +25 -7
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +12 -1
- 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/post-edit/gate.ts +57 -15
- package/src/toolchain/types.ts +2 -0
- package/dist/chunk-2SKAED2I.js +0 -2
- package/dist/chunk-2XYXV5HS.js +0 -4
- package/dist/chunk-2ZMYT6ZC.js +0 -1
- package/dist/chunk-34ZQTTU2.js +0 -2
- package/dist/chunk-4SQQKEVD.js +0 -16
- package/dist/chunk-5BWUVAR4.js +0 -1
- package/dist/chunk-6DN7NO7L.js +0 -1
- package/dist/chunk-6SMFVLTY.js +0 -1
- package/dist/chunk-6XQQBKPE.js +0 -58
- package/dist/chunk-BYWAG6X3.js +0 -6
- package/dist/chunk-EW2KVKCN.js +0 -2
- package/dist/chunk-F6SESI3P.js +0 -4
- package/dist/chunk-GTK5AREE.js +0 -2
- package/dist/chunk-HOBTFFQR.js +0 -1
- package/dist/chunk-IMVCVPMP.js +0 -3
- package/dist/chunk-IOCABSRL.js +0 -1
- package/dist/chunk-JASLOB2X.js +0 -1
- package/dist/chunk-KH5KPBCR.js +0 -10
- package/dist/chunk-KNMWCDDK.js +0 -7
- package/dist/chunk-KYVOMBO5.js +0 -1
- package/dist/chunk-L4FA6OD4.js +0 -1
- package/dist/chunk-LFV6G5Z3.js +0 -1
- package/dist/chunk-LGN7EJYR.js +0 -13
- package/dist/chunk-MB6VVVAF.js +0 -2
- package/dist/chunk-MTQSGWZJ.js +0 -1
- package/dist/chunk-NI2NK4JU.js +0 -1
- package/dist/chunk-NXHPO7ER.js +0 -6
- package/dist/chunk-OFHVDY4Q.js +0 -2
- package/dist/chunk-OIL6BB2S.js +0 -33
- package/dist/chunk-ONWUJXUR.js +0 -1
- package/dist/chunk-PODWLGNO.js +0 -6
- package/dist/chunk-QZANC2IG.js +0 -1
- package/dist/chunk-SSZB66C3.js +0 -3
- package/dist/chunk-TG6H6EOI.js +0 -1
- package/dist/chunk-UTTW55S2.js +0 -1
- package/dist/chunk-VEJGSURY.js +0 -8
- package/dist/chunk-W3XYKJ5H.js +0 -1
- package/dist/chunk-XGUAL3CA.js +0 -1
- package/dist/chunk-YPHXLAQF.js +0 -1
- package/dist/chunk-ZIHEF6K3.js +0 -3
- package/dist/entry-80.js +0 -1
- package/node_modules/pi-agent-read/src/core/tools/read/views.ts +0 -29
- 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-read/src/core/tools/read/views.ts +0 -29
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readdir } from "node:fs/promises";
|
|
1
|
+
import { readdir, stat } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
4
|
import { URI } from "vscode-uri";
|
|
@@ -191,35 +191,13 @@ export class LspManager {
|
|
|
191
191
|
return startingClient;
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
-
/**
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
async getWorkspaceClients(cwd: string, capability: "symbols" = "symbols"): Promise<LspClient[]> {
|
|
194
|
+
/** Start symbol servers only for language families with files in this workspace. */
|
|
195
|
+
async getWorkspaceClients(
|
|
196
|
+
cwd: string,
|
|
197
|
+
capability: "symbols" = "symbols",
|
|
198
|
+
scope = cwd,
|
|
199
|
+
): Promise<LspClient[]> {
|
|
201
200
|
const clients = new Set<LspClient>();
|
|
202
|
-
|
|
203
|
-
for (const extension of this._registry.knownExtensions) {
|
|
204
|
-
try {
|
|
205
|
-
const client = await this.getOrStart(extension, cwd, capability);
|
|
206
|
-
|
|
207
|
-
if (client) {
|
|
208
|
-
clients.add(client);
|
|
209
|
-
}
|
|
210
|
-
} catch {
|
|
211
|
-
// A workspace may list servers that are not installed locally.
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return [...clients];
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
Open one representative file for each configured language family.
|
|
220
|
-
*/
|
|
221
|
-
async prepareWorkspaceSymbols(cwd: string): Promise<LspClient[]> {
|
|
222
|
-
const clients = await this.getWorkspaceClients(cwd);
|
|
223
201
|
const remainingExtensions = new Set(this._registry.knownExtensions);
|
|
224
202
|
const ignoredDirectories = new Set([".git", ".cache", "node_modules", "dist", "build"]);
|
|
225
203
|
|
|
@@ -260,16 +238,27 @@ export class LspManager {
|
|
|
260
238
|
}
|
|
261
239
|
|
|
262
240
|
const filePath = path.join(directory, entry.name);
|
|
263
|
-
const opened = await this.openFile(filePath, cwd,
|
|
241
|
+
const opened = await this.openFile(filePath, cwd, capability).catch(() => null);
|
|
264
242
|
|
|
265
243
|
if (opened) {
|
|
244
|
+
clients.add(opened.client);
|
|
266
245
|
remainingExtensions.delete(extension);
|
|
267
246
|
}
|
|
268
247
|
}
|
|
269
248
|
};
|
|
270
249
|
|
|
271
|
-
|
|
272
|
-
|
|
250
|
+
const selected = path.resolve(cwd, scope);
|
|
251
|
+
if ((await stat(selected)).isFile()) {
|
|
252
|
+
const opened = await this.openFile(selected, cwd, capability);
|
|
253
|
+
return opened === null ? [] : [opened.client];
|
|
254
|
+
}
|
|
255
|
+
await visit(selected);
|
|
256
|
+
return [...clients];
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/** Open representative source files before querying workspace symbols. */
|
|
260
|
+
async prepareWorkspaceSymbols(cwd: string, scope = cwd): Promise<LspClient[]> {
|
|
261
|
+
return this.getWorkspaceClients(cwd, "symbols", scope);
|
|
273
262
|
}
|
|
274
263
|
|
|
275
264
|
/**
|
|
@@ -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) {
|
package/src/post-edit/gate.ts
CHANGED
|
@@ -1,21 +1,63 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
|
|
3
3
|
import { warmupFormatting } from "#src/toolchain/registry.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { MutationFormatting } from "pi-agent-text-editor/api/mutation-result";
|
|
5
|
+
import type {
|
|
6
|
+
TextPostEditTransaction,
|
|
7
|
+
TextPostEditStatusContribution,
|
|
8
|
+
} from "pi-agent-text-editor/api/post-edit";
|
|
5
9
|
|
|
6
|
-
/** Finish
|
|
7
|
-
export async function runIdePostEditGate(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
10
|
+
/** Finish file-writing work and report the formatter outcome, separately from diagnostics. */
|
|
11
|
+
export async function runIdePostEditGate(
|
|
12
|
+
transaction: TextPostEditTransaction,
|
|
13
|
+
): Promise<{ formatting: MutationFormatting } & Partial<TextPostEditStatusContribution>> {
|
|
14
|
+
if (!path.isAbsolute(transaction.resourceSource))
|
|
15
|
+
return { formatting: { status: "unavailable" } };
|
|
16
|
+
let formatterName: string | undefined;
|
|
17
|
+
try {
|
|
18
|
+
const toolchain = await warmupFormatting({ cwd: transaction.cwd });
|
|
19
|
+
const extension = path.extname(transaction.resourceSource).toLowerCase();
|
|
20
|
+
const matches = (tool: { extensions: readonly string[] }) =>
|
|
21
|
+
tool.extensions.includes(extension) || tool.extensions.includes("*");
|
|
22
|
+
const syntax = toolchain.compilers.find(matches);
|
|
23
|
+
if (syntax) {
|
|
24
|
+
const result = await syntax.compile({ filePath: transaction.resourceSource }, toolchain.ctx);
|
|
25
|
+
if (result.syntaxErrors.length > 0) return { formatting: { status: "skipped-syntax" } };
|
|
26
|
+
}
|
|
27
|
+
const formatter = toolchain.formatters.find(matches);
|
|
28
|
+
if (!formatter) return { formatting: { status: "unavailable" } };
|
|
29
|
+
formatterName = formatter.name;
|
|
30
|
+
const result = await formatter.format({ filePath: transaction.resourceSource }, toolchain.ctx);
|
|
31
|
+
if (result.formatter === null) return { formatting: { status: "unavailable" } };
|
|
32
|
+
formatterName = result.formatter ?? formatter.name;
|
|
33
|
+
return {
|
|
34
|
+
formatting: {
|
|
35
|
+
status: !result.ok ? "failed" : result.edits > 0 ? "changed" : "unchanged",
|
|
36
|
+
formatter: formatterName,
|
|
37
|
+
},
|
|
38
|
+
...(result.ok
|
|
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
|
+
}),
|
|
53
|
+
};
|
|
54
|
+
} catch {
|
|
55
|
+
return {
|
|
56
|
+
diffStatuses: [{ text: "Formatting failed", tone: "error" as const }],
|
|
57
|
+
formatting: {
|
|
58
|
+
status: "failed",
|
|
59
|
+
...(formatterName === undefined ? {} : { formatter: formatterName }),
|
|
60
|
+
},
|
|
61
|
+
};
|
|
17
62
|
}
|
|
18
|
-
// Configured formatters may use their own parser to reject invalid syntax safely.
|
|
19
|
-
const formatter = toolchain.formatters.find(matches);
|
|
20
|
-
await formatter?.format({ filePath: transaction.resourceSource }, toolchain.ctx);
|
|
21
63
|
}
|
package/src/toolchain/types.ts
CHANGED
|
@@ -29,6 +29,8 @@ export interface FormatInput {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export interface FormatResult {
|
|
32
|
+
/** Actual formatter executable. Omit for a named formatter plugin; null means no formatter was selected. */
|
|
33
|
+
formatter?: string | null;
|
|
32
34
|
ok: boolean;
|
|
33
35
|
/**
|
|
34
36
|
Number of edits applied. 0 = no change.
|
package/dist/chunk-2SKAED2I.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as r}from"./chunk-EI7MMDWY.js";import{Type as n}from"typebox";import{Value as C}from"typebox/value";var f=Symbol.for("pi-agent-text/TextAnchor"),u=class{constructor(t,o){this.value=t;this.lineNumber=o;if(t.length===0)throw new TypeError("Text anchor value must be non-empty");if(!Number.isSafeInteger(o)||o<1)throw new RangeError("Text anchor line number must be a positive safe integer")}static{r(this,"TextAnchor")}[f]=!0;static is(t){if(typeof t!="object"||t===null)return!1;try{let o=t;return o[f]===!0&&typeof o.value=="string"&&Number.isSafeInteger(o.lineNumber)&&o.lineNumber>=1}catch{return!1}}toString(){return this.value}},x=new WeakMap;function w(e,t,o){x.set(e,{renderer:t,resolverId:o})}r(w,"attachTextAnchorRenderer");function S(e){return x.get(e)?.renderer}r(S,"getTextAnchorRenderer");function P(e,t,o){let i=x.get(e);if(i===void 0)throw new Error(`No renderer is attached to text anchor "${t}"`);return{...i.renderer,resolverId:i.resolverId,full:i.renderer.renderFull(t,o),compact:i.renderer.renderCompact(t,o)}}r(P,"renderTextAnchor");var a={additionalProperties:!0},l=n.Function([],n.Unknown()),g=n.Object({lineNumber:n.Integer({minimum:1}),column:n.Integer({minimum:0})},a),j=n.Object({rank:n.Integer({minimum:1}),range:n.Object({start:g,end:g},a)},a),L=n.Object({id:n.String({minLength:1}),description:n.Union([n.String(),l]),normalize:n.Optional(l),renderFull:l,renderCompact:l,tryResolve:l,recover:n.Optional(l)},a),O=n.Object({code:n.Union([n.Literal("invalid"),n.Literal("stale"),n.Literal("missing"),n.Literal("ambiguous")]),reason:n.String(),contextRange:n.Optional(n.Object({offset:n.Number(),limit:n.Number()}))}),E=n.Union([n.Object({kind:n.Literal("not-handled")},a),n.Object({kind:n.Literal("resolved"),anchor:n.Unknown()},a),n.Object({kind:n.Literal("rejected"),rejection:O},a),n.Object({kind:n.Literal("failed"),error:n.Unknown()},a)]),N=n.Union([n.Object({kind:n.Literal("unavailable")},a),n.Object({kind:n.Literal("candidates"),candidates:n.Array(j),total:n.Integer({minimum:0})},a),n.Object({kind:n.Literal("timed-out")},a),n.Object({kind:n.Literal("failed"),error:n.Unknown()},a)]);function D(e){return p(L,e)&&y(()=>e.id.trim().length>0)}r(D,"isTextAnchorResolver");function I(e){return p(E,e)&&y(()=>{let t=e;return t.kind!=="resolved"||u.is(t.anchor)})}r(I,"isTextAnchorResolutionAttempt");function M(e){return p(N,e)}r(M,"isTextAnchorRecoveryOutcome");function p(e,t){return y(()=>C.Check(e,t))}r(p,"safeCheck");function y(e){try{return e()}catch{return!1}}r(y,"safeEvaluate");function T(e){if(!e.some(i=>i.marker!==void 0))return e.map(i=>`${i.prefix??""}${i.content}${i.suffix??""}`);let o=Math.max(0,...e.map(i=>i.prefix?.length??0));return e.map(i=>`${i.marker??" "}|${(i.prefix??"").padStart(o," ")}${i.content}${i.suffix??""}`)}r(T,"renderPresentedTextRows");var h="pi-agent-text/source-line";function $(e){let t=e.metadata?.[h];if(U(t))return t}r($,"getTextSourceLine");function F(e,t){return{...e,metadata:{...e.metadata,[h]:t}}}r(F,"withTextSourceLine");function U(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.source=="string"&&t.source.length>0&&typeof t.lineNumber=="number"&&Number.isInteger(t.lineNumber)&&t.lineNumber>0&&typeof t.content=="string"}r(U,"isTextSourceLine");import{Type as d}from"typebox";import{Value as W}from"typebox/value";var q=d.Function([],d.Unknown()),R=d.Object({id:d.String({minLength:1}),present:q}),B=d.Object({presenter:R,priority:d.Optional(d.Number())});function _(e){return A(R,e)}r(_,"isTextLinePresenter");function z(e){return A(B,e)}r(z,"isTextPresenterRegistration");function K(e,t){return{source:e,content:t,lines:H(t)}}r(K,"createTextDocument");function V(e){return e.lines.map(t=>`${t.content}${t.lineEnding}`).join("")}r(V,"renderTextDocument");function Y(e,t={}){let o=e.lines.flatMap(s=>[...s.presentation?.before??[],G(s,t.compact===!0),...s.presentation?.after??[]]),i=T(o),c=0;return e.lines.map(s=>{let m=1+(s.presentation?.before?.length??0)+(s.presentation?.after?.length??0),k=i.slice(c,c+m).join(`
|
|
2
|
-
`);return c+=m,`${k}${s.lineEnding}`}).join("")}r(Y,"renderPresentedTextDocument");function G(e,t){let o=t&&e.presentation?.compactPrefix!==void 0?e.presentation.compactPrefix:e.presentation?.prefix,i=t&&e.presentation?.compactSuffix!==void 0?e.presentation.compactSuffix:e.presentation?.suffix;return{content:e.content,...o!==void 0&&{prefix:o},...i!==void 0&&{suffix:i},...e.presentation?.marker!==void 0&&{marker:e.presentation.marker}}}r(G,"presentedRowFor");function H(e){if(e.length===0)return[];let t=[],o=/([^\r\n]*)(\r\n|\r|\n|$)/gu,i;for(;(i=o.exec(e))!==null&&i[0].length!==0;)t.push({lineNumber:t.length+1,content:i[1]??"",lineEnding:i[2]??""});return t}r(H,"splitTextLines");function A(e,t){try{return W.Check(e,t)}catch{return!1}}r(A,"safeCheck");var J=new Set(["application/ecmascript","application/graphql","application/javascript","application/json","application/sql","application/toml","application/x-httpd-php","application/x-javascript","application/x-ndjson","application/x-www-form-urlencoded","application/x-yaml","application/xml","application/yaml"]);function Q(){return{id:"text",description:"UTF-8 text.",tryConvert(e,t){return Promise.resolve(X(e,t))}}}r(Q,"createTextContentConverter");function X(e,t){let o=ee(t.signal);if(o!==void 0)return{kind:"failed",error:o};try{return{kind:"converted",content:[{type:"text",text:new TextDecoder("utf8",{fatal:!0}).decode(e.bytes)}]}}catch(i){return b(e.mediaType)?{kind:"failed",error:new TypeError(`${e.source} is not valid UTF-8 text`,{cause:i})}:{kind:"not-handled"}}}r(X,"convertText");function b(e){if(e===void 0)return!1;let t=e.split(";",1)[0]?.trim().toLowerCase()??"";return t.startsWith("text/")||J.has(t)||t.endsWith("+json")||t.endsWith("+xml")}r(b,"isTextualMediaType");function Z(e){let t=e[0];if(e.length!==1||t.type!=="text")throw new TypeError("Text resources require exactly one text block");return t.text}r(Z,"textFromAgentContent");function ee(e){if(e?.aborted===!0)return e.reason instanceof Error?e.reason:te()}r(ee,"cancellationError");function te(){let e=new Error("The operation was aborted");return e.name="AbortError",e}r(te,"abortError");function ne(e){if(e===null||typeof e!="object")return!1;let t=e;if(t.kind==="not-handled")return!0;if(t.kind==="failed")return"error"in t;if(t.kind==="rejected"){let o=t.rejection;return o!==null&&typeof o=="object"&&["invalid","stale","missing","ambiguous"].includes(o.code)&&typeof o.reason=="string"}return t.kind!=="resolved"||!Array.isArray(t.targets)||t.targets.length===0?!1:t.targets.every(o=>{if(o===null||typeof o!="object")return!1;let i=o.source,c=o.ranges;return typeof i=="string"&&i.length>0&&(c===void 0||Array.isArray(c)&&c.every(re))})}r(ne,"isTextTargetResolutionAttempt");function re(e){if(e===null||typeof e!="object")return!1;let t=e;return v(t.start)&&v(t.end)&&(t.linewise===void 0||typeof t.linewise=="boolean")}r(re,"isTextSelectionRange");function v(e){if(e===null||typeof e!="object")return!1;let t=e;return Number.isInteger(t.lineNumber)&&t.lineNumber>=1&&Number.isInteger(t.column)&&t.column>=0}r(v,"isTextSelectionPosition");function oe(e,t){if(e.length<16)return e;let o=t.indexOf(e);return o<0?e:[o,e.length]}r(oe,"storeText");function ie(e,t){return typeof e=="string"?e:t.slice(e[0],e[0]+e[1])}r(ie,"restoreText");export{u as a,w as b,S as c,P as d,D as e,I as f,M as g,T as h,$ as i,F as j,_ as k,z as l,K as m,V as n,Y as o,Q as p,b as q,Z as r,ne as s,oe as t,ie as u};
|
package/dist/chunk-2XYXV5HS.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{a as A}from"./chunk-WZI4YC2O.js";import{a as I}from"./chunk-ERVMDQGX.js";import{a as D,b as $}from"./chunk-VFBLX4TG.js";import{a as j}from"./chunk-OBWZ5RYN.js";import{a as b,b as L}from"./chunk-KZBAJFCV.js";import{e as P,g as R,h as k,i as E,l as S}from"./chunk-L4FA6OD4.js";import{a as u}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import v from"node:path";import{fileURLToPath as X}from"node:url";function z(t,e){if(t.trim().length===0)return[];switch(e.format){case"pi-json":return q(t);case"eslint-json":return F(t);case"sarif":return J(t);case"checkstyle":return V(t);case"gcc":case"clang":return W(t);case"regex":return G(t,u(e.pattern),e.columnBase??1)}}s(z,"parseDiagnostics");function q(t){let e=JSON.parse(t);return Array.isArray(e.diagnostics)?e.diagnostics.flatMap(p):[]}s(q,"parsePiJson");function F(t){return JSON.parse(t).flatMap(n=>Array.isArray(n.messages)?n.messages.flatMap(i=>p(i).map(r=>({...r,...n.filePath&&{file:n.filePath}}))):[])}s(F,"parseEslintJson");function J(t){return(JSON.parse(t).runs??[]).flatMap(n=>(n.results??[]).flatMap(i=>{let r=i.locations?.[0]?.physicalLocation,c=r?.region??{},o=i.message;return p({file:r?.artifactLocation?.uri,line:c.startLine,column:c.startColumn,message:o?.text,code:i.ruleId,severity:H(i.level)})}))}s(J,"parseSarif");function V(t){let e=[];for(let n of t.matchAll(/<file\s+([^>]+)>([\s\S]*?)<\/file>/gu)){let i=T(u(n[1])).name;for(let r of u(n[2]).matchAll(/<error\s+([^>]+?)\/?>(?:<\/error>)?/gu)){let c=T(u(r[1]));e.push(...p({file:i,line:Number(c.line),column:Number(c.column??1),message:c.message,code:c.source,severity:c.severity}))}}return e}s(V,"parseCheckstyle");function T(t){return Object.fromEntries([...t.matchAll(/([\w-]+)="([^"]*)"/gu)].map(e=>[u(e[1]),U(u(e[2]))]))}s(T,"xmlAttributes");function W(t){return Z(t,/^(?<file>.+?):(?<line>\d+):(?<column>\d+):\s*(?<severity>fatal error|error|warning|note|info|hint):\s*(?<message>.*?)(?:\s+\[(?<code>[^\]]+)\])?$/u)}s(W,"parseCompilerLines");function G(t,e,n){return[...t.replaceAll(`\r
|
|
2
|
-
`,`
|
|
3
|
-
`).matchAll(new RegExp(e,"gmu"))].flatMap(i=>i.groups===void 0?[]:p({...i.groups,...i.groups.column!==void 0&&{column:Number(i.groups.column)+(1-n)}}))}s(G,"parseRegexLines");function Z(t,e){return t.split(/\r?\n/u).flatMap(n=>{let i=n.match(e)?.groups;return i===void 0?[]:p(i)})}s(Z,"parseMatchingLines");function p(t){if(typeof t!="object"||t===null)return[];let e=t,n=N(e.line??e.startLine),i=N(e.column??e.startColumn,1),r=typeof e.message=="string"?e.message:void 0;return n===void 0||r===void 0?[]:[{...typeof e.file=="string"&&{file:e.file},code:O(e.code??e.ruleId,"lint"),message:r,line:n,column:i??1,severity:B(e.severity)}]}s(p,"normalizeDiagnostic");function N(t,e){let n=typeof t=="string"?Number.parseInt(t,10):t;return typeof n=="number"&&Number.isInteger(n)&&n>=1?n:e}s(N,"numberValue");function O(t,e){return typeof t=="string"||typeof t=="number"?String(t):e}s(O,"stringValue");function B(t){if(t===2)return"error";if(t===1)return"warning";let e=O(t,"warning").toLowerCase();return e.includes("error")||e==="e"||e==="f"||e==="fatal"?"error":e==="info"||e==="note"||e==="notice"?"info":e==="hint"?"hint":"warning"}s(B,"severityValue");function H(t){return t==="error"||t==="warning"||t==="note"?t:"warning"}s(H,"sarifSeverity");function U(t){return t.replace(/&#(x[0-9a-f]+|\d+);/giu,(e,n)=>{let i=n.toLowerCase().startsWith("x")?Number.parseInt(n.slice(1),16):Number(n);return i<=1114111?String.fromCodePoint(i):e}).replaceAll(""",'"').replaceAll("'","'").replaceAll("<","<").replaceAll(">",">").replaceAll("&","&")}s(U,"decodeXml");var w=[a("dart-analyze",["dart"],["dart"],["analysis_options.yaml","pubspec.yaml"],[".dart"],["dart","analyze","--format","machine","{file}"],"regex","https://dart.dev/tools/dart-analyze","^(?<severity>[^|]+)\\|[^|]+\\|(?<code>[^|]+)\\|(?<file>[^|]+)\\|(?<line>\\d+)\\|(?<column>\\d+)\\|\\d+\\|(?<message>.*)$",void 0,[0,1,2,3]),a("zig-ast-check",["zig"],["zig"],["build.zig","build.zig.zon","zls.json"],[".zig",".zon"],["zig","ast-check","{file}"],"gcc","https://ziglang.org/documentation/master/"),a("lintr",["r"],["Rscript"],[".lintr","DESCRIPTION"],[".r"],["Rscript","-e","print(lintr::lint(commandArgs(TRUE)[1]))","{file}"],"regex","https://lintr.r-lib.org/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<severity>[^:]+): \\[(?<code>[^\\]]+)\\] (?<message>.*)$"),a("clang-tidy",["c","cpp"],["clang-tidy"],[".clang-tidy","compile_commands.json"],[".c",".h",".cc",".cpp",".cxx",".hh",".hpp",".hxx"],["clang-tidy","{file}"],"clang","https://clang.llvm.org/extra/clang-tidy/"),a("eslint",["javascript","typescript","vue","svelte"],["eslint"],["eslint.config.js","eslint.config.mjs","eslint.config.cjs","eslint.config.ts","eslint.config.mts","eslint.config.cts",".eslintrc",".eslintrc.json",".eslintrc.js",".eslintrc.cjs",".eslintrc.yaml",".eslintrc.yml"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".vue",".svelte"],["eslint","--format","json","{file}"],"eslint-json","https://eslint.org/docs/latest/",void 0,["eslint"]),a("oxlint",["javascript","typescript"],["oxlint"],[".oxlintrc.json",".oxlintrc.jsonc","oxlint.config.ts","oxlint.config.mts"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts"],["oxlint","--format","sarif","{file}"],"sarif","https://oxc.rs/docs/guide/usage/linter.html",void 0,["oxlint"]),a("ruff",["python"],["ruff"],["pyproject.toml","ruff.toml",".ruff.toml"],[".py",".pyi"],["ruff","check","--output-format","concise","{file}"],"regex","https://docs.astral.sh/ruff/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<code>\\S+) (?<message>.+)$",["ruff"]),a("golangci-lint",["go"],["golangci-lint"],[".golangci.yml",".golangci.yaml","go.mod"],[".go"],["golangci-lint","run","--output.text.path=","--output.checkstyle.path=stdout","--show-stats=false","./..."],"checkstyle","https://golangci-lint.run/"),a("clippy",["rust"],["cargo"],["Cargo.toml","clippy.toml"],[".rs"],["cargo","clippy","--message-format","short"],"gcc","https://doc.rust-lang.org/clippy/"),a("dotnet-format",["csharp"],["dotnet"],[".editorconfig","global.json"],[".cs"],["dotnet","format","--verify-no-changes","--include","{relativeFile}"],"regex","https://learn.microsoft.com/dotnet/core/tools/dotnet-format","^(?<file>.+)\\((?<line>\\d+),(?<column>\\d+)\\): (?<severity>error|warning) (?<code>[^:]+): (?<message>.*?)(?: \\[.*\\])?$",void 0,[0,2]),a("checkstyle",["java"],["checkstyle"],["checkstyle.xml","pom.xml"],[".java"],["checkstyle","-c","checkstyle.xml","-f","xml","{file}"],"checkstyle","https://checkstyle.org/"),a("detekt",["kotlin"],["detekt"],["detekt.yml","build.gradle.kts"],[".kt",".kts"],["detekt","--input","{file}","--config","detekt.yml"],"regex","https://detekt.dev/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<message>.*?) \\[(?<code>[^\\]]+)\\]$",void 0,[0,2]),a("rubocop",["ruby"],["rubocop"],[".rubocop.yml","Gemfile"],[".rb",".rake"],["rubocop","--format","clang","{file}"],"regex","https://docs.rubocop.org/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<severity>[A-Z]): (?:\\[Correctable\\] )?(?<code>[^:]+): (?<message>.*)$"),a("phpcs",["php"],["phpcs"],["phpcs.xml","phpcs.xml.dist","composer.json"],[".php"],["phpcs","--report=checkstyle","{file}"],"checkstyle","https://github.com/PHPCSStandards/PHP_CodeSniffer",void 0,void 0,[0,1,2,3]),a("swiftlint",["swift"],["swiftlint"],[".swiftlint.yml","Package.swift"],[".swift"],["swiftlint","lint","--quiet","--reporter","checkstyle","{file}"],"checkstyle","https://github.com/realm/SwiftLint",void 0,void 0,[0,2]),a("scalafix",["scala"],["scalafix"],[".scalafix.conf"],[".scala",".sc"],["scalafix","--check","--files","{file}"],"gcc","https://scalacenter.github.io/scalafix/",void 0,void 0,[0,2,64,66]),a("credo",["elixir"],["mix"],["mix.exs",".credo.exs"],[".ex",".exs"],["mix","credo","--strict","--format","flycheck","--files-included","{file}"],"regex","https://hexdocs.pm/credo/","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): (?<severity>[A-Z]): (?<message>.+)$",void 0,Array.from({length:32},(t,e)=>e)),a("psscriptanalyzer",["powershell"],["pwsh"],["PSScriptAnalyzerSettings.psd1"],[".ps1",".psm1",".psd1"],["pwsh","-NoProfile","-NonInteractive","-CommandWithArgs",'$ErrorActionPreference="Stop";$options=@{};if(Test-Path -LiteralPath PSScriptAnalyzerSettings.psd1){$options.Settings="PSScriptAnalyzerSettings.psd1"};Invoke-ScriptAnalyzer -Path $args[0] @options | ForEach-Object {"$($_.ScriptPath):$($_.Line):$($_.Column): $($_.Severity): $($_.Message) [$($_.RuleName)]"}',"{file}"],"regex","https://learn.microsoft.com/powershell/module/psscriptanalyzer/invoke-scriptanalyzer","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): (?<severity>\\w+): (?<message>.+) \\[(?<code>[^\\]]+)\\]$",void 0,[0]),a("luacheck",["lua"],["luacheck"],[".luacheckrc"],[".lua"],["luacheck","--formatter","plain","--codes","--no-color","{file}"],"regex","https://github.com/lunarmodules/luacheck","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): \\((?<code>(?<severity>[WE])\\d+)\\) (?<message>.+)$",void 0,[0,1,2]),a("shellcheck",["shell"],["shellcheck"],[".shellcheckrc"],[".sh",".bash",".zsh"],["shellcheck","-f","gcc","{file}"],"gcc","https://www.shellcheck.net/"),a("stylelint",["css"],["stylelint"],["stylelint.config.js",".stylelintrc.json"],[".css",".scss",".sass",".less"],["stylelint","--formatter","compact","{file}"],"regex","https://stylelint.io/","^(?<file>.+): line (?<line>\\d+), col (?<column>\\d+), (?<severity>error|warning) - (?<message>.+) \\((?<code>[^)]+)\\)$",["stylelint"],[0,2]),a("yamllint",["yaml"],["yamllint"],[".yamllint",".yamllint.yml"],[".yaml",".yml"],["yamllint","-f","parsable","{file}"],"regex","https://yamllint.readthedocs.io/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): \\[(?<severity>[^\\]]+)\\] (?<message>.*?) \\((?<code>[^)]+)\\)$"),a("markdownlint",["markdown"],["markdownlint"],[".markdownlint.json",".markdownlint.yaml"],[".md",".mdx"],["markdownlint","{file}"],"regex","https://github.com/DavidAnson/markdownlint","^(?<file>.+?):(?<line>\\d+)(?::(?<column>\\d+))? (?<severity>error|warning) (?<code>MD\\d+)(?:/\\S+)? (?<message>.*)$"),a("sqlfluff",["sql"],["sqlfluff"],[".sqlfluff","pyproject.toml"],[".sql"],["sqlfluff","lint","--format","sarif","{file}"],"sarif","https://docs.sqlfluff.com/"),a("hadolint",["dockerfile"],["hadolint"],[".hadolint.yaml"],[".dockerfile"],["hadolint","--format","checkstyle","{file}"],"checkstyle","https://github.com/hadolint/hadolint",void 0,void 0,[0,1],void 0,["Dockerfile","Containerfile"]),a("tflint",["terraform"],["tflint"],[".tflint.hcl"],[".tf"],["tflint","--format","checkstyle"],"checkstyle","https://github.com/terraform-linters/tflint",void 0,void 0,[0,2]),a("cmake-lint",["cmake"],["cmake-lint"],[".cmake-format.py","CMakeLists.txt"],[".cmake"],["cmake-lint","{file}"],"regex","https://cmake-format.readthedocs.io/","^(?<file>.+?):(?<line>\\d+),(?<column>\\d+): \\[(?<code>(?<severity>[A-Z])\\d+)\\] (?<message>.*)$",void 0,[0,1],0,["CMakeLists.txt"]),a("htmlhint",["html"],["htmlhint"],[".htmlhintrc"],[".html",".htm"],["htmlhint","--format","checkstyle","--nocolor","{file}"],"checkstyle","https://htmlhint.com/"),a("jsonlint",["json"],["jsonlint"],[".jsonlintrc",".jsonlintrc.json",".jsonlintrc.yaml",".jsonlintrc.yml",".jsonlintrc.js",".jsonlintrc.cjs","jsonlint.config.js","jsonlint.config.cjs"],[".json"],["jsonlint","-q","{file}"],"regex","https://github.com/prantlf/jsonlint","^(?:Error: )?(?<message>Parse (?<severity>error) on line (?<line>\\d+)(?:, column (?<column>\\d+))?:[^\\n]*)$",["@prantlf/jsonlint","jsonlint"]),a("taplo-check",["toml"],["taplo"],["taplo.toml"],[".toml"],["taplo","check","--colors","never","{file}"],"regex","https://taplo.tamasfe.dev/","^(?<severity>error): (?<message>[^\\n]+)\\n\\s*\u250C\u2500 (?<file>.+):(?<line>\\d+):(?<column>\\d+)"),a("xmllint",["xml"],["xmllint"],[".xmllintrc"],[".xml",".xsd",".xsl"],["xmllint","--noout","{file}"],"regex","https://gnome.pages.gitlab.gnome.org/libxml2/xmllint.html","^(?<file>.+?):(?<line>\\d+): (?<severity>(?:parser |validity )?(?:error|warning)) : (?<message>.*)$",void 0,[0,1,2,3,4])];function a(t,e,n,i,r,c,o,d,l,f,h=[0,1],g,x){return{id:t,name:t,kind:"linter",languages:e,executables:n,configFiles:i,documentation:d,...f&&{dependencies:f},linter:{extensions:r,...x&&{fileNames:x},check:{command:c,successExitCodes:h},diagnostics:{format:o,...l&&{pattern:l},...g!==void 0&&{columnBase:g}}}}}s(a,"recipe");var m=class t{constructor(e,n,i=new Map){this.linters=e;this.availableBuiltIns=n;this.evidence=i}static{s(this,"LintCommandRegistry")}static async fromDirectory(e,n={}){let i=await P(e,"linters",l=>S(l).linters,n),r=n.environment??process.env,c=await Promise.all(i.entries.filter(l=>l.layer==="built-in").map(async l=>({id:l.id,available:await k(l.config.check,e,r)}))),o=await A(e,w),d=[...i.entries].sort((l,f)=>l.layer==="built-in"&&f.layer==="built-in"?(o.get(f.id)?.score??0)-(o.get(l.id)?.score??0):0);return new t(d,new Set(c.filter(l=>l.available).map(l=>l.id)),o)}static fromConfig(e){return new t(Object.entries(e.linters).map(([n,i])=>({id:n,config:i,layer:"project",sourcePath:"<memory>"})),new Set)}resolve(e,n){return this.resolveEntry(e,n)?.config}resolveEntry(e,n){return R(this.linters,this.availableBuiltIns,this.evidence,e,n)}get entries(){return this.linters}};async function y(t,e){let n;try{n=await E(t.check,e)}catch(d){return{ok:!1,diagnostics:[],failure:`command could not start: ${d instanceof Error?d.message:String(d)}`}}let i=t.diagnostics.format==="regex"||t.diagnostics.format==="clang"?[n.stdout,n.stderr].filter(d=>d.trim().length>0).join(`
|
|
4
|
-
`):n.stdout.trim().length>0?n.stdout:n.stderr,r;try{r=z(i,t.diagnostics)}catch{return{ok:!1,diagnostics:[],failure:`invalid ${t.diagnostics.format} diagnostics: ${i.trim().slice(0,200)||"empty command output"}`}}let c=n.ok&&(n.exitCode===0||r.length>0),o=t.check.cwd==="file"?v.dirname(e.filePath):e.projectRoot;return r=r.filter(d=>{if(d.file===void 0)return!0;let l=d.file.startsWith("file:")?X(d.file):d.file;return v.resolve(o,l)===v.resolve(e.filePath)}).map(({file:d,...l})=>l),{ok:c,diagnostics:r,...!c&&{failure:n.stderr.trim().slice(0,200)||`command exited with code ${String(n.exitCode)}`}}}s(y,"runConfiguredLinter");function _(t){return{kind:"linter",name:"command-lint",priority:100,extensions:["*"],detect:s(()=>Promise.resolve(!0),"detect"),async lint({filePath:e,fix:n},i){let r=t.resolve(e,i.cwd);if(r===void 0)return{ok:!0,diagnostics:[]};let c=n===!0&&r.fix!==void 0?r.fix:r.check,o=await y({...r,check:c},{projectRoot:i.cwd,filePath:e});return{ok:o.ok,diagnostics:o.diagnostics}}}}s(_,"createCommandLinter");import{copyFile as K,mkdtemp as Q,rm as Y}from"node:fs/promises";import C from"node:path";var M={protocol:D,apiVersion:1,id:"lint",setup(t){for(let e of w)t.addToolRecipe(e);t.addSetupCheck({id:"effective-config",inspect:ee}),t.addCheck({id:"config",title:"Linter",async run(e){try{let n=await m.fromDirectory(e.cwd,{environment:e.env}),i=te(n,e.files,e.cwd);return i.length===0?[{status:"skip",message:"No linter matches the inspected project files"}]:await Promise.all(i.map(async({entry:r,source:c})=>{let o=`${r.id} [${r.layer}] command ${JSON.stringify(r.config.check.command)}`,d=await Q(C.join(C.dirname(c),".pi-agent-ide-doctor-")),l=C.join(d,C.basename(c));try{await K(c,l);let f=await y(r.config,{projectRoot:e.cwd,filePath:l,env:e.env});return f.ok?{status:"pass",message:`${o}: probe passed`,detail:r.sourcePath}:{status:"fail",message:`${o}: probe failed`,detail:f.failure??r.sourcePath}}catch(f){return{status:"fail",message:`${o}: ${f instanceof Error?f.message:String(f)}`,detail:r.sourcePath}}finally{await Y(d,{recursive:!0,force:!0})}}))}catch(n){return[{status:"fail",message:n instanceof Error?n.message:String(n)}]}}})}};async function ee(t){try{let e=await m.fromDirectory(t.cwd,{environment:t.env}),n=[],i=new Map;for(let[r,c]of t.detectedLanguages){let o=c.map(d=>e.resolveEntry(d,t.cwd)).find(d=>d!==void 0);o!==void 0&&(n.push({kind:"linter",languageId:r,toolId:o.id}),await k(o.config.check,t.cwd,t.env)||i.set(o.id,{id:`linter-${o.id}-unavailable`,message:`Configured linter ${o.id} cannot run ${JSON.stringify(o.config.check.command)}`}))}return{selections:n,actions:[...i.values()]}}catch(e){return{actions:[{id:"linter-config-invalid",message:`Linter configuration cannot load: ${e instanceof Error?e.message:String(e)}`}]}}}s(ee,"inspectLinterSetup");function te(t,e,n){let i=new Map;for(let r of e){let c=t.resolveEntry(r,n);c!==void 0&&!i.has(c.id)&&i.set(c.id,{entry:c,source:r})}return[...i.values()]}s(te,"applicableLinters");async function ne(t){let e,n,i=s(o=>((n===void 0||e!==o)&&(e=o,n=ie(o)),n),"registryFor"),r={kind:"linter",name:"pi-agent-ide-lint",priority:200,extensions:["*"],detect:s(async o=>(await i(o.cwd),!0),"detect"),async lint(o,d){let l=await i(d.cwd);return _(l).lint(o,d)}},c={protocol:b,apiVersion:3,id:"lint",setup(o){o.addTool(r),o.addDiagnosticSource({id:"lint",async diagnose(d,l){let f=await i(l.cwd);l.signal.throwIfAborted();let h=f.resolve(d,l.cwd);if(!h)return{status:"unavailable",diagnostics:[],reason:"No linter configured for this file"};let g=await y(h,{projectRoot:l.cwd,filePath:d,signal:l.signal});return!g.ok&&g.diagnostics.length===0?{status:"unavailable",diagnostics:[],reason:g.failure??"Lint check failed"}:{status:"ready",diagnostics:g.diagnostics}}})}};await Promise.all([j(t,c),I(t,M)])}s(ne,"registerLint");async function ie(t){let e=process.env.PI_AGENT_IDE_CONFIG_DIR??t;return m.fromDirectory(e)}s(ie,"loadRegistry");export{ne as a};
|
package/dist/chunk-2ZMYT6ZC.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d}from"./chunk-EW2KVKCN.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-34ZQTTU2.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as j}from"./chunk-MTTKFJV6.js";import{m as T}from"./chunk-2SKAED2I.js";import{a as S}from"./chunk-ZC65Z3CK.js";import{a as c}from"./chunk-EI7MMDWY.js";import{createHash as ce}from"node:crypto";import{readFile as Q}from"node:fs/promises";import h from"node:path";import{spawn as Y}from"node:child_process";import O from"node:path";import{createInterface as Z}from"node:readline";import{existsSync as q}from"node:fs";import X from"node:os";import H from"node:path";function F(e=process.env.PI_CODING_AGENT_DIR??H.join(X.homedir(),".pi","agent"),n=process.platform){let t=H.join(e,"bin",n==="win32"?"rg.exe":"rg");return q(t)?t:"rg"}c(F,"resolveRipgrepExecutable");async function R(e,n,t){if(e.query.length===0)throw new Error("Search query must not be empty.");if(/\r|\n/u.test(e.query))throw new Error("Search supports one-line patterns only.");let r=e.limit??100,o=O.resolve(n,ne(e.path??".")),s=["--json","--no-config","--no-ignore-parent","--color=never","--with-filename","--line-number",e.caseSensitive===!0?"--case-sensitive":"--ignore-case",...e.wholeWord===!0?["--word-regexp"]:[],...L(e.include).flatMap(i=>["--glob",i]),...L(e.exclude).flatMap(i=>["--glob",`!${i}`]),"--",e.query,o];if(e.regex!==!0)return k(["--fixed-strings",...s],r,t);try{return await k(["--engine","auto",...s],r,t)}catch(i){if(!ee(i))throw i;return k(["--engine","default",...s],r,t)}}c(R,"searchText");function k(e,n,t){return new Promise((r,o)=>{let s=Y(F(),e,{stdio:["ignore","pipe","pipe"]}),i=Z({input:s.stdout}),a=[],u="",l=!1,d,p=c(()=>{s.kill()},"abort"),f=c(()=>{t?.removeEventListener("abort",p),i.close()},"cleanup");s.stderr.setEncoding("utf8"),s.stderr.on("data",m=>{u+=m}),i.on("line",m=>{if(!(l||d!==void 0||m.length===0))try{let g=JSON.parse(m);if(g.type!=="match")return;for(let V of te(g)){if(a.length===n){l=!0,s.kill();return}a.push(V)}}catch(g){d=g,s.kill()}}),s.once("error",m=>{f(),o(m)}),s.once("close",m=>{if(f(),t?.aborted===!0){let g=new Error("Search was aborted.");g.name="AbortError",o(g);return}if(d!==void 0){o(new Error("Unable to parse ripgrep search output.",{cause:d}));return}if(!l&&m!==0&&m!==1){o(new Error(u.trim()||`ripgrep exited with code ${String(m)}.`));return}a.sort(re),r({matches:a,complete:!l})}),t?.addEventListener("abort",p,{once:!0}),t?.aborted===!0&&p()})}c(k,"runRipgrep");function ee(e){return e instanceof Error&&/PCRE2: error matching: match limit exceeded/iu.test(e.message)}c(ee,"isPcre2MatchLimitError");function te(e){let n=e.data.path.text,t=e.data.lines.text;if(n===void 0||t===void 0||!Number.isSafeInteger(e.data.line_number))return[];let r=t.replace(/(?:\r\n|\n)$/u,""),o=Buffer.from(t),s=[];for(let i of e.data.submatches){if(i.start<0||i.end<=i.start||i.end>o.length)continue;let a=o.subarray(0,i.start).toString("utf8").length,u=o.subarray(0,i.end).toString("utf8").length;s.push({source:O.resolve(n),lineNumber:e.data.line_number,startColumn:a,endColumn:u,matchedText:r.slice(a,u),lineText:r})}return s}c(te,"matchesFromEvent");function L(e){if(e===void 0)return[];let n=[],t=0,r="";for(let o of e){if(o==="{"?t+=1:o==="}"&&(t=Math.max(0,t-1)),t===0&&(o===","||/\s/u.test(o))){r.length>0&&(n.push(r),r="");continue}r+=o}return r.length>0&&n.push(r),n}c(L,"splitGlobList");function ne(e){return e.startsWith("@")?e.slice(1):e}c(ne,"stripFilePrefix");function re(e,n){return e.source.localeCompare(n.source)||e.lineNumber-n.lineNumber||e.startColumn-n.startColumn||e.endColumn-n.endColumn}c(re,"compareMatches");function E(e,n=!1){let t=M(e);if(!C(t))return n?e:N(e);let r=v(new A(e,t).parse(),n);return`^${r.condition}.*?\\K(${r.match})`}c(E,"compileSearchQuery");function _(e){if(C(M(e)))return;let n=[...new Set(e.trim().split(/\s+/u).filter(Boolean))];return n.length>1?`(?:${n.map(N).join("|")})`:void 0}c(_,"compileSearchFallbackQuery");function C(e){return e.some(n=>n.quoted===!0||n.type==="and"||n.type==="or"||n.type==="not")}c(C,"containsBooleanSyntax");var A=class{static{c(this,"BooleanQueryParser")}#t;#r;#i=0;constructor(n,t){this.#t=n,this.#r=t}parse(){let n=this.#s(),t=this.#e();if(t.type!=="end"){let r=t.type==="right"?"unexpected ')'.":`unexpected ${se(t)}.`;throw y(t.offset,r)}return n}#s(){let n=this.#n();for(;this.#e().type==="or";){let t=this.#o(),r=this.#a(`after ${t.value}`);n={kind:"or",left:n,right:this.#c(r)}}return n}#n(){return this.#c(this.#a())}#c(n){let t=n;for(;;){let r=this.#e();if(r.type==="and"||r.type==="not"){this.#o();let o=this.#a(`after ${r.value}`);t={kind:r.type,left:t,right:o};continue}if(r.type==="term"||r.type==="left"){t={kind:"and",left:t,right:this.#a()};continue}return t}}#a(n){let t=this.#e();if(t.type==="term")return this.#o(),{kind:"term",value:t.value,quoted:t.quoted};if(t.type==="left"){if(this.#o(),this.#e().type==="right"||this.#e().type==="end")throw y(this.#e().offset,"expected a term after '('.");let o=this.#s();if(this.#e().type!=="right")throw y(this.#e().offset,"expected ')'.");return this.#o(),o}if(n===void 0&&(t.type==="and"||t.type==="or"||t.type==="not"))throw y(t.offset,`expected a term before ${t.value}.`);let r=n===void 0?"":` ${n}`;throw y(t.offset,`expected a term${r}.`)}#e(){return this.#r[this.#i]??{type:"end",value:"",offset:this.#t.length}}#o(){let n=this.#e();return this.#i+=1,n}};function M(e){let n=[],t=0;for(;t<e.length;){let r=e.charAt(t);if(/\s/u.test(r)){t+=1;continue}if(r==="("&&oe(e,t)){n.push({type:"left",value:r,offset:t}),t+=1;continue}if(r===")"){n.push({type:"right",value:r,offset:t}),t+=1;continue}if(W(e,t)){let i=e.charAt(t+1)==="|"?2:1;n.push({type:"or",value:e.slice(t,t+i),offset:t}),t+=i;continue}if(r==="'"||r==='"'){let i=t,a=r,u="";for(t+=1;t<e.length&&e.charAt(t)!==a;)e.charAt(t)==="\\"&&(e.charAt(t+1)===a||e.charAt(t+1)==="\\")&&(t+=1),u+=e.charAt(t++);if(t>=e.length)throw y(i,`unterminated ${a==="'"?"single":"double"}-quoted term.`);if(t+=1,u.length===0)throw y(i,"quoted terms must not be empty.");n.push({type:"term",value:u,offset:i,quoted:!0});continue}let o=t;for(;t<e.length;){let i=e.charAt(t);if(/\s/u.test(i)||i===")"||W(e,t))break;i==="\\"&&t+1<e.length?t+=2:i==="["||i==="("?t=$(e,t)??t+1:t+=1}let s=e.slice(o,t);n.push({type:ie(s),value:s,offset:o})}return n.push({type:"end",value:"",offset:e.length}),n}c(M,"tokenize");function W(e,n){return e.charAt(n)==="|"&&(e.charAt(n+1)==="|"||/\s/u.test(e.charAt(n-1))&&/\s/u.test(e.charAt(n+1)))}c(W,"isBooleanPipe");function $(e,n){let t=e.charAt(n)==="["?"]":")",r=n+1;for(;r<e.length;){let o=e.charAt(r);if(o==="\\")r+=2;else{if(o===t)return r+1;if(t===")"&&(o==="("||o==="[")){let s=$(e,r);if(s===void 0)return;r=s}else r+=1}}}c($,"regexBlockEnd");function oe(e,n){let t=$(e,n);if(t===void 0)return!0;let r=e.slice(n+1,t-1);return r.trim().length===0?!0:C(M(r))}c(oe,"isBooleanGroup");function ie(e){return e==="AND"?"and":e==="OR"?"or":e==="NOT"?"not":"term"}c(ie,"operatorType");function se(e){return e.value.length>0?JSON.stringify(e.value):"the end of the query"}c(se,"quoteToken");function y(e,n){return new SyntaxError(`Invalid Boolean search query at column ${String(e+1)}: ${n}`)}c(y,"syntaxError");function v(e,n){if(e.kind==="term"){let o=n&&!e.quoted?e.value:N(e.value);return{condition:`(?=.*(?:${o}))`,match:o}}let t=v(e.left,n),r=v(e.right,n);return e.kind==="or"?{condition:`(?:${t.condition}|${r.condition})`,match:`(?:${t.match}|${r.match})`}:e.kind==="not"?{condition:`${t.condition}(?!${r.condition})`,match:t.match}:{condition:`${t.condition}${r.condition}`,match:`(?:${t.match}|${r.match})`}}c(v,"compileExpression");function N(e){return e.replace(/[\\^$.*+?()[\]{}|]/gu,"\\$&")}c(N,"escapeRegex");function $e(e){let n=E(e.query),t=E(e.query,!0),r=_(e.query),o=[];return t!==n&&o.push({query:t,mode:"regex"}),r!==void 0&&r!==n&&r!==t&&o.push({query:r,mode:"words"}),{...e,query:n,regex:!0,fallbacks:o}}c($e,"createSearchRecipe");async function D(e,n,t){let r=e.query,o=await R(e,n,t),s=[];for(let i of e.fallbacks??[]){if(o.matches.length>0||!o.complete)break;t?.throwIfAborted();try{o=await R({...e,query:i.query,regex:!0},n,t),r=i.query,s.push(i.mode==="regex"?"Search fallback: no literal matches; tried unquoted terms as regex.":"Search fallback: no matches in earlier modes; tried separate words.")}catch(a){if(i.mode!=="regex"||!ae(a)||t?.aborted)throw a;s.push("Search fallback: invalid regex skipped; literal search found no matches.")}}return{...o,query:r,notices:s}}c(D,"runSearchRecipe");function ae(e){return e instanceof Error&&/regex parse error:|PCRE2: error compiling pattern/iu.test(e.message)}c(ae,"isRegexSyntaxError");var le=/^SEARCH#([A-F0-9]{4,64}):(all|[1-9]\d*):(line|match)$/u,U=4;function We(e,n,t,r){return K(e,n,t,r).slice(0,U)}c(We,"createSearchSessionId");function K(e,n,t,r){let o=t===void 0?me(n.map(a=>a.source)):h.resolve(t),s=n.map(a=>({match:a,source:h.relative(o,h.resolve(a.source))})).sort((a,u)=>a.source.localeCompare(u.source)||I(a.match,u.match)).map(({match:a,source:u})=>[u,a.lineNumber,a.startColumn,a.endColumn,a.matchedText,a.lineText]),i=de(r??{query:e,regex:!0},o);return ce("sha256").update(JSON.stringify([e,o,i,s])).digest("hex").toUpperCase()}c(K,"createSearchSessionIdentity");function ue(e,n){if(!/^[A-F0-9]{64}$/u.test(e))throw new Error("Search session identity must be a 64-character uppercase hexadecimal value.");for(let t=U;t<=e.length;t+=1){let r=e.slice(0,t);if(!n.has(r))return r}throw new Error("Could not allocate a unique search session id.")}c(ue,"allocateSearchSessionId");function de(e,n){return{query:e.query,path:h.resolve(n,e.path??"."),include:e.include??"",exclude:e.exclude??"",caseSensitive:e.caseSensitive===!0,wholeWord:e.wholeWord===!0,limit:e.limit??100,regex:e.regex===!0,fallbacks:e.fallbacks??[]}}c(de,"normalizeRecipe");var G=class{constructor(n=K){this.createIdentity=n}static{c(this,"SearchSessionStore")}#t=new Map;#r=new Map;async register(n,t,r,o,s,i={query:n,regex:!0}){let a=t.map(m=>({...m,source:h.resolve(m.source)})).sort(I),u=await z(a,s),l=this.createIdentity(n,a,o,i),p=this.#r.get(l)??ue(l,new Set(this.#t.keys())),f={id:p,query:n,matches:a,complete:r,contentBySource:u,recipe:i,cwd:h.resolve(o)};return this.#r.set(l,p),this.#t.set(p,f),f}anchorResolver(){return{id:"search",description:["`SEARCH#HASH:N:line` selects one result's full line; `SEARCH#HASH:N:match` selects its exact match.","`SEARCH#HASH:all:line` selects each unique containing line; `SEARCH#HASH:all:match` selects every exact match.","Omit `path` when `all` spans files."].join(`
|
|
2
|
-
`),renderFull(n){return n},renderCompact(n){let t=B(n);return t===void 0?"selected result":t.selector==="all"?t.mode==="match"?"all matches":"all lines":t.mode==="match"?`match ${String(t.selector)}`:`line ${String(t.selector)}`},tryResolve:c((n,t)=>this.#i(n,t.source,t.signal),"tryResolve")}}resourceResolver(){return{id:"search-targets",tryResolve:c((n,t)=>this.#s(n,t.cwd),"tryResolve")}}async#i(n,t,r){let o=B(n);if(o===void 0)return{kind:"not-handled"};let s=this.#t.get(o.id);if(s===void 0)return b();if(o.selector==="all"&&!s.complete)return x();let i=h.resolve(t),a=s;if(o.selector==="all"){if(s.refreshedComplete?.complete===!0)a=s.refreshedComplete;else if(s.refreshedComplete!==void 0&&(a=await this.#n(s,r),!a.complete))return x()}let u=w(a,o.selector,o.mode),l=u.filter(f=>f.source===i);if(l.length===0)return{kind:"rejected",rejection:{code:"missing",reason:"search anchor does not select this resource"}};let d=await P(i,r);if(d===void 0)return b(S(l[0]).lineNumber);if(o.selector==="all"&&d!==a.contentBySource.get(i)){if(a=await this.#n(s,r),!a.complete)return x();u=w(a,o.selector,o.mode),l=u.filter(f=>f.source===i)}if(l.length===0)return{kind:"rejected",rejection:{code:"missing",reason:"search anchor does not select this resource"}};if(o.selector!=="all"&&d!==s.contentBySource.get(i))return b(S(l[0]).lineNumber);let p=T(i,d);return{kind:"resolved",anchor:new j(n,i,l.map(f=>J(p,f,o.mode)))}}async#s(n,t){let r=B(n);if(r===void 0)return{kind:"not-handled"};let o=this.#t.get(r.id);if(o===void 0)return b();if(r.selector==="all"&&!o.complete)return x();let s=o;if(r.selector==="all"){if(o.refreshedComplete?.complete===!0)s=o.refreshedComplete;else if(o.refreshedComplete!==void 0&&(s=await this.#n(o),!s.complete))return x();let l=new Set(w(s,r.selector,r.mode).map(d=>d.source));for(let d of l)if(await P(d)!==s.contentBySource.get(d)){if(s=await this.#n(o),!s.complete)return x();break}}let i=w(s,r.selector,r.mode);if(r.selector!=="all"){let l=i[0]?.source;if(l!==void 0&&await P(l)!==s.contentBySource.get(l))return b(i[0]?.lineNumber)}let a=new Map;for(let l of i){let d=a.get(l.source)??[];d.push(J(T(l.source,s.contentBySource.get(l.source)??l.lineText),l,r.mode)),a.set(l.source,d)}let u=[...a].map(([l,d])=>({source:l,ranges:d}));return u.length===0?{kind:"rejected",rejection:{code:"missing",reason:"search anchor has no matches"}}:{kind:"resolved",targets:u}}async#n(n,t){let r=await D(n.recipe,n.cwd,t),o=r.matches.map(i=>({...i,source:h.resolve(i.source)})).sort(I),s={matches:o,complete:r.complete,contentBySource:await z(o,t)};return this.#t.set(n.id,{...n,refreshedComplete:s}),s}};function B(e){let n=le.exec(e);if(n!==null)return{id:S(n[1]),selector:n[2]==="all"?"all":Number(n[2]),mode:n[3]==="line"?"line":"match"}}c(B,"parseSearchAnchor");function w(e,n,t){let r=n==="all"?e.matches:[e.matches[n-1]].filter(he);if(t==="match"||n!=="all")return r;let o=new Set;return r.filter(s=>{let i=`${s.source}\0${String(s.lineNumber)}`;return o.has(i)?!1:(o.add(i),!0)})}c(w,"selectMatches");function he(e){return e!==void 0}c(he,"isMatch");function J(e,n,t){if(t==="match")return{start:{lineNumber:n.lineNumber,column:n.startColumn},end:{lineNumber:n.lineNumber,column:n.endColumn}};let r=S(e.lines[n.lineNumber-1]);return{start:{lineNumber:n.lineNumber,column:0},end:{lineNumber:n.lineNumber+(r.lineEnding.length>0?1:0),column:r.lineEnding.length>0?0:r.content.length},linewise:!0}}c(J,"selectionRange");async function z(e,n){let t=new Map;for(let r of new Set(e.map(o=>o.source))){let o=await Q(r,{encoding:"utf8",...n!==void 0&&{signal:n}}),s=T(r,o);for(let i of e.filter(a=>a.source===r)){let a=s.lines[i.lineNumber-1]?.content;if(a!==i.lineText||a.slice(i.startColumn,i.endColumn)!==i.matchedText)throw new Error(`Search result in ${r} changed before its anchors were registered.`)}t.set(r,o)}return t}c(z,"snapshotContents");async function P(e,n){try{return await Q(e,{encoding:"utf8",...n!==void 0&&{signal:n}})}catch{return}}c(P,"readCurrent");function b(e=1){return{kind:"rejected",rejection:{code:"stale",reason:"search anchor is stale",contextRange:{offset:Math.max(1,e-2),limit:5}}}}c(b,"staleAnchor");function x(){return{kind:"rejected",rejection:{code:"missing",reason:"search did not register an all anchor because its result was limited"}}}c(x,"missingCompleteAnchor");function me(e){if(e.length===0)return".";let n=h.dirname(h.resolve(S(e[0])));for(let t of e.slice(1)){let r=h.resolve(t);for(;!fe(n,r);){let o=h.dirname(n);if(o===n)return n;n=o}}return n}c(me,"commonSourceDirectory");function fe(e,n){let t=h.relative(e,n);return t!==".."&&!t.startsWith(`..${h.sep}`)&&!h.isAbsolute(t)}c(fe,"isWithin");function I(e,n){return e.source.localeCompare(n.source)||e.lineNumber-n.lineNumber||e.startColumn-n.startColumn||e.endColumn-n.endColumn}c(I,"compareMatches");export{F as a,$e as b,D as c,We as d,K as e,ue as f,G as g};
|