pi-agent-ide 0.7.3 → 0.8.1
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 +48 -35
- package/README.md +70 -19
- package/dist/chunk-246NTPOS.js +1 -0
- package/dist/chunk-2ITKAXHO.js +1 -0
- package/dist/chunk-3WO2NOEQ.js +1 -0
- package/dist/{chunk-ZTYWHL2F.js → chunk-47SPPIXK.js} +1 -1
- package/dist/chunk-4HWKBCBH.js +1 -0
- package/dist/chunk-4W7GH3T7.js +10 -0
- package/dist/{chunk-JMVDFOTQ.js → chunk-57F5GTHO.js} +1 -1
- package/dist/chunk-6EDOLYOV.js +1 -0
- package/dist/chunk-756K3LJY.js +1 -0
- package/dist/chunk-7LOVUWNI.js +1 -0
- package/dist/chunk-A64JRDZK.js +1 -0
- package/dist/chunk-AIT3YWR5.js +3 -0
- package/dist/chunk-AKNHSDGV.js +1 -0
- package/dist/chunk-AUL5FGGK.js +2 -0
- package/dist/chunk-BB4A5UI3.js +5 -0
- package/dist/chunk-BQAKA3FU.js +1 -0
- package/dist/chunk-BR7GRH4A.js +5 -0
- package/dist/chunk-BXGMMZT3.js +1 -0
- package/dist/{chunk-ZIWPKIBZ.js → chunk-D4IA2MTA.js} +1 -1
- package/dist/chunk-DUUOCBS3.js +3 -0
- package/dist/chunk-DXONCYWF.js +3 -0
- package/dist/chunk-E2PHA4SQ.js +1 -0
- package/dist/{chunk-H445SHSJ.js → chunk-EMRJP6EM.js} +1 -1
- package/dist/chunk-GEMDU6XW.js +1 -0
- package/dist/chunk-GNACBJM3.js +1 -0
- package/dist/chunk-HCK7OIQ3.js +1 -0
- package/dist/chunk-HFJGCYFO.js +11 -0
- package/dist/chunk-ID4RJIVZ.js +9 -0
- package/dist/chunk-IMGIDBCC.js +1 -0
- package/dist/chunk-JKMXND6V.js +1 -0
- package/dist/chunk-L2B4DTVS.js +1 -0
- package/dist/chunk-LAJQSHEI.js +4 -0
- package/dist/chunk-LEKC4GQK.js +5 -0
- package/dist/chunk-LLRUJD62.js +1 -0
- package/dist/{chunk-2ZMMRINH.js → chunk-M4TVRCMZ.js} +1 -1
- package/dist/chunk-MKEC3U2M.js +4 -0
- package/dist/chunk-N56WAVYA.js +1 -0
- package/dist/chunk-OFILFO6D.js +1 -0
- package/dist/chunk-OI3HBIPK.js +2 -0
- package/dist/{chunk-S6QRG3TQ.js → chunk-OM4LYD3S.js} +1 -1
- package/dist/{chunk-WLZIUMJL.js → chunk-PRLIHLCS.js} +1 -1
- package/dist/chunk-Q5X6OXNS.js +2 -0
- package/dist/chunk-R2U5WXYR.js +1 -0
- package/dist/chunk-S72FVLUX.js +1 -0
- package/dist/chunk-SWA5B5B2.js +9 -0
- package/dist/chunk-T4FTT3U4.js +1 -0
- package/dist/chunk-T7MWQQIF.js +3 -0
- package/dist/chunk-TGC2ZACO.js +1 -0
- package/dist/chunk-TOYN4W4F.js +1 -0
- package/dist/chunk-TXG2H7YQ.js +9 -0
- package/dist/{chunk-QFTBY67N.js → chunk-UEVGZUII.js} +3 -3
- package/dist/{chunk-7UGNGK7Y.js → chunk-VAXLSPPU.js} +1 -1
- package/dist/chunk-VDP5CQHM.js +3 -0
- package/dist/chunk-VMGZMXEM.js +10 -0
- package/dist/chunk-VNTY7BKC.js +1 -0
- package/dist/chunk-W3YFF6OO.js +1 -0
- package/dist/chunk-W7M3V7FR.js +28 -0
- package/dist/chunk-WMHSVEIT.js +29 -0
- package/dist/chunk-WPBQ45ZL.js +1 -0
- package/dist/chunk-WXGTU2M6.js +1 -0
- package/dist/chunk-XSIKDVAR.js +25 -0
- package/dist/chunk-YHREORHH.js +2 -0
- package/dist/chunk-YJ6T3PEP.js +1 -0
- package/dist/chunk-YTYLS2UM.js +1 -0
- package/dist/chunk-Z2QGNTGQ.js +1 -0
- package/dist/{chunk-QDLTO5PH.js → chunk-ZAWRSA7N.js} +1 -1
- package/dist/chunk-ZV5ETNLQ.js +1 -0
- 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-13.js +1 -1
- package/dist/entry-14.js +1 -1
- package/dist/entry-15.js +1 -1
- package/dist/entry-16.js +1 -1
- package/dist/entry-17.js +1 -1
- package/dist/entry-18.js +1 -0
- package/dist/entry-2.js +1 -1
- package/dist/entry-20.js +1 -1
- package/dist/entry-21.js +1 -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 -2
- package/dist/entry-26.js +1 -1
- package/dist/entry-27.js +2 -2
- package/dist/entry-28.js +1 -1
- package/dist/entry-29.js +4 -1
- package/dist/entry-30.js +1 -1
- package/dist/entry-31.js +1 -17
- package/dist/entry-32.js +1 -1
- package/dist/entry-33.js +18 -3
- package/dist/entry-34.js +1 -1
- package/dist/entry-35.js +1 -1
- package/dist/entry-36.js +1 -4
- package/dist/entry-37.js +1 -9
- 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 +1 -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 +1 -25
- package/dist/entry-46.js +1 -1
- package/dist/entry-47.js +25 -1
- package/dist/entry-48.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +1 -3
- package/dist/entry-51.js +1 -13
- package/dist/entry-52.js +3 -1
- package/dist/entry-53.js +13 -1
- package/dist/entry-54.js +1 -1
- package/dist/entry-55.js +1 -1
- package/dist/entry-56.js +1 -1
- package/dist/entry-57.js +1 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-59.js +1 -1
- package/dist/entry-6.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-61.js +1 -0
- package/dist/entry-62.js +1 -1
- package/dist/entry-64.js +1 -1
- package/dist/entry-65.js +0 -1
- package/dist/entry-66.js +1 -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-7.js +1 -1
- package/dist/entry-70.js +1 -1
- package/dist/entry-71.js +1 -0
- package/dist/entry-72.js +1 -1
- package/dist/entry-74.js +1 -1
- package/dist/entry-75.js +0 -1
- package/dist/entry-76.js +1 -1
- package/dist/entry-77.js +1 -80
- package/dist/entry-78.js +1 -19
- package/dist/entry-79.js +80 -2
- package/dist/entry-8.js +1 -1
- package/dist/entry-80.js +22 -1
- package/dist/entry-81.js +2 -1
- package/dist/entry-82.js +1 -5
- package/dist/entry-83.js +1 -3
- package/dist/entry-84.js +1 -1
- package/dist/entry-85.js +3 -1
- package/dist/entry-86.js +1 -1
- package/dist/entry-87.js +1 -0
- package/dist/entry-88.js +1 -0
- package/dist/pi-agent-ide.js +53 -24
- package/docs/agent-guides/debugger.md +2 -0
- package/docs/agent-guides/editing.md +1 -1
- package/docs/agent-guides/search-code.md +7 -2
- package/docs/agent-guides/ssh.md +58 -0
- package/docs/agent-guides/vision.md +6 -0
- package/docs/configuration.md +51 -5
- package/docs/development.md +1 -13
- package/docs/extensions.md +1 -1
- package/docs/releases.md +1 -1
- package/docs/settings-help.md +39 -0
- package/docs/tools.md +22 -14
- package/docs/user-hooks.md +7 -3
- package/node_modules/pi-agent-doctor/package.json +10 -9
- package/node_modules/pi-agent-doctor/runtime/entry-25.js +1 -0
- package/node_modules/pi-agent-doctor/src/evidence.ts +49 -4
- package/node_modules/pi-agent-doctor/src/executable.ts +46 -16
- package/node_modules/pi-agent-doctor/src/fixtures/executable-probe.ts +78 -0
- package/node_modules/pi-agent-doctor/src/fixtures/probe-executable-wait.mjs +10 -0
- package/node_modules/pi-agent-doctor/src/plugin-protocol.ts +6 -0
- package/node_modules/pi-agent-doctor/src/project-probes.ts +73 -0
- package/node_modules/pi-agent-doctor/src/workspace.ts +106 -0
- package/node_modules/pi-agent-documentation/package.json +2 -2
- package/node_modules/pi-agent-documentation/runtime/entry-26.js +1 -0
- package/node_modules/pi-agent-filesystem/package.json +8 -8
- package/node_modules/pi-agent-filesystem/src/resolver.ts +23 -7
- package/node_modules/pi-agent-filesystem-image/package.json +4 -4
- package/node_modules/pi-agent-filesystem-jq/index.ts +33 -6
- package/node_modules/pi-agent-filesystem-jq/package.json +6 -7
- package/node_modules/pi-agent-filesystem-jq/src/jq.ts +67 -0
- package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
- package/node_modules/pi-agent-filesystem-pdf/runtime/entry-30.js +2 -0
- package/node_modules/pi-agent-filesystem-text/package.json +4 -4
- package/node_modules/pi-agent-ide-ast/package.json +15 -41
- package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +2 -1
- package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +10 -3
- package/node_modules/pi-agent-ide-ast/src/ast/read-text.ts +4 -1
- package/node_modules/pi-agent-ide-ast/src/ast/selection.ts +3 -3
- package/node_modules/pi-agent-ide-ast/src/doctor-plugin.ts +13 -10
- package/node_modules/pi-agent-ide-ast/src/extension.ts +17 -1
- package/node_modules/pi-agent-ide-ast/src/outline-resolver.ts +32 -4
- package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +2 -2
- package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +1 -1
- package/node_modules/pi-agent-ide-ast/src/search-presentation.ts +4 -3
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +100 -42
- package/node_modules/pi-agent-ide-ast/src/select-presentation.ts +3 -2
- package/node_modules/pi-agent-ide-ast/src/tool-select.ts +2 -1
- package/node_modules/pi-agent-ide-changes/index.ts +10 -2
- package/node_modules/pi-agent-ide-changes/package.json +10 -11
- package/node_modules/pi-agent-ide-changes/runtime/entry-34.js +1 -0
- package/node_modules/pi-agent-ide-changes/src/change-anchor.ts +7 -2
- package/node_modules/pi-agent-ide-changes/src/changes/change-service.ts +18 -1
- package/node_modules/pi-agent-ide-changes/src/changes/change-types.ts +3 -0
- package/node_modules/pi-agent-ide-changes/src/changes/git-changes-backend.ts +59 -7
- package/node_modules/pi-agent-ide-changes/src/changes/git-paths.ts +49 -0
- package/node_modules/pi-agent-ide-changes/src/current-change-presenter.ts +10 -2
- package/node_modules/pi-agent-ide-changes/src/doctor-plugin.ts +13 -14
- package/node_modules/pi-agent-ide-changes/src/last-text-transaction-store.ts +2 -1
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +47 -11
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +6 -1
- package/node_modules/pi-agent-ide-formatter/index.ts +14 -2
- package/node_modules/pi-agent-ide-formatter/package.json +4 -4
- package/node_modules/pi-agent-ide-formatter/src/doctor-plugin.ts +47 -35
- package/node_modules/pi-agent-ide-formatter/src/formatter.ts +41 -11
- package/node_modules/pi-agent-ide-formatter/src/registry.ts +9 -28
- package/node_modules/pi-agent-ide-languages/package.json +3 -3
- package/node_modules/pi-agent-ide-lint/index.ts +35 -4
- package/node_modules/pi-agent-ide-lint/package.json +8 -8
- package/node_modules/pi-agent-ide-lint/runtime/entry-38.js +2 -0
- package/node_modules/pi-agent-ide-lint/src/command-linter.ts +14 -10
- package/node_modules/pi-agent-ide-lint/src/doctor-plugin.ts +47 -39
- package/node_modules/pi-agent-ide-lint/src/registry.ts +9 -25
- package/node_modules/pi-agent-ide-lsp/index.ts +107 -25
- package/node_modules/pi-agent-ide-lsp/package.json +10 -13
- package/node_modules/pi-agent-ide-lsp/runtime/entry-39.js +2 -0
- package/node_modules/pi-agent-ide-lsp/src/code-view-resolvers.ts +6 -2
- package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +5 -1
- package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +5 -3
- package/node_modules/pi-agent-ide-lsp/src/doctor-plugin.ts +27 -11
- package/node_modules/pi-agent-ide-lsp/src/lsp/abort.ts +62 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +245 -103
- package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +26 -45
- package/node_modules/pi-agent-ide-lsp/src/lsp/diagnostic-adapters.ts +1 -1
- package/node_modules/pi-agent-ide-lsp/src/lsp/document-uri.ts +40 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/file-watchers.ts +8 -1
- package/node_modules/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +24 -17
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +255 -56
- package/node_modules/pi-agent-ide-lsp/src/lsp/navigation.ts +51 -11
- package/node_modules/pi-agent-ide-lsp/src/lsp/owner-transport.ts +67 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +149 -18
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +79 -31
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbols.ts +15 -12
- package/node_modules/pi-agent-ide-lsp/src/lsp/workspace-owner.ts +16 -0
- package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +67 -46
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +50 -19
- package/node_modules/pi-agent-image/package.json +3 -3
- package/node_modules/pi-agent-invariant/package.json +2 -2
- package/node_modules/pi-agent-pdf/package.json +3 -4
- package/node_modules/pi-agent-read/package.json +12 -12
- package/node_modules/pi-agent-read/runtime/entry-45.js +0 -1
- package/node_modules/pi-agent-read/runtime/entry-47.js +2 -0
- package/node_modules/pi-agent-read/src/api/tools/read.ts +4 -2
- package/node_modules/pi-agent-read/src/core/extension.ts +4 -1
- package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +143 -69
- package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +25 -1
- package/node_modules/pi-agent-read/src/core/tools/read/result-target.ts +67 -44
- package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +8 -3
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +20 -5
- package/node_modules/pi-agent-resource/package.json +2 -2
- package/node_modules/pi-agent-resource/src/content-conversion/content-host.ts +75 -16
- package/node_modules/pi-agent-resource/src/index.ts +3 -0
- package/node_modules/pi-agent-resource/src/resource-error.ts +17 -0
- package/node_modules/pi-agent-resource/src/resource.ts +23 -0
- package/node_modules/pi-agent-resource/src/result-targets.ts +25 -2
- package/node_modules/pi-agent-resource/src/validation.ts +2 -1
- package/node_modules/pi-agent-search/package.json +9 -9
- package/node_modules/pi-agent-search/runtime/entry-50.js +0 -1
- package/node_modules/pi-agent-search/runtime/entry-51.js +1 -0
- package/node_modules/pi-agent-search/runtime/entry-52.js +2 -0
- package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +1 -1
- package/node_modules/pi-agent-search/src/api/presentation.ts +10 -2
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +7 -3
- package/node_modules/pi-agent-search/src/api/search.ts +51 -2
- package/node_modules/pi-agent-search/src/core/extension.ts +2 -3
- package/node_modules/pi-agent-search/src/core/search-core.ts +98 -8
- package/node_modules/pi-agent-search-text/index.ts +37 -1
- package/node_modules/pi-agent-search-text/package.json +14 -12
- package/node_modules/pi-agent-search-text/runtime/entry-53.js +1 -0
- package/node_modules/pi-agent-search-text/runtime/entry-56.js +1 -0
- package/node_modules/pi-agent-search-text/src/doctor-plugin.ts +10 -5
- package/node_modules/pi-agent-search-text/src/file-search.ts +26 -3
- package/node_modules/pi-agent-search-text/src/fuzzy-search.ts +54 -3
- package/node_modules/pi-agent-search-text/src/resolvers.ts +22 -5
- package/node_modules/pi-agent-search-text/src/scoped-search.ts +4 -5
- package/node_modules/pi-agent-search-text/src/search-backend.ts +123 -17
- package/node_modules/pi-agent-search-text/src/search-recipe.ts +5 -1
- package/node_modules/pi-agent-search-text/src/search-result.ts +1 -0
- package/node_modules/pi-agent-search-text/src/search-session.ts +166 -31
- package/node_modules/pi-agent-text/package.json +3 -3
- package/node_modules/pi-agent-text/src/text-document.ts +2 -0
- package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
- package/node_modules/pi-agent-text-anchor-exact/package.json +5 -6
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-62.js +2 -0
- package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +3 -1
- package/node_modules/pi-agent-text-editor/package.json +26 -34
- package/node_modules/pi-agent-text-editor/runtime/entry-77.js +0 -1
- package/node_modules/pi-agent-text-editor/runtime/entry-78.js +1 -0
- package/node_modules/pi-agent-text-editor/src/api/delete-guard.ts +29 -2
- package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +3 -0
- package/node_modules/pi-agent-text-editor/src/api/file-operations.ts +55 -0
- package/node_modules/pi-agent-text-editor/src/api/file-transfers.ts +41 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-guard.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/api/native-edit-batch-event.ts +2 -2
- package/node_modules/pi-agent-text-editor/src/api/native-files.ts +127 -0
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +20 -1
- package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +1 -0
- package/node_modules/pi-agent-text-editor/src/core/delete-policy.ts +93 -85
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +15 -2
- package/node_modules/pi-agent-text-editor/src/core/file-operation-guards.ts +81 -0
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +70 -25
- package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +123 -27
- package/node_modules/pi-agent-text-editor/src/core/file-result-targets.ts +30 -1
- package/node_modules/pi-agent-text-editor/src/core/file-transfers.ts +147 -105
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +18 -9
- package/node_modules/pi-agent-text-editor/src/core/mutation-result-targets.ts +91 -14
- package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +74 -9
- package/node_modules/pi-agent-text-editor/src/core/temporary-directories.ts +49 -25
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +16 -8
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +122 -39
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +7 -4
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +307 -32
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +85 -31
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +22 -1
- package/node_modules/pi-agent-text-editor/src/core/write-agent-result.ts +4 -1
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -8
- package/node_modules/pi-agent-text-editor-renderer/runtime/entry-80.js +2 -0
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +139 -27
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-81.js +2 -0
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-82.js +1 -0
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-83.js +1 -0
- package/node_modules/pi-agent-web/index.ts +28 -4
- package/node_modules/pi-agent-web/package.json +8 -11
- package/node_modules/pi-agent-web/src/doctor-plugin.ts +21 -6
- package/node_modules/pi-agent-web/src/resolver.ts +12 -2
- package/node_modules/pi-agent-web/src/search.ts +2 -1
- package/node_modules/pi-agent-web-html/package.json +3 -5
- 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-pdf/runtime/entry-87.js +2 -0
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/node_modules/pi-agent-web-text/runtime/entry-88.js +2 -0
- package/package.json +43 -39
- package/skills/configure-agent-ide/SKILL.md +38 -0
- package/src/api/content.ts +6 -0
- package/src/api/doctor-runtime.ts +80 -0
- package/src/api/doctor.ts +6 -0
- package/src/api/hooks.ts +3 -0
- package/src/api/plugin-protocol.ts +11 -1
- package/src/api/tips.ts +3 -0
- package/src/api/tool-config.ts +143 -24
- package/src/backend/config.ts +85 -0
- package/src/backend/configured-process.ts +59 -0
- package/src/backend/dap-java-transport.ts +112 -0
- package/src/backend/dap-java-worker.py +218 -0
- package/src/backend/dap-node-transport.ts +112 -0
- package/src/backend/dap-powershell-worker.py +44 -0
- package/src/backend/dap-r-worker.py +210 -0
- package/src/backend/dap-tcp-transport.ts +42 -0
- package/src/backend/dap-tcp-worker.py +125 -0
- package/src/backend/dap-transport.ts +69 -0
- package/src/backend/dap-unix-worker.py +63 -0
- package/src/backend/debugger-registration.ts +62 -0
- package/src/backend/debugger-workspace-owner.ts +413 -0
- package/src/backend/doctor-inventory-worker.py +54 -0
- package/src/backend/doctor-probe-worker.py +140 -0
- package/src/backend/doctor-registration.ts +18 -0
- package/src/backend/doctor-workspace.ts +381 -0
- package/src/backend/file-operation-resolver.ts +58 -0
- package/src/backend/file-revision.ts +13 -0
- package/src/backend/file-transfer.ts +302 -0
- package/src/backend/file-watch-worker.py +119 -0
- package/src/backend/formatter-registration.ts +114 -0
- package/src/backend/git-registration.ts +60 -0
- package/src/backend/identity.ts +47 -0
- package/src/backend/index.ts +12 -0
- package/src/backend/lint-registration.ts +102 -0
- package/src/backend/lsp-file-watchers.ts +220 -0
- package/src/backend/lsp-registration.ts +83 -0
- package/src/backend/lsp-transport.ts +87 -0
- package/src/backend/lsp-workspace-owner.ts +50 -0
- package/src/backend/object-transfer.ts +299 -0
- package/src/backend/owned-command.ts +105 -0
- package/src/backend/owned-process-stop.ts +36 -0
- package/src/backend/owned-read-command.ts +20 -0
- package/src/backend/process-environment.ts +77 -0
- package/src/backend/process-metadata-worker.py +98 -0
- package/src/backend/process-metadata.ts +99 -0
- package/src/backend/recipe-evidence-worker.py +26 -0
- package/src/backend/recipe-evidence.ts +77 -0
- package/src/backend/registration.ts +124 -0
- package/src/backend/registry.ts +29 -0
- package/src/backend/resource-resolver.ts +147 -0
- package/src/backend/search-environment.ts +100 -0
- package/src/backend/ssh-channel-worker.py +306 -0
- package/src/backend/ssh-channel.ts +376 -0
- package/src/backend/ssh-transfer-worker.py +99 -0
- package/src/backend/ssh-transport.ts +54 -0
- package/src/backend/ssh-worker.py +730 -0
- package/src/backend/ssh.ts +610 -0
- package/src/backend/tool-config-access.ts +63 -0
- package/src/backend/tool-project.ts +71 -0
- package/src/backend/vision-capture-worker.py +319 -0
- package/src/backend/vision-capture.ts +165 -0
- package/src/backend/vision-registration.ts +104 -0
- package/src/backend/web-browser-worker.mjs +182 -0
- package/src/backend/web-browser.ts +128 -0
- package/src/backend/web-http-worker.py +62 -0
- package/src/backend/web-http.ts +79 -0
- package/src/backend/web-owner.ts +68 -0
- package/src/backend/web-registration.ts +14 -0
- package/src/code-view/diagnostic-view.ts +2 -2
- package/src/code-view/reference.ts +9 -0
- package/src/composite/builtin-extensions.ts +9 -14
- package/src/composite/module-labels.ts +1 -0
- package/src/composite/nested-tool-rendering.ts +26 -6
- package/src/composite/preferences.ts +13 -0
- package/src/composite/settings-documentation.ts +59 -0
- package/src/composite/settings-help.ts +106 -0
- package/src/composite/text-results.ts +50 -22
- package/src/core/diagnostic-store.ts +32 -10
- package/src/core/ide-core.ts +22 -2
- package/src/doctor/arguments.ts +19 -0
- package/src/doctor/config-writer.ts +72 -29
- package/src/doctor/discovery.ts +53 -15
- package/src/doctor/extension.ts +27 -10
- package/src/doctor/run.ts +42 -7
- package/src/documentation/extension.ts +12 -0
- package/src/documentation/search.ts +166 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +8 -8
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/index.ts +33 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +6 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/jq.ts +67 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-30.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-31.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-27.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/resolver.ts +23 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +28 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -11
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -5
- 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-pdf/runtime/entry-87.js +2 -0
- 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/plugins/pi-agent-web-text/runtime/entry-88.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-84.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/doctor-plugin.ts +21 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/resolver.ts +12 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/search.ts +2 -1
- package/src/extensions/pi-agent-read/package.json +12 -12
- package/src/extensions/pi-agent-read/runtime/entry-45.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-46.js +1 -0
- package/src/extensions/pi-agent-read/runtime/entry-47.js +2 -0
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +4 -2
- package/src/extensions/pi-agent-read/src/core/extension.ts +4 -1
- package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +143 -69
- package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +25 -1
- package/src/extensions/pi-agent-read/src/core/tools/read/result-target.ts +67 -44
- package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +8 -3
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +20 -5
- package/src/extensions/pi-agent-search/package.json +9 -9
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +37 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +14 -12
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-53.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-55.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-56.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/doctor-plugin.ts +10 -5
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +26 -3
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/fuzzy-search.ts +54 -3
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +22 -5
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +4 -5
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +123 -17
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +5 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +166 -31
- package/src/extensions/pi-agent-search/runtime/entry-50.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-51.js +1 -0
- package/src/extensions/pi-agent-search/runtime/entry-52.js +2 -0
- package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +1 -1
- package/src/extensions/pi-agent-search/src/api/presentation.ts +10 -2
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +7 -3
- package/src/extensions/pi-agent-search/src/api/search.ts +51 -2
- package/src/extensions/pi-agent-search/src/core/extension.ts +2 -3
- package/src/extensions/pi-agent-search/src/core/search-core.ts +98 -8
- package/src/extensions/pi-agent-text-editor/package.json +26 -34
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-61.js +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-62.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/read-handler.ts +3 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -8
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-80.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +139 -27
- 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/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-81.js +2 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-77.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-78.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-79.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/delete-guard.ts +29 -2
- package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +3 -0
- package/src/extensions/pi-agent-text-editor/src/api/file-operations.ts +55 -0
- package/src/extensions/pi-agent-text-editor/src/api/file-transfers.ts +41 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-guard.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/native-edit-batch-event.ts +2 -2
- package/src/extensions/pi-agent-text-editor/src/api/native-files.ts +127 -0
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +20 -1
- package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +1 -0
- package/src/extensions/pi-agent-text-editor/src/core/delete-policy.ts +93 -85
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +15 -2
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-guards.ts +81 -0
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +70 -25
- package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +123 -27
- package/src/extensions/pi-agent-text-editor/src/core/file-result-targets.ts +30 -1
- package/src/extensions/pi-agent-text-editor/src/core/file-transfers.ts +147 -105
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +18 -9
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result-targets.ts +91 -14
- package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +74 -9
- package/src/extensions/pi-agent-text-editor/src/core/temporary-directories.ts +49 -25
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +16 -8
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +122 -39
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +7 -4
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +307 -32
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +85 -31
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +22 -1
- package/src/extensions/pi-agent-text-editor/src/core/write-agent-result.ts +4 -1
- package/src/pi-agent-ide.ts +14 -2
- package/src/plugins/pi-agent-ide-ast/package.json +15 -41
- package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +2 -1
- package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +10 -3
- package/src/plugins/pi-agent-ide-ast/src/ast/read-text.ts +4 -1
- package/src/plugins/pi-agent-ide-ast/src/ast/selection.ts +3 -3
- package/src/plugins/pi-agent-ide-ast/src/doctor-plugin.ts +13 -10
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +17 -1
- package/src/plugins/pi-agent-ide-ast/src/outline-resolver.ts +32 -4
- package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +2 -2
- package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +1 -1
- package/src/plugins/pi-agent-ide-ast/src/search-presentation.ts +4 -3
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +100 -42
- package/src/plugins/pi-agent-ide-ast/src/select-presentation.ts +3 -2
- package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +2 -1
- package/src/plugins/pi-agent-ide-changes/index.ts +10 -2
- package/src/plugins/pi-agent-ide-changes/package.json +10 -11
- package/src/plugins/pi-agent-ide-changes/runtime/entry-34.js +1 -0
- package/src/plugins/pi-agent-ide-changes/src/change-anchor.ts +7 -2
- package/src/plugins/pi-agent-ide-changes/src/changes/change-service.ts +18 -1
- package/src/plugins/pi-agent-ide-changes/src/changes/change-types.ts +3 -0
- package/src/plugins/pi-agent-ide-changes/src/changes/git-changes-backend.ts +59 -7
- package/src/plugins/pi-agent-ide-changes/src/changes/git-paths.ts +49 -0
- package/src/plugins/pi-agent-ide-changes/src/current-change-presenter.ts +10 -2
- package/src/plugins/pi-agent-ide-changes/src/doctor-plugin.ts +13 -14
- package/src/plugins/pi-agent-ide-changes/src/last-text-transaction-store.ts +2 -1
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +47 -11
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +6 -1
- package/src/plugins/pi-agent-ide-debugger/index.ts +62 -25
- package/src/plugins/pi-agent-ide-debugger/src/adapter-executables.ts +3 -1
- package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +33 -0
- package/src/plugins/pi-agent-ide-debugger/src/doctor-plugin.ts +150 -171
- package/src/plugins/pi-agent-ide-debugger/src/process-provider.ts +2 -0
- package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +152 -58
- package/src/plugins/pi-agent-ide-debugger/src/workspace-owner.ts +28 -0
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +4 -1
- package/src/plugins/pi-agent-ide-formatter/index.ts +14 -2
- package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
- package/src/plugins/pi-agent-ide-formatter/src/doctor-plugin.ts +47 -35
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +41 -11
- package/src/plugins/pi-agent-ide-formatter/src/registry.ts +9 -28
- package/src/plugins/pi-agent-ide-languages/package.json +3 -3
- package/src/plugins/pi-agent-ide-lint/index.ts +35 -4
- package/src/plugins/pi-agent-ide-lint/package.json +8 -8
- package/src/plugins/pi-agent-ide-lint/runtime/entry-38.js +2 -0
- package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +14 -10
- package/src/plugins/pi-agent-ide-lint/src/doctor-plugin.ts +47 -39
- package/src/plugins/pi-agent-ide-lint/src/registry.ts +9 -25
- package/src/plugins/pi-agent-ide-lsp/index.ts +107 -25
- package/src/plugins/pi-agent-ide-lsp/package.json +10 -13
- package/src/plugins/pi-agent-ide-lsp/runtime/entry-39.js +2 -0
- package/src/plugins/pi-agent-ide-lsp/src/code-view-resolvers.ts +6 -2
- package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +5 -1
- package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +5 -3
- package/src/plugins/pi-agent-ide-lsp/src/doctor-plugin.ts +27 -11
- package/src/plugins/pi-agent-ide-lsp/src/lsp/abort.ts +62 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +245 -103
- package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +26 -45
- package/src/plugins/pi-agent-ide-lsp/src/lsp/diagnostic-adapters.ts +1 -1
- package/src/plugins/pi-agent-ide-lsp/src/lsp/document-uri.ts +40 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/file-watchers.ts +8 -1
- package/src/plugins/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +24 -17
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +255 -56
- package/src/plugins/pi-agent-ide-lsp/src/lsp/navigation.ts +51 -11
- package/src/plugins/pi-agent-ide-lsp/src/lsp/owner-transport.ts +67 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +149 -18
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +79 -31
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbols.ts +15 -12
- package/src/plugins/pi-agent-ide-lsp/src/lsp/workspace-owner.ts +16 -0
- package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +67 -46
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +50 -19
- package/src/plugins/pi-agent-ide-processes/src/registry.ts +8 -1
- package/src/plugins/pi-agent-ide-terminal/index.ts +7 -0
- package/src/plugins/pi-agent-ide-terminal/src/process-provider.ts +5 -1
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +5 -2
- package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +161 -42
- package/src/plugins/pi-agent-ide-terminal/src/shell-profile.ts +7 -0
- package/src/plugins/pi-agent-ide-terminal/src/shell-result.ts +11 -0
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +33 -8
- package/src/plugins/pi-agent-ide-terminal/src/types.ts +5 -0
- package/src/plugins/pi-agent-ide-vision/index.ts +170 -9
- package/src/plugins/pi-agent-ide-vision/src/doctor-plugin.ts +47 -0
- package/src/plugins/pi-agent-ide-vision/src/vision.ts +42 -1
- package/src/post-edit/gate.ts +4 -1
- package/src/tips/core.ts +5 -2
- package/src/tips/extension.ts +30 -2
- package/src/tips/persistence.ts +29 -27
- package/src/tips/setup-hint.ts +19 -0
- package/src/toolchain/types.ts +2 -0
- package/dist/chunk-3YK4XMWB.js +0 -0
- package/dist/chunk-5JELU6RV.js +0 -7
- package/dist/chunk-6U5OU77O.js +0 -3
- package/dist/chunk-7LD2OQH3.js +0 -14
- package/dist/chunk-BMOJTJJJ.js +0 -3
- package/dist/chunk-BYZSBXUK.js +0 -2
- package/dist/chunk-CEX73RI5.js +0 -28
- package/dist/chunk-DZWTKF2K.js +0 -1
- package/dist/chunk-EOKEQ3YH.js +0 -25
- package/dist/chunk-HZ5BNF3A.js +0 -1
- package/dist/chunk-IG56UGSO.js +0 -2
- package/dist/chunk-KVHDMIZS.js +0 -3
- package/dist/chunk-M5IVSCR2.js +0 -1
- package/dist/chunk-M5MJP7Z2.js +0 -1
- package/dist/chunk-MGCHOGQD.js +0 -1
- package/dist/chunk-N34ATN52.js +0 -1
- package/dist/chunk-NHKPP2AI.js +0 -28
- package/dist/chunk-NRZO5KJT.js +0 -9
- package/dist/chunk-OB46OPMZ.js +0 -1
- package/dist/chunk-Q6CZ6GBR.js +0 -3
- package/dist/chunk-QIK2E64R.js +0 -1
- package/dist/chunk-SBP3ABH4.js +0 -5
- package/dist/chunk-STBJO3Z3.js +0 -2
- package/dist/chunk-T6LX2RX5.js +0 -1
- package/dist/chunk-TXOTNK6B.js +0 -11
- package/dist/chunk-WZI4YC2O.js +0 -1
- package/dist/entry-19.js +0 -1
- package/docs/research/apply-native-capability-matrix.md +0 -174
- package/docs/research/apply-read-latency.md +0 -221
- package/docs/research/codemode-write-context.md +0 -56
- package/docs/research/lpt-393-fuzzy-results/file.json +0 -152
- package/docs/research/lpt-393-fuzzy-results/repo.json +0 -122
- package/docs/research/lpt-393-search-fuzzy-fallback.md +0 -97
- package/docs/research/native-codemode-batch-decision.md +0 -31
- package/docs/research/native-codemode-batching.md +0 -65
- package/node_modules/pi-agent-doctor/runtime/entry-19.js +0 -1
- package/node_modules/pi-agent-filesystem/runtime/entry-25.js +0 -2
- package/node_modules/pi-agent-filesystem-image/runtime/entry-26.js +0 -2
- package/node_modules/pi-agent-ide-ast/runtime/entry-30.js +0 -1
- package/node_modules/pi-agent-ide-formatter/runtime/entry-34.js +0 -2
- package/node_modules/pi-agent-image/runtime/entry-38.js +0 -1
- package/node_modules/pi-agent-invariant/runtime/entry-39.js +0 -1
- package/node_modules/pi-agent-search/runtime/entry-47.js +0 -1
- package/node_modules/pi-agent-search-text/runtime/entry-51.js +0 -2
- package/node_modules/pi-agent-search-text/runtime/entry-52.js +0 -1
- package/node_modules/pi-agent-text-anchor-constant/runtime/entry-56.js +0 -2
- package/node_modules/pi-agent-text-editor/runtime/entry-62.js +0 -1
- package/node_modules/pi-agent-text-editor-renderer/runtime/entry-78.js +0 -2
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-80.js +0 -1
- package/node_modules/pi-agent-tool-ui/runtime/entry-81.js +0 -1
- package/node_modules/pi-agent-web/runtime/entry-82.js +0 -2
- package/node_modules/pi-agent-web-html/runtime/entry-83.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-26.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-27.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-25.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-83.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-84.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-82.js +0 -2
- package/src/extensions/pi-agent-read/runtime/entry-41.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-42.js +0 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-51.js +0 -2
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-52.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-47.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-48.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-56.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-57.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-78.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-79.js +0 -2
- package/src/extensions/pi-agent-text-editor/runtime/entry-61.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-62.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-30.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-31.js +0 -2
- package/src/plugins/pi-agent-ide-formatter/runtime/entry-34.js +0 -2
- /package/node_modules/{pi-agent-documentation → pi-agent-doctor}/runtime/entry-24.js +0 -0
- /package/node_modules/{pi-agent-filesystem-jq → pi-agent-filesystem}/runtime/entry-27.js +0 -0
- /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-28.js +0 -0
- /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-jq}/runtime/entry-29.js +0 -0
- /package/node_modules/{pi-agent-ide-ast → pi-agent-filesystem-text}/runtime/entry-31.js +0 -0
- /package/node_modules/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-32.js +0 -0
- /package/node_modules/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-33.js +0 -0
- /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-changes}/runtime/entry-35.js +0 -0
- /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-formatter}/runtime/entry-36.js +0 -0
- /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-languages}/runtime/entry-37.js +0 -0
- /package/node_modules/{pi-agent-pdf → pi-agent-image}/runtime/entry-40.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-invariant}/runtime/entry-41.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-42.js +0 -0
- /package/node_modules/{pi-agent-resource → pi-agent-read}/runtime/entry-46.js +0 -0
- /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-48.js +0 -0
- /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-55.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-exact → pi-agent-text}/runtime/entry-57.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-exact → pi-agent-text-anchor-constant}/runtime/entry-58.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-59.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-60.js +0 -0
- /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-line-hash}/runtime/entry-61.js +0 -0
- /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor}/runtime/entry-79.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-web}/runtime/entry-84.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web-html}/runtime/entry-85.js +0 -0
- /package/node_modules/{pi-agent-web-text → pi-agent-web-image}/runtime/entry-86.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-28.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-jq}/runtime/entry-29.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-html}/runtime/entry-85.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-image}/runtime/entry-86.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-anchor-exact → pi-agent-text-anchor-constant}/runtime/entry-58.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-59.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-60.js +0 -0
- /package/src/plugins/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-32.js +0 -0
- /package/src/plugins/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-33.js +0 -0
- /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-changes}/runtime/entry-35.js +0 -0
- /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-formatter}/runtime/entry-36.js +0 -0
- /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-languages}/runtime/entry-37.js +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { stat } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import type { SearchEnvironment } from "pi-agent-search/api/search";
|
|
4
5
|
import { createInterface } from "node:readline";
|
|
5
6
|
|
|
6
7
|
import { resolveRipgrepExecutable } from "#src/ripgrep.js";
|
|
@@ -44,6 +45,7 @@ export async function searchText(
|
|
|
44
45
|
cwd: string,
|
|
45
46
|
signal?: AbortSignal,
|
|
46
47
|
budget?: SearchCaptureBudget,
|
|
48
|
+
environment?: SearchEnvironment,
|
|
47
49
|
): Promise<TextSearchBackendResult> {
|
|
48
50
|
if (request.query.length === 0) {
|
|
49
51
|
throw new Error("Search query must not be empty.");
|
|
@@ -53,17 +55,34 @@ export async function searchText(
|
|
|
53
55
|
throw new Error("Search supports one-line patterns only.");
|
|
54
56
|
}
|
|
55
57
|
|
|
56
|
-
if (request.condition !== undefined)
|
|
57
|
-
|
|
58
|
+
if (request.condition !== undefined)
|
|
59
|
+
return searchBoolean(
|
|
60
|
+
request,
|
|
61
|
+
(pattern, onLine) => searchPattern(pattern, cwd, signal, onLine, undefined, environment),
|
|
62
|
+
signal,
|
|
63
|
+
);
|
|
64
|
+
return searchPattern(request, cwd, signal, undefined, budget, environment);
|
|
58
65
|
}
|
|
59
66
|
|
|
60
67
|
/** Reuse ordinary text-search scope, ignores, and glob parsing for the extra scan. */
|
|
61
|
-
export async function ripgrepScope(
|
|
62
|
-
|
|
63
|
-
|
|
68
|
+
export async function ripgrepScope(
|
|
69
|
+
request: TextSearchRequest,
|
|
70
|
+
cwd: string,
|
|
71
|
+
environment?: SearchEnvironment,
|
|
72
|
+
signal?: AbortSignal,
|
|
73
|
+
) {
|
|
74
|
+
if (environment === undefined && (request.path?.includes("://") || cwd.includes("://")))
|
|
75
|
+
throw new Error("No search environment owns this scope.");
|
|
76
|
+
const target =
|
|
77
|
+
environment?.resolve(cwd, stripFilePrefix(request.path ?? ".")) ??
|
|
78
|
+
path.resolve(cwd, stripFilePrefix(request.path ?? "."));
|
|
79
|
+
const directory =
|
|
80
|
+
environment === undefined
|
|
81
|
+
? (await stat(target)).isDirectory()
|
|
82
|
+
: await environment.isDirectory(target, signal);
|
|
64
83
|
return {
|
|
65
|
-
cwd: directory ? target : path.dirname(target),
|
|
66
|
-
target: directory ? "." : path.basename(target)
|
|
84
|
+
cwd: directory ? target : (environment?.dirname(target) ?? path.dirname(target)),
|
|
85
|
+
target: directory ? "." : `./${environment?.basename(target) ?? path.basename(target)}`,
|
|
67
86
|
arguments: [
|
|
68
87
|
"--no-config",
|
|
69
88
|
"--no-ignore-parent",
|
|
@@ -88,7 +107,15 @@ export async function searchTextContent(
|
|
|
88
107
|
signal?: AbortSignal,
|
|
89
108
|
): Promise<TextSearchBackendResult> {
|
|
90
109
|
if (request.condition !== undefined)
|
|
91
|
-
|
|
110
|
+
return searchBoolean(
|
|
111
|
+
request,
|
|
112
|
+
async (pattern, onLine) => {
|
|
113
|
+
const result = await searchTextContent(pattern, content, cwd, signal);
|
|
114
|
+
for (const match of result.matches) onLine?.(match.source, match.lineNumber);
|
|
115
|
+
return result;
|
|
116
|
+
},
|
|
117
|
+
signal,
|
|
118
|
+
);
|
|
92
119
|
if (/\r|\n/u.test(request.query)) throw new Error("Search supports one-line patterns only.");
|
|
93
120
|
const result = await runRipgrep(
|
|
94
121
|
[
|
|
@@ -127,8 +154,9 @@ async function searchPattern(
|
|
|
127
154
|
signal?: AbortSignal,
|
|
128
155
|
onLine?: MatchingLine,
|
|
129
156
|
budget?: SearchCaptureBudget,
|
|
157
|
+
environment?: SearchEnvironment,
|
|
130
158
|
): Promise<TextSearchBackendResult> {
|
|
131
|
-
const scope = await ripgrepScope(request, cwd);
|
|
159
|
+
const scope = await ripgrepScope(request, cwd, environment, signal);
|
|
132
160
|
const searchCwd = scope.cwd;
|
|
133
161
|
const commonArguments = [
|
|
134
162
|
"--json",
|
|
@@ -143,7 +171,15 @@ async function searchPattern(
|
|
|
143
171
|
];
|
|
144
172
|
|
|
145
173
|
if (request.regex !== true) {
|
|
146
|
-
return runRipgrep(
|
|
174
|
+
return runRipgrep(
|
|
175
|
+
["--fixed-strings", ...commonArguments],
|
|
176
|
+
searchCwd,
|
|
177
|
+
signal,
|
|
178
|
+
onLine,
|
|
179
|
+
budget,
|
|
180
|
+
undefined,
|
|
181
|
+
environment,
|
|
182
|
+
);
|
|
147
183
|
}
|
|
148
184
|
|
|
149
185
|
try {
|
|
@@ -153,6 +189,8 @@ async function searchPattern(
|
|
|
153
189
|
signal,
|
|
154
190
|
onLine,
|
|
155
191
|
budget,
|
|
192
|
+
undefined,
|
|
193
|
+
environment,
|
|
156
194
|
);
|
|
157
195
|
} catch (error) {
|
|
158
196
|
if (!isPcre2MatchLimitError(error)) {
|
|
@@ -174,6 +212,8 @@ async function searchPattern(
|
|
|
174
212
|
signal,
|
|
175
213
|
onLine,
|
|
176
214
|
budget,
|
|
215
|
+
undefined,
|
|
216
|
+
environment,
|
|
177
217
|
);
|
|
178
218
|
} catch (fallbackError) {
|
|
179
219
|
if (signal?.aborted) throw fallbackError;
|
|
@@ -188,7 +228,7 @@ async function searchPattern(
|
|
|
188
228
|
|
|
189
229
|
async function searchBoolean(
|
|
190
230
|
request: TextSearchRequest,
|
|
191
|
-
|
|
231
|
+
search: (pattern: TextSearchRequest, onLine?: MatchingLine) => Promise<TextSearchBackendResult>,
|
|
192
232
|
signal?: AbortSignal,
|
|
193
233
|
): Promise<TextSearchBackendResult> {
|
|
194
234
|
const condition = request.condition;
|
|
@@ -210,15 +250,13 @@ async function searchBoolean(
|
|
|
210
250
|
for (const pattern of patterns) {
|
|
211
251
|
signal?.throwIfAborted();
|
|
212
252
|
const lines = new Set<string>();
|
|
213
|
-
await
|
|
253
|
+
await search(
|
|
214
254
|
{ ...scope, query: pattern, regex: true, wholeWord: false },
|
|
215
|
-
cwd,
|
|
216
|
-
signal,
|
|
217
255
|
(source, lineNumber) => lines.add(JSON.stringify([source, lineNumber])),
|
|
218
256
|
);
|
|
219
257
|
present.set(pattern, lines);
|
|
220
258
|
}
|
|
221
|
-
const result = await
|
|
259
|
+
const result = await search(scope);
|
|
222
260
|
const selected = new Set<string>();
|
|
223
261
|
const matches = result.matches.filter((match) => {
|
|
224
262
|
const key = lineKey(match);
|
|
@@ -239,7 +277,10 @@ function runRipgrep(
|
|
|
239
277
|
onLine?: MatchingLine,
|
|
240
278
|
budget?: SearchCaptureBudget,
|
|
241
279
|
input?: string,
|
|
280
|
+
environment?: SearchEnvironment,
|
|
242
281
|
): Promise<TextSearchBackendResult> {
|
|
282
|
+
if (environment !== undefined)
|
|
283
|
+
return runOwnedRipgrep(arguments_, cwd, environment, signal, onLine, budget);
|
|
243
284
|
return new Promise((resolve, reject) => {
|
|
244
285
|
const child = spawn(resolveRipgrepExecutable(), arguments_, {
|
|
245
286
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -344,13 +385,78 @@ function runRipgrep(
|
|
|
344
385
|
});
|
|
345
386
|
}
|
|
346
387
|
|
|
388
|
+
async function runOwnedRipgrep(
|
|
389
|
+
arguments_: readonly string[],
|
|
390
|
+
cwd: string,
|
|
391
|
+
environment: SearchEnvironment,
|
|
392
|
+
signal?: AbortSignal,
|
|
393
|
+
onLine?: MatchingLine,
|
|
394
|
+
budget?: SearchCaptureBudget,
|
|
395
|
+
): Promise<TextSearchBackendResult> {
|
|
396
|
+
const matches: TextSearchMatch[] = [];
|
|
397
|
+
const controller = new AbortController();
|
|
398
|
+
const abort = () => controller.abort(signal?.reason);
|
|
399
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
400
|
+
if (signal?.aborted) abort();
|
|
401
|
+
let bytes = 0;
|
|
402
|
+
const state = { limited: false };
|
|
403
|
+
try {
|
|
404
|
+
const result = await environment.runLines(
|
|
405
|
+
arguments_,
|
|
406
|
+
cwd,
|
|
407
|
+
(line) => {
|
|
408
|
+
if (state.limited || !line.length) return;
|
|
409
|
+
bytes += Buffer.byteLength(line) + 1;
|
|
410
|
+
if (budget !== undefined && bytes > budget.bytes) {
|
|
411
|
+
state.limited = true;
|
|
412
|
+
controller.abort();
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
const event = JSON.parse(line) as
|
|
416
|
+
| RipgrepMatchEvent
|
|
417
|
+
| { type: "begin" | "end" | "summary"; data: never };
|
|
418
|
+
if (event.type !== "match") return;
|
|
419
|
+
if (onLine !== undefined) {
|
|
420
|
+
const source = event.data.path.text;
|
|
421
|
+
if (source !== undefined && Number.isSafeInteger(event.data.line_number))
|
|
422
|
+
onLine(environment.resolve(cwd, source), event.data.line_number);
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
for (const match of matchesFromEvent(event, cwd, environment)) {
|
|
426
|
+
if (budget !== undefined && matches.length >= budget.matches) {
|
|
427
|
+
state.limited = true;
|
|
428
|
+
controller.abort();
|
|
429
|
+
break;
|
|
430
|
+
}
|
|
431
|
+
matches.push(match);
|
|
432
|
+
}
|
|
433
|
+
},
|
|
434
|
+
controller.signal,
|
|
435
|
+
);
|
|
436
|
+
if (result.code !== 0 && result.code !== 1)
|
|
437
|
+
throw new Error(result.stderr.trim() || "Ripgrep failed.");
|
|
438
|
+
} catch (error) {
|
|
439
|
+
signal?.throwIfAborted();
|
|
440
|
+
if (!state.limited) throw error;
|
|
441
|
+
} finally {
|
|
442
|
+
signal?.removeEventListener("abort", abort);
|
|
443
|
+
}
|
|
444
|
+
signal?.throwIfAborted();
|
|
445
|
+
matches.sort(compareMatches);
|
|
446
|
+
return { matches, complete: !state.limited };
|
|
447
|
+
}
|
|
448
|
+
|
|
347
449
|
function isPcre2MatchLimitError(error: unknown): boolean {
|
|
348
450
|
return (
|
|
349
451
|
error instanceof Error && /PCRE2: error matching: match limit exceeded/iu.test(error.message)
|
|
350
452
|
);
|
|
351
453
|
}
|
|
352
454
|
|
|
353
|
-
function matchesFromEvent(
|
|
455
|
+
function matchesFromEvent(
|
|
456
|
+
event: RipgrepMatchEvent,
|
|
457
|
+
cwd: string,
|
|
458
|
+
environment?: SearchEnvironment,
|
|
459
|
+
): TextSearchMatch[] {
|
|
354
460
|
const source = event.data.path.text;
|
|
355
461
|
const rawLine = event.data.lines.text;
|
|
356
462
|
|
|
@@ -374,7 +480,7 @@ function matchesFromEvent(event: RipgrepMatchEvent, cwd: string): TextSearchMatc
|
|
|
374
480
|
const startColumn = lineBuffer.subarray(0, submatch.start).toString("utf8").length;
|
|
375
481
|
const endColumn = lineBuffer.subarray(0, submatch.end).toString("utf8").length;
|
|
376
482
|
matches.push({
|
|
377
|
-
source: path.resolve(cwd, source),
|
|
483
|
+
source: environment?.resolve(cwd, source) ?? path.resolve(cwd, source),
|
|
378
484
|
lineNumber: event.data.line_number,
|
|
379
485
|
startColumn,
|
|
380
486
|
endColumn,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SearchEnvironment } from "pi-agent-search/api/search";
|
|
1
2
|
import {
|
|
2
3
|
searchText,
|
|
3
4
|
type TextSearchRequest,
|
|
@@ -46,11 +47,12 @@ export async function runSearchRecipe(
|
|
|
46
47
|
recipe: SearchRecipe,
|
|
47
48
|
cwd: string,
|
|
48
49
|
signal?: AbortSignal,
|
|
50
|
+
environment?: SearchEnvironment,
|
|
49
51
|
): Promise<
|
|
50
52
|
TextSearchBackendResult & { readonly query: string; readonly notices: readonly string[] }
|
|
51
53
|
> {
|
|
52
54
|
let query = recipe.query;
|
|
53
|
-
let result = await searchText(recipe, cwd, signal);
|
|
55
|
+
let result = await searchText(recipe, cwd, signal, undefined, environment);
|
|
54
56
|
const notices: string[] = [];
|
|
55
57
|
for (const fallback of recipe.fallbacks ?? []) {
|
|
56
58
|
if (result.matches.length > 0 || !result.complete) break;
|
|
@@ -60,6 +62,8 @@ export async function runSearchRecipe(
|
|
|
60
62
|
{ ...recipe, query: fallback.query, regex: true, condition: fallback.condition },
|
|
61
63
|
cwd,
|
|
62
64
|
signal,
|
|
65
|
+
undefined,
|
|
66
|
+
environment,
|
|
63
67
|
);
|
|
64
68
|
result = next;
|
|
65
69
|
query = fallback.query;
|
|
@@ -298,6 +298,7 @@ function isCount(value: unknown): value is number {
|
|
|
298
298
|
}
|
|
299
299
|
|
|
300
300
|
function displaySource(source: string, cwd: string): string {
|
|
301
|
+
if (source.includes("://")) return source;
|
|
301
302
|
const relative = path.relative(cwd, source);
|
|
302
303
|
// oxlint-disable-next-line repo/no-parent-paths -- defensive check against traversal, not a traversal
|
|
303
304
|
return relative.length > 0 && !relative.startsWith("..") && !path.isAbsolute(relative)
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { requiredValue } from "pi-agent-invariant";
|
|
2
|
-
import type { ResultTargetStore } from "pi-agent-resource";
|
|
3
|
-
import type {
|
|
2
|
+
import type { ResultTargetStore, ResolvedResultTargets } from "pi-agent-resource";
|
|
3
|
+
import type {
|
|
4
|
+
SearchSelectionMatch,
|
|
5
|
+
SearchSelectionRegistration,
|
|
6
|
+
SearchContext,
|
|
7
|
+
} from "pi-agent-search/api/search";
|
|
4
8
|
import { createHash } from "node:crypto";
|
|
5
9
|
import { open, readFile } from "node:fs/promises";
|
|
6
10
|
import path from "node:path";
|
|
11
|
+
import type { SearchEnvironment } from "pi-agent-search/api/search";
|
|
7
12
|
|
|
8
13
|
import {
|
|
9
14
|
createTextDocument,
|
|
@@ -27,11 +32,12 @@ export type TextSearchMatch = SearchSelectionMatch;
|
|
|
27
32
|
|
|
28
33
|
export interface TextSearchSession {
|
|
29
34
|
readonly id: string;
|
|
30
|
-
readonly target?: string;
|
|
31
|
-
readonly matchTargets?: readonly string[];
|
|
32
35
|
readonly query: string;
|
|
33
36
|
readonly matches: readonly TextSearchMatch[];
|
|
34
37
|
readonly complete: boolean;
|
|
38
|
+
/** Strict source handles stay separate from legacy refreshing SEARCH references. */
|
|
39
|
+
readonly target?: string;
|
|
40
|
+
readonly matchTargets?: readonly string[];
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
interface SearchSnapshot {
|
|
@@ -40,7 +46,11 @@ interface SearchSnapshot {
|
|
|
40
46
|
readonly contentBySource: ReadonlyMap<string, string>;
|
|
41
47
|
}
|
|
42
48
|
|
|
49
|
+
type SnapshotReader = (source: string, signal?: AbortSignal) => Promise<string>;
|
|
50
|
+
|
|
43
51
|
interface StoredSearchSession extends TextSearchSession, SearchSnapshot {
|
|
52
|
+
readonly read?: SnapshotReader;
|
|
53
|
+
readonly environment?: SearchEnvironment;
|
|
44
54
|
readonly refresh?: SearchSelectionRegistration["refresh"];
|
|
45
55
|
readonly recipe: SearchRecipe;
|
|
46
56
|
readonly snapshotByteBudget?: number;
|
|
@@ -77,11 +87,13 @@ export function createSearchSessionIdentity(
|
|
|
77
87
|
const root =
|
|
78
88
|
cwd === undefined
|
|
79
89
|
? commonSourceDirectory(matches.map((match) => match.source))
|
|
80
|
-
:
|
|
90
|
+
: canonicalSource(cwd);
|
|
81
91
|
const identity = matches
|
|
82
92
|
.map((match) => ({
|
|
83
93
|
match,
|
|
84
|
-
source:
|
|
94
|
+
source: match.source.includes("://")
|
|
95
|
+
? canonicalSource(match.source)
|
|
96
|
+
: path.relative(root, path.resolve(match.source)),
|
|
85
97
|
}))
|
|
86
98
|
.sort(
|
|
87
99
|
(left, right) =>
|
|
@@ -126,7 +138,7 @@ export function allocateSearchSessionId(
|
|
|
126
138
|
function normalizeRecipe(recipe: SearchRecipe, cwd: string): Record<string, unknown> {
|
|
127
139
|
return {
|
|
128
140
|
query: recipe.query,
|
|
129
|
-
path:
|
|
141
|
+
path: resolveScope(cwd, recipe.path ?? "."),
|
|
130
142
|
include: recipe.include ?? "",
|
|
131
143
|
exclude: recipe.exclude ?? "",
|
|
132
144
|
caseSensitive: recipe.caseSensitive === true,
|
|
@@ -154,6 +166,11 @@ export class SearchSessionStore {
|
|
|
154
166
|
public constructor(
|
|
155
167
|
private readonly createIdentity: typeof createSearchSessionIdentity = createSearchSessionIdentity,
|
|
156
168
|
private readonly resultTargets?: ResultTargetStore,
|
|
169
|
+
private readonly readSource?: (
|
|
170
|
+
source: string,
|
|
171
|
+
cwd: string,
|
|
172
|
+
signal?: AbortSignal,
|
|
173
|
+
) => Promise<string>,
|
|
157
174
|
) {}
|
|
158
175
|
|
|
159
176
|
/** Capture current files; an optional byte budget also bounds reads if a file grows during capture. */
|
|
@@ -169,11 +186,21 @@ export class SearchSessionStore {
|
|
|
169
186
|
},
|
|
170
187
|
refresh?: SearchSelectionRegistration["refresh"],
|
|
171
188
|
snapshotByteBudget?: number,
|
|
189
|
+
environment?: SearchEnvironment,
|
|
172
190
|
): Promise<TextSearchSession> {
|
|
173
191
|
const matches = sourceMatches
|
|
174
|
-
.map((match) => ({ ...match, source:
|
|
192
|
+
.map((match) => ({ ...match, source: canonicalSource(match.source) }))
|
|
175
193
|
.sort(compareMatches);
|
|
176
|
-
const
|
|
194
|
+
const readSource = this.readSource;
|
|
195
|
+
const read: SnapshotReader | undefined =
|
|
196
|
+
readSource === undefined ? undefined : (source, abort) => readSource(source, cwd, abort);
|
|
197
|
+
const contentBySource = await snapshotContents(
|
|
198
|
+
matches,
|
|
199
|
+
signal,
|
|
200
|
+
snapshotByteBudget,
|
|
201
|
+
environment,
|
|
202
|
+
read,
|
|
203
|
+
);
|
|
177
204
|
const identity = this.createIdentity(query, matches, cwd, recipe);
|
|
178
205
|
const knownId = this.#idsByIdentity.get(identity);
|
|
179
206
|
const id = knownId ?? allocateSearchSessionId(identity, new Set<string>(this.#sessions.keys()));
|
|
@@ -183,11 +210,21 @@ export class SearchSessionStore {
|
|
|
183
210
|
matches,
|
|
184
211
|
complete,
|
|
185
212
|
contentBySource,
|
|
186
|
-
|
|
213
|
+
read,
|
|
214
|
+
...registerResultReferences(
|
|
215
|
+
this.resultTargets,
|
|
216
|
+
id,
|
|
217
|
+
matches,
|
|
218
|
+
contentBySource,
|
|
219
|
+
cwd,
|
|
220
|
+
complete,
|
|
221
|
+
(source, abort) => readOwnedText(source, abort, environment, read),
|
|
222
|
+
),
|
|
187
223
|
...(snapshotByteBudget === undefined ? {} : { snapshotByteBudget }),
|
|
188
224
|
recipe,
|
|
225
|
+
environment,
|
|
189
226
|
...(refresh !== undefined && { refresh }),
|
|
190
|
-
cwd:
|
|
227
|
+
cwd: canonicalSource(cwd),
|
|
191
228
|
};
|
|
192
229
|
this.#idsByIdentity.set(identity, id);
|
|
193
230
|
this.#sessions.set(id, session);
|
|
@@ -204,6 +241,7 @@ export class SearchSessionStore {
|
|
|
204
241
|
recipe?: SearchRecipe,
|
|
205
242
|
refresh?: SearchSelectionRegistration["refresh"],
|
|
206
243
|
snapshotByteBudget?: number,
|
|
244
|
+
environment?: SearchEnvironment,
|
|
207
245
|
): Promise<TextSearchSession | undefined> {
|
|
208
246
|
try {
|
|
209
247
|
return await this.register(
|
|
@@ -215,6 +253,7 @@ export class SearchSessionStore {
|
|
|
215
253
|
recipe,
|
|
216
254
|
refresh,
|
|
217
255
|
snapshotByteBudget,
|
|
256
|
+
environment,
|
|
218
257
|
);
|
|
219
258
|
} catch (error) {
|
|
220
259
|
if (error instanceof SearchSnapshotChangedError) return undefined;
|
|
@@ -255,7 +294,7 @@ export class SearchSessionStore {
|
|
|
255
294
|
try {
|
|
256
295
|
const result =
|
|
257
296
|
session.refresh === undefined
|
|
258
|
-
? await runSearchRecipe(session.recipe, session.cwd, signal)
|
|
297
|
+
? await runSearchRecipe(session.recipe, session.cwd, signal, session.environment)
|
|
259
298
|
: await session.refresh(signal);
|
|
260
299
|
observations.push({
|
|
261
300
|
...base,
|
|
@@ -300,6 +339,42 @@ export class SearchSessionStore {
|
|
|
300
339
|
};
|
|
301
340
|
}
|
|
302
341
|
|
|
342
|
+
/** Resolve Search input with the same numbered-snapshot and all-query refresh authority as edits. */
|
|
343
|
+
public async resolveSearchScope(
|
|
344
|
+
value: string,
|
|
345
|
+
context: SearchContext,
|
|
346
|
+
): Promise<ResolvedResultTargets | undefined> {
|
|
347
|
+
if (!value.startsWith("SEARCH#")) return undefined;
|
|
348
|
+
const result = await this.#resolveResources(value, context.cwd, context.signal, true);
|
|
349
|
+
if (result.kind !== "resolved")
|
|
350
|
+
throw new Error(
|
|
351
|
+
result.kind === "rejected" ? result.rejection.reason : "Invalid Search reference.",
|
|
352
|
+
);
|
|
353
|
+
const parsed = requiredValue(parseSearchAnchor(value));
|
|
354
|
+
const session = requiredValue(this.#sessions.get(parsed.id));
|
|
355
|
+
return {
|
|
356
|
+
complete: true,
|
|
357
|
+
targets: result.targets.map((target) => {
|
|
358
|
+
if (target.expectedContent === undefined)
|
|
359
|
+
throw new Error("Search snapshot is unavailable.");
|
|
360
|
+
return {
|
|
361
|
+
source: target.source,
|
|
362
|
+
expectedContent: target.expectedContent,
|
|
363
|
+
ranges: target.ranges ?? [],
|
|
364
|
+
readCurrent: async (signal?: AbortSignal) => {
|
|
365
|
+
const current = await readCurrent(
|
|
366
|
+
target.source,
|
|
367
|
+
signal,
|
|
368
|
+
session.environment,
|
|
369
|
+
session.read,
|
|
370
|
+
);
|
|
371
|
+
if (current === undefined) throw new Error("Search source is unavailable.");
|
|
372
|
+
return current;
|
|
373
|
+
},
|
|
374
|
+
};
|
|
375
|
+
}),
|
|
376
|
+
};
|
|
377
|
+
}
|
|
303
378
|
public resourceResolver(): TextAnchorResourceResolver {
|
|
304
379
|
return {
|
|
305
380
|
id: "search-targets",
|
|
@@ -317,7 +392,7 @@ export class SearchSessionStore {
|
|
|
317
392
|
let session = this.#sessions.get(parsed.id);
|
|
318
393
|
if (session === undefined) return staleAnchor();
|
|
319
394
|
if (parsed.selector === "all" && !session.complete) return missingCompleteAnchor();
|
|
320
|
-
const source =
|
|
395
|
+
const source = canonicalSource(contextSource);
|
|
321
396
|
let snapshot: SearchSnapshot = session;
|
|
322
397
|
if (parsed.selector === "all") {
|
|
323
398
|
if (session.refreshedComplete?.complete === true) {
|
|
@@ -335,7 +410,7 @@ export class SearchSessionStore {
|
|
|
335
410
|
rejection: { code: "missing", reason: "search anchor does not select this resource" },
|
|
336
411
|
};
|
|
337
412
|
}
|
|
338
|
-
const current = await readCurrent(source, signal);
|
|
413
|
+
const current = await readCurrent(source, signal, session.environment, session.read);
|
|
339
414
|
if (current === undefined) return staleAnchor(requiredValue(sourceMatches[0]).lineNumber);
|
|
340
415
|
if (parsed.selector === "all" && current !== snapshot.contentBySource.get(source)) {
|
|
341
416
|
snapshot = await this.#refresh(session, signal);
|
|
@@ -362,27 +437,32 @@ export class SearchSessionStore {
|
|
|
362
437
|
};
|
|
363
438
|
}
|
|
364
439
|
|
|
365
|
-
async #resolveResources(
|
|
440
|
+
async #resolveResources(
|
|
441
|
+
value: string,
|
|
442
|
+
cwd: string,
|
|
443
|
+
signal?: AbortSignal,
|
|
444
|
+
allowEmpty = false,
|
|
445
|
+
): Promise<TextTargetResolutionAttempt> {
|
|
366
446
|
const parsed = parseSearchAnchor(value);
|
|
367
447
|
if (parsed === undefined) return { kind: "not-handled" };
|
|
368
448
|
const session = this.#sessions.get(parsed.id);
|
|
369
|
-
if (session === undefined) return staleAnchor();
|
|
449
|
+
if (session === undefined || session.cwd !== canonicalSource(cwd)) return staleAnchor();
|
|
370
450
|
if (parsed.selector === "all" && !session.complete) return missingCompleteAnchor();
|
|
371
451
|
let snapshot: SearchSnapshot = session;
|
|
372
452
|
if (parsed.selector === "all") {
|
|
373
453
|
if (session.refreshedComplete?.complete === true) {
|
|
374
454
|
snapshot = session.refreshedComplete;
|
|
375
455
|
} else if (session.refreshedComplete !== undefined) {
|
|
376
|
-
snapshot = await this.#refresh(session);
|
|
456
|
+
snapshot = await this.#refresh(session, signal);
|
|
377
457
|
if (!snapshot.complete) return missingCompleteAnchor();
|
|
378
458
|
}
|
|
379
459
|
const sources = new Set(
|
|
380
460
|
selectMatches(snapshot, parsed.selector, parsed.mode).map((match) => match.source),
|
|
381
461
|
);
|
|
382
462
|
for (const source of sources) {
|
|
383
|
-
const current = await readCurrent(source);
|
|
463
|
+
const current = await readCurrent(source, signal, session.environment, session.read);
|
|
384
464
|
if (current !== snapshot.contentBySource.get(source)) {
|
|
385
|
-
snapshot = await this.#refresh(session);
|
|
465
|
+
snapshot = await this.#refresh(session, signal);
|
|
386
466
|
if (!snapshot.complete) return missingCompleteAnchor();
|
|
387
467
|
break;
|
|
388
468
|
}
|
|
@@ -393,7 +473,8 @@ export class SearchSessionStore {
|
|
|
393
473
|
const source = selected[0]?.source;
|
|
394
474
|
if (
|
|
395
475
|
source !== undefined &&
|
|
396
|
-
(await readCurrent(source
|
|
476
|
+
(await readCurrent(source, signal, session.environment, session.read)) !==
|
|
477
|
+
snapshot.contentBySource.get(source)
|
|
397
478
|
) {
|
|
398
479
|
return staleAnchor(selected[0]?.lineNumber);
|
|
399
480
|
}
|
|
@@ -418,7 +499,7 @@ export class SearchSessionStore {
|
|
|
418
499
|
ranges,
|
|
419
500
|
expectedContent: snapshot.contentBySource.get(source),
|
|
420
501
|
}));
|
|
421
|
-
return targets.length === 0
|
|
502
|
+
return targets.length === 0 && !(allowEmpty && parsed.selector === "all")
|
|
422
503
|
? { kind: "rejected", rejection: { code: "missing", reason: "search anchor has no matches" } }
|
|
423
504
|
: { kind: "resolved", targets };
|
|
424
505
|
}
|
|
@@ -426,15 +507,21 @@ export class SearchSessionStore {
|
|
|
426
507
|
async #refresh(session: StoredSearchSession, signal?: AbortSignal): Promise<SearchSnapshot> {
|
|
427
508
|
const result =
|
|
428
509
|
session.refresh === undefined
|
|
429
|
-
? await runSearchRecipe(session.recipe, session.cwd, signal)
|
|
510
|
+
? await runSearchRecipe(session.recipe, session.cwd, signal, session.environment)
|
|
430
511
|
: await session.refresh(signal);
|
|
431
512
|
const matches = result.matches
|
|
432
|
-
.map((match) => ({ ...match, source:
|
|
513
|
+
.map((match) => ({ ...match, source: canonicalSource(match.source) }))
|
|
433
514
|
.sort(compareMatches);
|
|
434
515
|
const refreshed: SearchSnapshot = {
|
|
435
516
|
matches,
|
|
436
517
|
complete: result.complete,
|
|
437
|
-
contentBySource: await snapshotContents(
|
|
518
|
+
contentBySource: await snapshotContents(
|
|
519
|
+
matches,
|
|
520
|
+
signal,
|
|
521
|
+
session.snapshotByteBudget,
|
|
522
|
+
session.environment,
|
|
523
|
+
session.read,
|
|
524
|
+
),
|
|
438
525
|
};
|
|
439
526
|
this.#sessions.set(session.id, { ...session, refreshedComplete: refreshed });
|
|
440
527
|
return refreshed;
|
|
@@ -443,10 +530,12 @@ export class SearchSessionStore {
|
|
|
443
530
|
|
|
444
531
|
function registerResultReferences(
|
|
445
532
|
store: ResultTargetStore | undefined,
|
|
533
|
+
sessionId: string,
|
|
446
534
|
matches: readonly TextSearchMatch[],
|
|
447
535
|
contents: ReadonlyMap<string, string>,
|
|
448
536
|
cwd: string,
|
|
449
537
|
complete: boolean,
|
|
538
|
+
read: SnapshotReader,
|
|
450
539
|
): Pick<TextSearchSession, "target" | "matchTargets"> {
|
|
451
540
|
if (store === undefined) return {};
|
|
452
541
|
const documents = new Map(
|
|
@@ -456,7 +545,20 @@ function registerResultReferences(
|
|
|
456
545
|
source: match.source,
|
|
457
546
|
expectedContent: requiredValue(contents.get(match.source)),
|
|
458
547
|
ranges: [selectionRange(requiredValue(documents.get(match.source)), match, "match")],
|
|
548
|
+
readCurrent: (signal?: AbortSignal) => read(match.source, signal),
|
|
459
549
|
}));
|
|
550
|
+
for (const [index, match] of matches.slice(0, 100).entries()) {
|
|
551
|
+
const lineTarget = store.register(
|
|
552
|
+
[
|
|
553
|
+
{
|
|
554
|
+
...requiredValue(targets[index]),
|
|
555
|
+
ranges: [selectionRange(requiredValue(documents.get(match.source)), match, "line")],
|
|
556
|
+
},
|
|
557
|
+
],
|
|
558
|
+
cwd,
|
|
559
|
+
);
|
|
560
|
+
store.registerSearchReference(`SEARCH#${sessionId}:${index + 1}:line`, lineTarget, cwd);
|
|
561
|
+
}
|
|
460
562
|
return {
|
|
461
563
|
target: store.register(targets, cwd, complete),
|
|
462
564
|
matchTargets: targets.slice(0, 100).map((target) => store.register([target], cwd, complete)),
|
|
@@ -563,13 +665,15 @@ async function snapshotContents(
|
|
|
563
665
|
matches: readonly TextSearchMatch[],
|
|
564
666
|
signal?: AbortSignal,
|
|
565
667
|
byteBudget?: number,
|
|
668
|
+
environment?: SearchEnvironment,
|
|
669
|
+
read?: SnapshotReader,
|
|
566
670
|
): Promise<ReadonlyMap<string, string>> {
|
|
567
671
|
const sources = [...new Set(matches.map((match) => match.source))];
|
|
568
672
|
if (byteBudget !== undefined) {
|
|
569
673
|
const contents = new Map<string, string>();
|
|
570
674
|
let remaining = byteBudget;
|
|
571
675
|
for (const source of sources) {
|
|
572
|
-
const content = await readBoundedSnapshot(source, remaining, signal);
|
|
676
|
+
const content = await readBoundedSnapshot(source, remaining, signal, environment, read);
|
|
573
677
|
remaining -= Buffer.byteLength(content);
|
|
574
678
|
validateSnapshot(source, content, matches);
|
|
575
679
|
contents.set(source, content);
|
|
@@ -578,10 +682,7 @@ async function snapshotContents(
|
|
|
578
682
|
}
|
|
579
683
|
const snapshots = await Promise.allSettled(
|
|
580
684
|
sources.map(async (source) => {
|
|
581
|
-
const content = await
|
|
582
|
-
encoding: "utf8",
|
|
583
|
-
...(signal !== undefined && { signal }),
|
|
584
|
-
});
|
|
685
|
+
const content = await readOwnedText(source, signal, environment, read);
|
|
585
686
|
validateSnapshot(source, content, matches);
|
|
586
687
|
return [source, content] as const;
|
|
587
688
|
}),
|
|
@@ -610,8 +711,16 @@ async function readBoundedSnapshot(
|
|
|
610
711
|
source: string,
|
|
611
712
|
budget: number,
|
|
612
713
|
signal?: AbortSignal,
|
|
714
|
+
environment?: SearchEnvironment,
|
|
715
|
+
read?: SnapshotReader,
|
|
613
716
|
): Promise<string> {
|
|
614
717
|
signal?.throwIfAborted();
|
|
718
|
+
if (source.includes("://")) {
|
|
719
|
+
const content = await readOwnedText(source, signal, environment, read);
|
|
720
|
+
if (Buffer.byteLength(content) > budget)
|
|
721
|
+
throw new Error("Candidate snapshot byte budget reached.");
|
|
722
|
+
return content;
|
|
723
|
+
}
|
|
615
724
|
const file = await open(source, "r");
|
|
616
725
|
try {
|
|
617
726
|
const info = await file.stat();
|
|
@@ -633,14 +742,40 @@ async function readBoundedSnapshot(
|
|
|
633
742
|
await file.close();
|
|
634
743
|
}
|
|
635
744
|
}
|
|
636
|
-
async function readCurrent(
|
|
745
|
+
async function readCurrent(
|
|
746
|
+
source: string,
|
|
747
|
+
signal?: AbortSignal,
|
|
748
|
+
environment?: SearchEnvironment,
|
|
749
|
+
read?: SnapshotReader,
|
|
750
|
+
): Promise<string | undefined> {
|
|
637
751
|
try {
|
|
638
|
-
return await
|
|
752
|
+
return await readOwnedText(source, signal, environment, read);
|
|
639
753
|
} catch {
|
|
640
754
|
return undefined;
|
|
641
755
|
}
|
|
642
756
|
}
|
|
643
757
|
|
|
758
|
+
function canonicalSource(source: string): string {
|
|
759
|
+
return source.includes("://") ? source : path.resolve(source);
|
|
760
|
+
}
|
|
761
|
+
function resolveScope(cwd: string, source: string): string {
|
|
762
|
+
if (source.includes("://")) return source;
|
|
763
|
+
return cwd.includes("://")
|
|
764
|
+
? new URL(source, cwd.endsWith("/") ? cwd : cwd + "/").href
|
|
765
|
+
: path.resolve(cwd, source);
|
|
766
|
+
}
|
|
767
|
+
async function readOwnedText(
|
|
768
|
+
source: string,
|
|
769
|
+
signal?: AbortSignal,
|
|
770
|
+
environment?: SearchEnvironment,
|
|
771
|
+
read?: SnapshotReader,
|
|
772
|
+
): Promise<string> {
|
|
773
|
+
signal?.throwIfAborted();
|
|
774
|
+
if (read !== undefined) return read(source, signal);
|
|
775
|
+
if (environment !== undefined) return environment.readText(source, signal);
|
|
776
|
+
if (source.includes("://")) throw new Error("No search snapshot owner for this source.");
|
|
777
|
+
return readFile(source, { encoding: "utf8", ...(signal !== undefined && { signal }) });
|
|
778
|
+
}
|
|
644
779
|
function staleAnchor(
|
|
645
780
|
lineNumber = 1,
|
|
646
781
|
): Extract<TextAnchorResolutionAttempt, { readonly kind: "rejected" }> {
|