pi-agent-ide 0.1.1 → 0.2.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 +27 -0
- package/README.md +11 -5
- package/dist/chunk-266RH77Z.js +1 -0
- package/dist/chunk-2SKAED2I.js +2 -0
- package/dist/chunk-2ZMYT6ZC.js +1 -0
- package/dist/chunk-34ZQTTU2.js +2 -0
- package/dist/chunk-3H2EU7VQ.js +0 -0
- package/dist/chunk-3YK4XMWB.js +0 -0
- package/dist/chunk-476MR2QB.js +1 -0
- package/dist/chunk-4KQOODGE.js +13 -0
- package/dist/chunk-4SQQKEVD.js +16 -0
- package/dist/chunk-52BM6J6I.js +6 -0
- package/dist/chunk-5A25RATC.js +3 -0
- package/dist/chunk-5BWUVAR4.js +1 -0
- package/dist/chunk-6DN7NO7L.js +1 -0
- package/dist/chunk-6SMFVLTY.js +1 -0
- package/dist/chunk-7NDBZ4WX.js +1 -0
- package/dist/chunk-AP7Z3VWC.js +1 -0
- package/dist/chunk-BYWAG6X3.js +6 -0
- package/dist/chunk-DEP55R35.js +1 -0
- package/dist/chunk-E2RESHYR.js +1 -0
- package/dist/chunk-E4SECPF4.js +1 -0
- package/dist/chunk-EEH4WYI7.js +1 -0
- package/dist/chunk-EI7MMDWY.js +1 -0
- package/dist/chunk-ERVMDQGX.js +1 -0
- package/dist/chunk-EW2KVKCN.js +2 -0
- package/dist/chunk-F6SESI3P.js +4 -0
- package/dist/chunk-GTK5AREE.js +2 -0
- package/dist/chunk-HOBTFFQR.js +1 -0
- package/dist/chunk-IMVCVPMP.js +3 -0
- package/dist/chunk-IOCABSRL.js +1 -0
- package/dist/chunk-JASLOB2X.js +1 -0
- package/dist/chunk-JMVDFOTQ.js +1 -0
- package/dist/chunk-K4ZMRDEI.js +0 -0
- package/dist/chunk-KINKBPPX.js +1 -0
- package/dist/chunk-KNMWCDDK.js +7 -0
- package/dist/chunk-KP37XTDI.js +1 -0
- package/dist/chunk-KYVOMBO5.js +1 -0
- package/dist/chunk-KZBAJFCV.js +1 -0
- package/dist/chunk-LFV6G5Z3.js +1 -0
- package/dist/chunk-MB6VVVAF.js +2 -0
- package/dist/chunk-MBUXFKIW.js +3 -0
- package/dist/chunk-MTTKFJV6.js +1 -0
- package/dist/chunk-NI2NK4JU.js +1 -0
- package/dist/chunk-NNCZYO4Q.js +0 -0
- package/dist/chunk-OBWZ5RYN.js +1 -0
- package/dist/chunk-OIL6BB2S.js +33 -0
- package/dist/chunk-ORAPGW7W.js +1 -0
- package/dist/chunk-OVUYPHDE.js +1 -0
- package/dist/chunk-PETQCA7G.js +1 -0
- package/dist/chunk-PODWLGNO.js +6 -0
- package/dist/chunk-QNZVPFSP.js +3 -0
- package/dist/chunk-QW5O42QJ.js +2 -0
- package/dist/chunk-SJYDLHEF.js +108 -0
- package/dist/chunk-SSZB66C3.js +3 -0
- package/dist/chunk-STUZZM5B.js +1 -0
- package/dist/chunk-T2RPMEM2.js +1 -0
- package/dist/chunk-TG6H6EOI.js +1 -0
- package/dist/chunk-TNWYEXFG.js +1 -0
- package/dist/chunk-U4D6FT66.js +1 -0
- package/dist/chunk-VCCMVQXU.js +1 -0
- package/dist/chunk-VFBLX4TG.js +1 -0
- package/dist/chunk-VSP2QQPQ.js +2 -0
- package/dist/chunk-VUNCBASK.js +10 -0
- package/dist/chunk-VWVLBOMU.js +8 -0
- package/dist/chunk-W3XYKJ5H.js +1 -0
- package/dist/chunk-XGUAL3CA.js +1 -0
- package/dist/chunk-XNXQYPVT.js +10 -0
- package/dist/chunk-YHUTTZC6.js +2 -0
- package/dist/chunk-YPHXLAQF.js +1 -0
- package/dist/chunk-YQTLJ5ZV.js +58 -0
- package/dist/chunk-ZC65Z3CK.js +1 -0
- package/dist/entry-0.js +1 -0
- package/dist/entry-1.js +1 -0
- package/dist/entry-10.js +1 -0
- package/dist/entry-11.js +1 -0
- package/dist/entry-12.js +1 -0
- package/dist/entry-13.js +1 -0
- package/dist/entry-14.js +1 -0
- package/dist/entry-16.js +1 -0
- package/dist/entry-17.js +1 -0
- package/dist/entry-18.js +1 -0
- package/dist/entry-19.js +1 -0
- package/dist/entry-2.js +1 -0
- package/dist/entry-20.js +1 -0
- package/dist/entry-21.js +1 -0
- package/dist/entry-22.js +1 -0
- package/dist/entry-23.js +1 -0
- package/dist/entry-24.js +1 -0
- package/dist/entry-25.js +1 -0
- package/dist/entry-26.js +1 -0
- package/dist/entry-27.js +1 -0
- package/dist/entry-28.js +1 -0
- package/dist/entry-29.js +1 -0
- package/dist/entry-3.js +1 -0
- package/dist/entry-30.js +1 -0
- package/dist/entry-31.js +1 -0
- package/dist/entry-32.js +1 -0
- package/dist/entry-33.js +1 -0
- package/dist/entry-34.js +1 -0
- package/dist/entry-35.js +1 -0
- package/dist/entry-36.js +1 -0
- package/dist/entry-37.js +1 -0
- package/dist/entry-38.js +1 -0
- package/dist/entry-39.js +1 -0
- package/dist/entry-4.js +1 -0
- package/dist/entry-40.js +1 -0
- package/dist/entry-41.js +1 -0
- package/dist/entry-42.js +1 -0
- package/dist/entry-43.js +1 -0
- package/dist/entry-44.js +1 -0
- package/dist/entry-45.js +1 -0
- package/dist/entry-46.js +1 -0
- package/dist/entry-47.js +1 -0
- package/dist/entry-48.js +1 -0
- package/dist/entry-49.js +1 -0
- package/dist/entry-5.js +1 -0
- package/dist/entry-50.js +1 -0
- package/dist/entry-51.js +1 -0
- package/dist/entry-52.js +1 -0
- package/dist/entry-53.js +0 -0
- package/dist/entry-54.js +1 -0
- package/dist/entry-55.js +0 -0
- package/dist/entry-56.js +1 -0
- package/dist/entry-57.js +1 -0
- package/dist/entry-58.js +1 -0
- package/dist/entry-59.js +1 -0
- package/dist/entry-6.js +1 -0
- package/dist/entry-60.js +1 -0
- package/dist/entry-61.js +1 -0
- package/dist/entry-62.js +0 -0
- package/dist/entry-63.js +1 -0
- package/dist/entry-64.js +0 -0
- package/dist/entry-65.js +1 -0
- package/dist/entry-66.js +1 -0
- package/dist/entry-67.js +1 -0
- package/dist/entry-68.js +1 -0
- package/dist/entry-69.js +1 -0
- package/dist/entry-7.js +1 -0
- package/dist/entry-70.js +1 -0
- package/dist/entry-71.js +1 -0
- package/dist/entry-72.js +1 -0
- package/dist/entry-73.js +1 -0
- package/dist/entry-74.js +1 -0
- package/dist/entry-75.js +1 -0
- package/dist/entry-76.js +1 -0
- package/dist/entry-77.js +1 -0
- package/dist/entry-78.js +1 -0
- package/dist/entry-79.js +1 -0
- package/dist/entry-8.js +1 -0
- package/dist/entry-9.js +1 -0
- package/dist/pi-agent-ide.js +13 -0
- package/docs/architecture.md +21 -17
- package/docs/configuration.md +149 -52
- package/docs/development.md +105 -5
- package/docs/extensions.md +64 -4
- package/docs/generated/tool-catalog/css.md +7 -6
- package/docs/generated/tool-catalog/html.md +6 -5
- package/docs/generated/tool-catalog/javascript.md +8 -6
- package/docs/generated/tool-catalog/json.md +7 -6
- package/docs/generated/tool-catalog/markdown.md +6 -5
- package/docs/generated/tool-catalog/toml.md +6 -5
- package/docs/generated/tool-catalog/typescript.md +8 -6
- package/docs/generated/tool-catalog/yaml.md +6 -5
- package/docs/tools.md +88 -6
- package/node_modules/pi-agent-doctor/package.json +8 -5
- package/node_modules/pi-agent-doctor/runtime/entry-16.js +1 -0
- package/node_modules/pi-agent-doctor/runtime/entry-17.js +1 -0
- package/node_modules/pi-agent-doctor/runtime/entry-18.js +1 -0
- package/node_modules/pi-agent-doctor/runtime/entry-19.js +1 -0
- package/node_modules/pi-agent-doctor/src/executable.ts +33 -0
- package/node_modules/pi-agent-doctor/src/plugin-protocol.ts +30 -4
- package/node_modules/pi-agent-filesystem/index.ts +4 -3
- package/node_modules/pi-agent-filesystem/package.json +7 -7
- package/node_modules/pi-agent-filesystem/runtime/entry-20.js +2 -0
- package/node_modules/pi-agent-filesystem-image/package.json +4 -4
- package/node_modules/pi-agent-filesystem-image/runtime/entry-21.js +2 -0
- package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
- package/node_modules/pi-agent-filesystem-pdf/runtime/entry-22.js +2 -0
- package/node_modules/pi-agent-filesystem-text/package.json +4 -4
- package/node_modules/pi-agent-filesystem-text/runtime/entry-23.js +2 -0
- package/node_modules/pi-agent-ide-ast/package.json +11 -10
- package/node_modules/pi-agent-ide-ast/runtime/entry-24.js +1 -0
- package/node_modules/pi-agent-ide-ast/runtime/entry-25.js +2 -0
- package/node_modules/pi-agent-ide-ast/src/api/scope.ts +1 -1
- package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +1 -1
- package/node_modules/pi-agent-ide-ast/src/doctor-plugin.ts +25 -0
- package/node_modules/pi-agent-ide-ast/src/extension.ts +13 -5
- package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +6 -0
- package/node_modules/pi-agent-ide-changes/index.ts +6 -2
- package/node_modules/pi-agent-ide-changes/package.json +8 -7
- package/node_modules/pi-agent-ide-changes/runtime/entry-26.js +1 -0
- package/node_modules/pi-agent-ide-changes/runtime/entry-27.js +2 -0
- package/node_modules/pi-agent-ide-changes/src/change-anchor.ts +6 -0
- package/node_modules/pi-agent-ide-changes/src/changes/change-groups.ts +1 -1
- package/node_modules/pi-agent-ide-changes/src/changes/change-service.ts +1 -1
- package/node_modules/pi-agent-ide-changes/src/changes/git-changes-backend.ts +1 -0
- package/node_modules/pi-agent-ide-changes/src/current-change-presenter.ts +1 -1
- package/node_modules/pi-agent-ide-changes/src/doctor-plugin.ts +31 -1
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +5 -0
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +7 -0
- package/node_modules/pi-agent-ide-formatter/package.json +4 -4
- package/node_modules/pi-agent-ide-formatter/runtime/entry-28.js +2 -0
- package/node_modules/pi-agent-ide-formatter/src/catalog.ts +34 -0
- package/node_modules/pi-agent-ide-formatter/src/doctor-plugin.ts +115 -63
- package/node_modules/pi-agent-ide-formatter/src/registry.ts +71 -28
- package/node_modules/pi-agent-ide-languages/package.json +3 -3
- package/node_modules/pi-agent-ide-languages/runtime/entry-29.js +2 -0
- package/node_modules/pi-agent-ide-lint/index.ts +30 -155
- package/node_modules/pi-agent-ide-lint/package.json +8 -7
- package/node_modules/pi-agent-ide-lint/runtime/entry-30.js +2 -0
- package/node_modules/pi-agent-ide-lint/src/catalog.ts +14 -2
- package/node_modules/pi-agent-ide-lint/src/command-linter.ts +60 -4
- package/node_modules/pi-agent-ide-lint/src/diagnostics.ts +3 -1
- package/node_modules/pi-agent-ide-lint/src/doctor-plugin.ts +115 -64
- package/node_modules/pi-agent-ide-lint/src/registry.ts +72 -27
- package/node_modules/pi-agent-ide-lsp/index.ts +35 -134
- package/node_modules/pi-agent-ide-lsp/package.json +9 -8
- package/node_modules/pi-agent-ide-lsp/runtime/entry-31.js +2 -0
- package/node_modules/pi-agent-ide-lsp/src/code-view-resolvers.ts +1 -1
- package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +113 -0
- package/node_modules/pi-agent-ide-lsp/src/doctor-plugin.ts +108 -53
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +94 -27
- package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +2 -1
- package/node_modules/pi-agent-ide-lsp/src/lsp/diagnostic-adapters.ts +76 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/diagnostics.ts +137 -144
- package/node_modules/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +2 -2
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +9 -32
- package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +86 -50
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +1 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/types.ts +8 -6
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +5 -5
- package/node_modules/pi-agent-image/package.json +3 -3
- package/node_modules/pi-agent-image/runtime/entry-32.js +1 -0
- package/node_modules/pi-agent-invariant/package.json +12 -0
- package/node_modules/pi-agent-invariant/runtime/entry-33.js +1 -0
- package/node_modules/pi-agent-pdf/package.json +3 -3
- package/node_modules/pi-agent-pdf/runtime/entry-34.js +1 -0
- package/node_modules/pi-agent-pdf/src/pdf-converter.ts +3 -2
- package/node_modules/pi-agent-read/package.json +11 -9
- package/node_modules/pi-agent-read/runtime/entry-35.js +1 -0
- package/node_modules/pi-agent-read/runtime/entry-36.js +1 -0
- package/node_modules/pi-agent-read/runtime/entry-37.js +1 -0
- package/node_modules/pi-agent-read/runtime/entry-38.js +1 -0
- package/node_modules/pi-agent-read/runtime/entry-39.js +2 -0
- package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +1 -1
- package/node_modules/pi-agent-read/src/api/tools/read.ts +113 -2
- package/node_modules/pi-agent-read/src/core/extension.ts +19 -0
- package/node_modules/pi-agent-read/src/core/read-core.ts +85 -13
- package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +26 -10
- package/node_modules/pi-agent-read/src/core/tools/read/persisted-result.ts +72 -0
- package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +102 -12
- package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +27 -3
- package/node_modules/pi-agent-read/src/core/tools/read/views.ts +29 -0
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +532 -46
- package/node_modules/pi-agent-resource/package.json +5 -2
- package/node_modules/pi-agent-resource/runtime/entry-40.js +1 -0
- package/node_modules/pi-agent-resource/src/content-conversion/content-converter.ts +1 -1
- package/node_modules/pi-agent-resource/src/content-conversion/content-host.ts +1 -1
- package/node_modules/pi-agent-resource/src/content-conversion/content-runner.ts +1 -1
- package/node_modules/pi-agent-resource/src/content-conversion/validation.ts +1 -1
- package/node_modules/pi-agent-search/package.json +7 -6
- package/node_modules/pi-agent-search/runtime/entry-41.js +1 -0
- package/node_modules/pi-agent-search/runtime/entry-42.js +1 -0
- package/node_modules/pi-agent-search/runtime/entry-43.js +1 -0
- package/node_modules/pi-agent-search/runtime/entry-44.js +2 -0
- package/node_modules/pi-agent-search/src/api/search.ts +4 -0
- package/node_modules/pi-agent-search/src/core/extension.ts +99 -27
- package/node_modules/pi-agent-search/src/core/search-config.ts +98 -0
- package/node_modules/pi-agent-search/src/core/search-core.ts +32 -28
- package/node_modules/pi-agent-search/src/core/search-timeout.ts +54 -0
- package/node_modules/pi-agent-search-text/index.ts +53 -3
- package/node_modules/pi-agent-search-text/package.json +9 -9
- package/node_modules/pi-agent-search-text/runtime/entry-45.js +2 -0
- package/node_modules/pi-agent-search-text/runtime/entry-46.js +1 -0
- package/node_modules/pi-agent-search-text/src/doctor-plugin.ts +20 -1
- package/node_modules/pi-agent-search-text/src/persisted-result.ts +56 -0
- package/node_modules/pi-agent-search-text/src/resolvers.ts +36 -34
- package/node_modules/pi-agent-search-text/src/search-query.ts +254 -71
- package/node_modules/pi-agent-search-text/src/search-recipe.ts +68 -0
- package/node_modules/pi-agent-search-text/src/search-renderer.ts +71 -117
- package/node_modules/pi-agent-search-text/src/search-result.ts +1 -0
- package/node_modules/pi-agent-search-text/src/search-session.ts +276 -110
- package/node_modules/pi-agent-text/package.json +6 -3
- package/node_modules/pi-agent-text/runtime/entry-47.js +1 -0
- package/node_modules/pi-agent-text/src/index.ts +23 -0
- package/node_modules/pi-agent-text/src/stored-text.ts +14 -0
- package/node_modules/pi-agent-text/src/text-anchor.ts +160 -16
- package/node_modules/pi-agent-text/src/text-document.ts +26 -5
- package/node_modules/pi-agent-text/src/text-target.ts +105 -0
- package/node_modules/pi-agent-text-anchor-constant/package.json +7 -4
- package/node_modules/pi-agent-text-anchor-constant/runtime/entry-48.js +2 -0
- package/node_modules/pi-agent-text-anchor-constant/src/resolver.ts +6 -0
- package/node_modules/pi-agent-text-anchor-exact/index.ts +34 -0
- package/node_modules/pi-agent-text-anchor-exact/package.json +27 -0
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-49.js +1 -0
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-50.js +2 -0
- package/node_modules/pi-agent-text-anchor-exact/src/anchor.ts +230 -0
- package/node_modules/pi-agent-text-anchor-exact/src/config.ts +159 -0
- package/node_modules/pi-agent-text-anchor-exact/src/fuzzy-worker.ts +100 -0
- package/node_modules/pi-agent-text-anchor-exact/src/recovery.ts +151 -0
- package/node_modules/pi-agent-text-anchor-line-hash/index.ts +8 -2
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +10 -6
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-51.js +1 -0
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-52.js +2 -0
- package/node_modules/pi-agent-text-anchor-line-hash/src/anchor.ts +32 -1
- package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +20 -12
- package/node_modules/pi-agent-text-editor/package.json +22 -21
- package/node_modules/pi-agent-text-editor/runtime/entry-53.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-54.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-55.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-56.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-57.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-58.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-59.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-60.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-61.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-62.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-63.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-64.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-65.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-66.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-67.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-68.js +2 -0
- package/node_modules/pi-agent-text-editor/src/api/anchor-inspection.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +1 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +38 -0
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +30 -15
- package/node_modules/pi-agent-text-editor/src/api/text-selection-anchor.ts +10 -13
- package/node_modules/pi-agent-text-editor/src/api/tool-call-interceptor.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +12 -5
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +15 -1
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +14 -10
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/diff.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +3 -2
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +19 -2
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +64 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/inline-hints.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/read-fragment-resolver.ts +83 -0
- package/node_modules/pi-agent-text-editor/src/core/text-anchor-registry.ts +96 -8
- package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +4 -1
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +194 -35
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +43 -13
- package/node_modules/pi-agent-text-editor/src/core/text-editor-config.ts +95 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +75 -5
- package/node_modules/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +7 -0
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +541 -130
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +5 -9
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/rendering.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +228 -6
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +50 -70
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +25 -26
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +30 -21
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +57 -71
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +30 -27
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -0
- package/node_modules/pi-agent-text-editor-argument-order/package.json +3 -3
- package/node_modules/pi-agent-text-editor-argument-order/runtime/entry-69.js +2 -0
- package/node_modules/pi-agent-text-editor-overwrite/index.ts +1 -1
- package/node_modules/pi-agent-text-editor-overwrite/package.json +4 -3
- package/node_modules/pi-agent-text-editor-overwrite/runtime/entry-70.js +2 -0
- package/node_modules/pi-agent-text-editor-renderer/index.ts +21 -1
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -3
- package/node_modules/pi-agent-text-editor-renderer/runtime/entry-71.js +2 -0
- package/node_modules/pi-agent-text-editor-renderer/src/animation-pressure.ts +50 -0
- package/node_modules/pi-agent-text-editor-renderer/src/config.ts +73 -0
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +1 -1
- package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +77 -22
- package/node_modules/pi-agent-text-editor-renderer/src/diff-theme.ts +1 -1
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +140 -24
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-projection.ts +274 -43
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-result.ts +33 -6
- package/node_modules/pi-agent-text-editor-renderer/src/persisted-result.ts +47 -0
- package/node_modules/pi-agent-text-editor-renderer/src/render-resource.ts +7 -0
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +265 -105
- package/node_modules/pi-agent-text-editor-renderer/src/typing-interpolation.ts +96 -15
- package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +22 -6
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -4
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-72.js +2 -0
- package/node_modules/pi-agent-tool-call-interception/package.json +5 -2
- 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 +175 -32
- package/node_modules/pi-agent-tool-ui/package.json +15 -0
- package/node_modules/pi-agent-tool-ui/runtime/entry-74.js +1 -0
- package/node_modules/pi-agent-tool-ui/src/index.ts +318 -0
- package/node_modules/pi-agent-web/index.ts +16 -6
- package/node_modules/pi-agent-web/package.json +8 -6
- package/node_modules/pi-agent-web/runtime/entry-75.js +2 -0
- package/node_modules/pi-agent-web/src/browser-loader.ts +180 -0
- package/node_modules/pi-agent-web/src/doctor-plugin.ts +41 -0
- package/node_modules/pi-agent-web/src/resolver.ts +128 -24
- package/node_modules/pi-agent-web-html/package.json +6 -3
- package/node_modules/pi-agent-web-html/runtime/entry-76.js +2 -0
- package/node_modules/pi-agent-web-html/src/extract-readable-html.ts +19 -6
- package/node_modules/pi-agent-web-image/package.json +4 -4
- package/node_modules/pi-agent-web-image/runtime/entry-77.js +2 -0
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/runtime/entry-78.js +2 -0
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/node_modules/pi-agent-web-text/runtime/entry-79.js +2 -0
- package/package.json +68 -54
- package/src/api/code-view.ts +4 -0
- package/src/api/connect-tip-provider.ts +49 -0
- package/src/api/plugin-protocol.ts +41 -2
- package/src/api/tips.ts +77 -0
- package/src/api/tool-config/formatters.json +215 -0
- package/src/api/tool-config/linters.json +257 -0
- package/src/api/tool-config/lsp-servers.json +275 -0
- package/src/api/tool-config.ts +217 -13
- package/src/api/toolchain.ts +0 -5
- package/src/code-view/diagnostic-view.ts +117 -26
- package/src/code-view/source-view.ts +1 -1
- package/src/composite/builtin-extensions.ts +12 -6
- package/src/composite/extensions-config.ts +137 -0
- package/src/composite/selection.ts +58 -3
- package/src/core/diagnostic-store.ts +244 -0
- package/src/core/extension.ts +40 -0
- package/src/core/ide-core.ts +48 -3
- package/src/doctor/config-writer.ts +1 -1
- package/src/doctor/core.ts +47 -0
- package/src/doctor/discovery.ts +10 -2
- package/src/doctor/extension.ts +12 -1
- package/src/doctor/inventory.ts +24 -6
- package/src/doctor/run.ts +68 -87
- package/src/doctor/tip-provider.ts +92 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +4 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-21.js +2 -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-22.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-23.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-20.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +16 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +6 -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/extract-readable-html.ts +19 -6
- 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-image/runtime/entry-77.js +2 -0
- 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-78.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-79.js +2 -0
- 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 +180 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/doctor-plugin.ts +41 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/resolver.ts +128 -24
- package/src/extensions/pi-agent-read/package.json +11 -9
- package/src/extensions/pi-agent-read/runtime/entry-35.js +1 -0
- package/src/extensions/pi-agent-read/runtime/entry-36.js +1 -0
- package/src/extensions/pi-agent-read/runtime/entry-37.js +1 -0
- package/src/extensions/pi-agent-read/runtime/entry-38.js +1 -0
- package/src/extensions/pi-agent-read/runtime/entry-39.js +2 -0
- package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +113 -2
- package/src/extensions/pi-agent-read/src/core/extension.ts +19 -0
- package/src/extensions/pi-agent-read/src/core/read-core.ts +85 -13
- package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +26 -10
- package/src/extensions/pi-agent-read/src/core/tools/read/persisted-result.ts +72 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +102 -12
- package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +27 -3
- package/src/extensions/pi-agent-read/src/core/tools/read/views.ts +29 -0
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +532 -46
- package/src/extensions/pi-agent-search/package.json +7 -6
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +53 -3
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +9 -9
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-45.js +2 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-46.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/doctor-plugin.ts +20 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/persisted-result.ts +56 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +36 -34
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-query.ts +254 -71
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +68 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +71 -117
- 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 +276 -110
- package/src/extensions/pi-agent-search/runtime/entry-41.js +1 -0
- package/src/extensions/pi-agent-search/runtime/entry-42.js +1 -0
- package/src/extensions/pi-agent-search/runtime/entry-43.js +1 -0
- package/src/extensions/pi-agent-search/runtime/entry-44.js +2 -0
- package/src/extensions/pi-agent-search/src/api/search.ts +4 -0
- package/src/extensions/pi-agent-search/src/core/extension.ts +99 -27
- package/src/extensions/pi-agent-search/src/core/search-config.ts +98 -0
- package/src/extensions/pi-agent-search/src/core/search-core.ts +32 -28
- package/src/extensions/pi-agent-search/src/core/search-timeout.ts +54 -0
- package/src/extensions/pi-agent-text-editor/package.json +22 -21
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +7 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-48.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/src/resolver.ts +6 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/index.ts +34 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +27 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-49.js +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-50.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchor.ts +230 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/config.ts +159 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/fuzzy-worker.ts +100 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/recovery.ts +151 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +8 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +10 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-51.js +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-52.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/anchor.ts +32 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/read-handler.ts +20 -12
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/runtime/entry-69.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/index.ts +1 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +4 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/runtime/entry-70.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +21 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-71.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/animation-pressure.ts +50 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/config.ts +73 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +1 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +77 -22
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-theme.ts +1 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +140 -24
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-projection.ts +274 -43
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-result.ts +33 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/persisted-result.ts +47 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/render-resource.ts +7 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +265 -105
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/typing-interpolation.ts +96 -15
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/index.ts +22 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-72.js +2 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-53.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-54.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-55.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-56.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-57.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-58.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-59.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-60.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-61.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-62.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-63.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-64.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-65.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-66.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-67.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-68.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/anchor-inspection.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +1 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +38 -0
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +30 -15
- package/src/extensions/pi-agent-text-editor/src/api/text-selection-anchor.ts +10 -13
- package/src/extensions/pi-agent-text-editor/src/api/tool-call-interceptor.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +12 -5
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +15 -1
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +14 -10
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/diff.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +3 -2
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +19 -2
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +64 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/inline-hints.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/read-fragment-resolver.ts +83 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-anchor-registry.ts +96 -8
- package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +4 -1
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +194 -35
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +43 -13
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-config.ts +95 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +75 -5
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +7 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +541 -130
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +5 -9
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/rendering.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +228 -6
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +50 -70
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +25 -26
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +30 -21
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +57 -71
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +30 -27
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -0
- package/src/pi-agent-ide.ts +15 -3
- package/src/plugins/pi-agent-ide-ast/package.json +11 -10
- package/src/plugins/pi-agent-ide-ast/runtime/entry-24.js +1 -0
- package/src/plugins/pi-agent-ide-ast/runtime/entry-25.js +2 -0
- package/src/plugins/pi-agent-ide-ast/src/api/scope.ts +1 -1
- package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +1 -1
- package/src/plugins/pi-agent-ide-ast/src/doctor-plugin.ts +25 -0
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +13 -5
- package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +6 -0
- package/src/plugins/pi-agent-ide-changes/index.ts +6 -2
- package/src/plugins/pi-agent-ide-changes/package.json +8 -7
- package/src/plugins/pi-agent-ide-changes/runtime/entry-26.js +1 -0
- package/src/plugins/pi-agent-ide-changes/runtime/entry-27.js +2 -0
- package/src/plugins/pi-agent-ide-changes/src/change-anchor.ts +6 -0
- package/src/plugins/pi-agent-ide-changes/src/changes/change-groups.ts +1 -1
- package/src/plugins/pi-agent-ide-changes/src/changes/change-service.ts +1 -1
- package/src/plugins/pi-agent-ide-changes/src/changes/git-changes-backend.ts +1 -0
- package/src/plugins/pi-agent-ide-changes/src/current-change-presenter.ts +1 -1
- package/src/plugins/pi-agent-ide-changes/src/doctor-plugin.ts +31 -1
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +5 -0
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +7 -0
- package/src/plugins/pi-agent-ide-diagnostics/index.ts +1 -0
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +191 -0
- package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
- package/src/plugins/pi-agent-ide-formatter/runtime/entry-28.js +2 -0
- package/src/plugins/pi-agent-ide-formatter/src/catalog.ts +34 -0
- package/src/plugins/pi-agent-ide-formatter/src/doctor-plugin.ts +115 -63
- package/src/plugins/pi-agent-ide-formatter/src/registry.ts +71 -28
- package/src/plugins/pi-agent-ide-languages/package.json +3 -3
- package/src/plugins/pi-agent-ide-languages/runtime/entry-29.js +2 -0
- package/src/plugins/pi-agent-ide-lint/index.ts +30 -155
- package/src/plugins/pi-agent-ide-lint/package.json +8 -7
- package/src/plugins/pi-agent-ide-lint/runtime/entry-30.js +2 -0
- package/src/plugins/pi-agent-ide-lint/src/catalog.ts +14 -2
- package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +60 -4
- package/src/plugins/pi-agent-ide-lint/src/diagnostics.ts +3 -1
- package/src/plugins/pi-agent-ide-lint/src/doctor-plugin.ts +115 -64
- package/src/plugins/pi-agent-ide-lint/src/registry.ts +72 -27
- package/src/plugins/pi-agent-ide-lsp/index.ts +35 -134
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -8
- package/src/plugins/pi-agent-ide-lsp/runtime/entry-31.js +2 -0
- package/src/plugins/pi-agent-ide-lsp/src/code-view-resolvers.ts +1 -1
- package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +113 -0
- package/src/plugins/pi-agent-ide-lsp/src/doctor-plugin.ts +108 -53
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +94 -27
- package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +2 -1
- package/src/plugins/pi-agent-ide-lsp/src/lsp/diagnostic-adapters.ts +76 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/diagnostics.ts +137 -144
- package/src/plugins/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +2 -2
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +9 -32
- package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +86 -50
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +1 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/types.ts +8 -6
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +5 -5
- package/src/post-edit/gate.ts +17 -141
- package/src/tips/core.ts +86 -0
- package/src/tips/extension.ts +115 -0
- package/src/tips/persistence.ts +225 -0
- package/src/tips/tip-callout.ts +77 -0
- package/src/toolchain/registry.ts +8 -23
- package/src/toolchain/types.ts +6 -74
- package/node_modules/pi-agent-search-semantic/index.ts +0 -97
- package/node_modules/pi-agent-search-semantic/package.json +0 -17
- package/node_modules/pi-agent-search-text/src/lucene-query-parser.d.ts +0 -20
- package/node_modules/pi-agent-search-web/index.ts +0 -82
- package/node_modules/pi-agent-search-web/package.json +0 -20
- package/node_modules/pi-agent-search-web/src/config.ts +0 -560
- package/node_modules/pi-agent-search-web/src/doctor-plugin.ts +0 -40
- package/node_modules/pi-agent-search-web/src/providers/duckduckgo-html.ts +0 -74
- package/node_modules/pi-agent-search-web/src/providers/endpoints.ts +0 -81
- package/node_modules/pi-agent-search-web/src/providers/request.ts +0 -427
- package/node_modules/pi-agent-search-web/src/providers/response.ts +0 -353
- package/node_modules/pi-agent-search-web/src/search-format.ts +0 -24
- package/node_modules/pi-agent-search-web/src/search.ts +0 -376
- package/node_modules/pi-agent-search-web/src/types.ts +0 -141
- package/src/composite/config.ts +0 -100
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-semantic/index.ts +0 -97
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-semantic/package.json +0 -17
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/lucene-query-parser.d.ts +0 -20
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/index.ts +0 -82
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/package.json +0 -20
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/config.ts +0 -560
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/doctor-plugin.ts +0 -40
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/duckduckgo-html.ts +0 -74
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/endpoints.ts +0 -81
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/request.ts +0 -427
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/response.ts +0 -353
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/search-format.ts +0 -24
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/search.ts +0 -376
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/types.ts +0 -141
- package/src/toolchain/gate.ts +0 -305
- /package/{src/utils/required-value.ts → node_modules/pi-agent-invariant/src/index.ts} +0 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.0 — 2026-09-05
|
|
4
|
+
|
|
5
|
+
### Editing and search
|
|
6
|
+
|
|
7
|
+
- Edit with exact text or anchors, insert before or after a target, and use search results directly for reads and edits across files.
|
|
8
|
+
- Search tries literal text first, then regex and individual words when needed. Quoted text and Boolean conditions keep their meaning, and fallback steps are reported.
|
|
9
|
+
|
|
10
|
+
### Background diagnostics
|
|
11
|
+
|
|
12
|
+
- Lint and LSP checks run after edits are saved, without holding up the edit result. Agents receive a compact summary in their next model context and can request details through `diagnostics:` or the diagnostics view.
|
|
13
|
+
- Pending and unavailable checks are reported explicitly rather than appearing clean.
|
|
14
|
+
|
|
15
|
+
### Web reading
|
|
16
|
+
|
|
17
|
+
- URL reads automatically retry in a local browser when ordinary loading fails or a page needs JavaScript. If both attempts fail, the result includes both errors.
|
|
18
|
+
|
|
19
|
+
### Interface and performance
|
|
20
|
+
|
|
21
|
+
- More consistent tool output and steadier streamed diffs, with fixes for wrapping, backgrounds, and large edits.
|
|
22
|
+
- Smaller saved tool histories and startup that no longer waits for optional tips.
|
|
23
|
+
|
|
24
|
+
### Configuration and agent guidance
|
|
25
|
+
|
|
26
|
+
- Built-in formatter, linter, and LSP settings can be overridden globally or per project.
|
|
27
|
+
- Updated agent instructions explain the available tools, search references, and editing rules.
|
package/README.md
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
<a href="https://www.npmjs.com/package/pi-agent-ide"><img src="https://img.shields.io/npm/v/pi-agent-ide" alt="npm version"></a>
|
|
11
11
|
<a href="https://www.npmjs.com/package/pi-agent-ide"><img src="https://img.shields.io/npm/dm/pi-agent-ide" alt="npm downloads"></a>
|
|
12
12
|
<a href="https://github.com/alexshpunt/pi-agent-ide/actions/workflows/ci.yml"><img src="https://github.com/alexshpunt/pi-agent-ide/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI status"></a>
|
|
13
|
+
<a href="https://github.com/alexshpunt/pi-agent-ide/actions/workflows/ci.yml"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2Falexshpunt%2F0d28d39557e2a9976c4548e7737c102d%2Fraw%2Funit.json" alt="Unit test count"></a>
|
|
14
|
+
<a href="https://github.com/alexshpunt/pi-agent-ide/actions/workflows/ci.yml"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2Falexshpunt%2F0d28d39557e2a9976c4548e7737c102d%2Fraw%2Fintegration.json" alt="Integration test count"></a>
|
|
13
15
|
<a href="./LICENSE"><img src="https://img.shields.io/npm/l/pi-agent-ide" alt="MIT license"></a>
|
|
14
16
|
</p>
|
|
15
17
|
|
|
@@ -24,7 +26,7 @@ The current focus is measurement. The project is being compared with vanilla Pi
|
|
|
24
26
|
Pi Agent IDE provides a small set of tools with more specialized behavior behind them:
|
|
25
27
|
|
|
26
28
|
- `read` handles files, web pages, images, PDFs, code views, and diagnostics;
|
|
27
|
-
- `search` routes text
|
|
29
|
+
- `search` routes text and structural searches;
|
|
28
30
|
- `write`, `replace`, `insert`, `delete`, `copy`, and `move` cover common text mutations; range-based edits can target snapshot and semantic anchors instead of reproducing the `oldText` block required by Pi's built-in `edit` tool;
|
|
29
31
|
- optional plugins add AST, LSP, formatting, linting, and Git-aware behavior;
|
|
30
32
|
- `/pi-agent-ide-doctor` detects project languages and lets each loaded plugin check or configure its own scope.
|
|
@@ -41,7 +43,9 @@ pi install npm:pi-agent-ide
|
|
|
41
43
|
|
|
42
44
|
Pi packages run with your full system permissions. Review the package before installing it.
|
|
43
45
|
|
|
44
|
-
## Check project
|
|
46
|
+
## Check project tools
|
|
47
|
+
|
|
48
|
+
Pi Agent IDE includes formatter, linter, and LSP mappings. It runs their external commands through your current `PATH`, so projects work without copied IDE config files when those commands are installed.
|
|
45
49
|
|
|
46
50
|
Start Pi in your project directory, then run:
|
|
47
51
|
|
|
@@ -49,11 +53,13 @@ Start Pi in your project directory, then run:
|
|
|
49
53
|
/pi-agent-ide-doctor
|
|
50
54
|
```
|
|
51
55
|
|
|
52
|
-
Doctor
|
|
56
|
+
Doctor checks the effective project, global, and built-in mappings. It reports each applicable ID, its source layer and command, and the real probe result. It also checks AST support, search, and Git.
|
|
57
|
+
|
|
58
|
+
Doctor shows its report before changing anything. If project evidence points to a different installed tool, it can write a project-only override under `.pi/pi-agent-ide/`. It never changes global or built-in configuration. Native files such as `eslint.config.js`, `.clang-format`, and `pyproject.toml` remain unchanged.
|
|
53
59
|
|
|
54
|
-
Doctor
|
|
60
|
+
Doctor also reports optional system Chrome/Chromium support for browser-rendered web reads. When setup still needs work, you can ask the agent to finish it; doctor runs the checks again afterward.
|
|
55
61
|
|
|
56
|
-
Run doctor again after installing or changing project tools. For
|
|
62
|
+
Run doctor again after installing or changing project tools. For configuration paths, precedence, and command flags, see [Configuration](./docs/configuration.md#doctor).
|
|
57
63
|
|
|
58
64
|
## Documentation
|
|
59
65
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as c}from"./chunk-EW2KVKCN.js";import{e as a}from"./chunk-2SKAED2I.js";import{a as r}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as i}from"typebox/value";var n="pi-agent-text-editor",p=17,P="pi-agent-text-editor/position",I="pi-agent-text-editor/search",b=`${n}/core/ready`,S=`${n}/plugin/register`,s=e.Function([],e.Unknown()),d=e.Object({tryResolve:s},{additionalProperties:!0}),l=e.Object({lineNumber:e.Integer({minimum:1}),column:e.Integer({minimum:0})}),T=e.Object({start:l,end:l,linewise:e.Optional(e.Boolean())}),R=e.Object({source:e.String({minLength:1}),ranges:e.Optional(e.Array(T))}),x=e.Union([e.Object({kind:e.Literal("not-handled")},{additionalProperties:!0}),e.Object({kind:e.Literal("resolved"),targets:e.Array(R,{minItems:1})},{additionalProperties:!0}),e.Object({kind:e.Literal("rejected"),rejection:e.Object({code:e.Union([e.Literal("invalid"),e.Literal("stale"),e.Literal("missing"),e.Literal("ambiguous")]),reason:e.String(),contextRange:e.Optional(e.Object({offset:e.Number(),limit:e.Number()}))})},{additionalProperties:!0}),e.Object({kind:e.Literal("failed"),error:e.Unknown()},{additionalProperties:!0})]),g=e.String({pattern:"\\S"}),m=e.Object({resolver:e.Unknown(),priority:e.Optional(e.Number())}),y=e.Object({resolver:e.Unknown(),resources:e.Optional(e.Unknown()),kind:e.String({pattern:"\\S"}),type:e.Union([e.Literal("major"),e.Literal("auxiliary"),e.Literal("constant")]),priority:e.Optional(e.Number())}),v=e.Object({protocol:e.Literal(n),apiVersion:e.Literal(p)}),u=e.Object({protocol:e.Literal(n),apiVersion:e.Literal(p),id:e.String(),setup:s}),E=e.Object({plugin:u,accept:s});function k(t){return i.Check(g,t)}r(k,"isTextEditorToolId");function _(t){if(!i.Check(m,t))return!1;let o=t;return c(o.resolver)&&(!("priority"in o)||typeof o.priority=="number")}r(_,"isResourceResolverRegistration");function j(t){if(!i.Check(y,t))return!1;let o=t;return a(o.resolver)&&(!("resources"in o)||i.Check(d,o.resources))&&(!("priority"in o)||typeof o.priority=="number")}r(j,"isTextAnchorResolverRegistration");function C(t){return i.Check(x,t)}r(C,"isTextAnchorResourceResolutionAttempt");function L(t){return i.Check(v,t)}r(L,"isTextEditorCoreReady");function w(t){return i.Check(u,t)}r(w,"isTextEditorPlugin");function N(t){return i.Check(E,t)}r(N,"isTextEditorPluginRegistrationRequest");export{n as a,p as b,P as c,I as d,b as e,S as f,k as g,_ as h,j as i,C as j,L as k,w as l,N as m};
|
|
@@ -0,0 +1,2 @@
|
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1,2 @@
|
|
|
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};
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as E}from"./chunk-ERVMDQGX.js";import{a as D,b as R}from"./chunk-VFBLX4TG.js";import{a as L}from"./chunk-OBWZ5RYN.js";import{a as w,b}from"./chunk-KZBAJFCV.js";import{e as v,f as j,g as h,h as x,k as P}from"./chunk-7NDBZ4WX.js";import{a as d}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";function S(n,t){if(n.trim().length===0)return[];switch(t.format){case"pi-json":return q(n);case"eslint-json":return M(n);case"sarif":return F(n);case"checkstyle":return J(n);case"gcc":case"clang":return V(n);case"regex":return z(n,d(t.pattern))}}s(S,"parseDiagnostics");function q(n){let t=JSON.parse(n);return Array.isArray(t.diagnostics)?t.diagnostics.flatMap(u):[]}s(q,"parsePiJson");function M(n){return JSON.parse(n).flatMap(e=>Array.isArray(e.messages)?e.messages.flatMap(u):[])}s(M,"parseEslintJson");function F(n){return(JSON.parse(n).runs??[]).flatMap(e=>(e.results??[]).flatMap(r=>{let i=r.locations?.[0]?.physicalLocation?.region??{},a=r.message;return u({line:i.startLine,column:i.startColumn,message:a?.text,code:r.ruleId,severity:B(r.level)})}))}s(F,"parseSarif");function J(n){let t=[],e=/<error\s+([^>]+?)\/?>(?:<\/error>)?/gu;for(let r of n.matchAll(e)){let i=Object.fromEntries([...d(r[1]).matchAll(/([\w-]+)="([^"]*)"/gu)].map(a=>[d(a[1]),H(d(a[2]))]));t.push(...u({line:Number(i.line),column:Number(i.column??1),message:i.message,code:i.source,severity:i.severity}))}return t}s(J,"parseCheckstyle");function V(n){return T(n,/^(?<file>.+?):(?<line>\d+):(?<column>\d+):\s*(?<severity>fatal error|error|warning|note|info|hint):\s*(?<message>.*?)(?:\s+\[(?<code>[^\]]+)\])?$/u)}s(V,"parseCompilerLines");function z(n,t){return T(n,new RegExp(t,"u"))}s(z,"parseRegexLines");function T(n,t){return n.split(/\r?\n/u).flatMap(e=>{let r=e.match(t)?.groups;return r===void 0?[]:u(r)})}s(T,"parseMatchingLines");function u(n){if(typeof n!="object"||n===null)return[];let t=n,e=I(t.line??t.startLine),r=I(t.column??t.startColumn,1),i=typeof t.message=="string"?t.message:void 0;return e===void 0||i===void 0?[]:[{code:O(t.code??t.ruleId,"lint"),message:i,line:e,column:r??1,severity:G(t.severity)}]}s(u,"normalizeDiagnostic");function I(n,t){let e=typeof n=="string"?Number.parseInt(n,10):n;return typeof e=="number"&&Number.isInteger(e)&&e>=1?e:t}s(I,"numberValue");function O(n,t){return typeof n=="string"||typeof n=="number"?String(n):t}s(O,"stringValue");function G(n){if(n===2)return"error";if(n===1)return"warning";let t=O(n,"warning").toLowerCase();return t.includes("error")?"error":t==="info"||t==="note"||t==="notice"?"info":t==="hint"?"hint":"warning"}s(G,"severityValue");function B(n){return n==="error"||n==="warning"||n==="note"?n:"warning"}s(B,"sarifSeverity");function H(n){return n.replaceAll(""",'"').replaceAll("'","'").replaceAll("<","<").replaceAll(">",">").replaceAll("&","&")}s(H,"decodeXml");import A from"node:path";var f=class n{constructor(t,e){this.linters=t;this.availableBuiltIns=e}static{s(this,"LintCommandRegistry")}static async fromDirectory(t,e={}){let r=await v(t,"linters",o=>P(o).linters,e),i=e.environment??process.env,a=await Promise.all(r.entries.filter(o=>o.layer==="built-in").map(async o=>({id:o.id,available:await h(o.config.check,t,i)})));return new n(r.entries,new Set(a.filter(o=>o.available).map(o=>o.id)))}static fromConfig(t){return new n(Object.entries(t.linters).map(([e,r])=>({id:e,config:r,layer:"project",sourcePath:"<memory>"})),new Set)}resolve(t,e){return this.resolveEntry(t,e)?.config}resolveEntry(t,e){let r=A.isAbsolute(t)?t:A.join(e,t);return this.linters.find(i=>(i.layer!=="built-in"||this.availableBuiltIns.has(i.id))&&j(i.config,r,e))}get entries(){return this.linters}};async function p(n,t){let e;try{e=await x(n.check,t)}catch(a){return{ok:!1,diagnostics:[],failure:`command could not start: ${a instanceof Error?a.message:String(a)}`}}let r=e.stdout.trim().length>0?e.stdout:e.stderr,i;try{i=S(r,n.diagnostics)}catch{return{ok:!1,diagnostics:[],failure:`invalid ${n.diagnostics.format} diagnostics: ${r.trim().slice(0,200)||"empty command output"}`}}return{ok:e.ok,diagnostics:i,...!e.ok&&{failure:e.stderr.trim().slice(0,200)||`command exited with code ${String(e.exitCode)}`}}}s(p,"runConfiguredLinter");function N(n){return{kind:"linter",name:"command-lint",priority:100,extensions:["*"],detect:s(()=>Promise.resolve(!0),"detect"),async lint({filePath:t,fix:e},r){let i=n.resolve(t,r.cwd);if(i===void 0)return{ok:!0,diagnostics:[]};let a=e===!0&&i.fix!==void 0?i.fix:i.check,o=await p({...i,check:a},{projectRoot:r.cwd,filePath:t});return{ok:o.ok,diagnostics:o.diagnostics}}}}s(N,"createCommandLinter");import{copyFile as X,mkdtemp as K,rm as Q}from"node:fs/promises";import k from"node:path";var $=[c("clang-tidy",["c","cpp"],["clang-tidy"],[".clang-tidy","compile_commands.json"],[".c",".h",".cc",".cpp",".cxx",".hpp"],["clang-tidy","{file}"],"clang","https://clang.llvm.org/extra/clang-tidy/"),c("eslint",["javascript","typescript"],["eslint"],["eslint.config.js","eslint.config.mjs",".eslintrc.json"],[".js",".jsx",".mjs",".cjs",".ts",".tsx"],["eslint","--format","json","{file}"],"eslint-json","https://eslint.org/docs/latest/",void 0,["eslint"]),c("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"]),c("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"]),c("golangci-lint",["go"],["golangci-lint"],[".golangci.yml",".golangci.yaml","go.mod"],[".go"],["golangci-lint","run","{file}"],"gcc","https://golangci-lint.run/"),c("clippy",["rust"],["cargo"],["Cargo.toml","clippy.toml"],[".rs"],["cargo","clippy","--message-format","short"],"gcc","https://doc.rust-lang.org/clippy/"),c("dotnet-format",["csharp"],["dotnet"],[".editorconfig","global.json"],[".cs"],["dotnet","format","--verify-no-changes"],"gcc","https://learn.microsoft.com/dotnet/core/tools/dotnet-format"),c("checkstyle",["java"],["checkstyle"],["checkstyle.xml","pom.xml"],[".java"],["checkstyle","-f","xml","{file}"],"checkstyle","https://checkstyle.org/"),c("detekt",["kotlin"],["detekt"],["detekt.yml","build.gradle.kts"],[".kt",".kts"],["detekt","--input","{file}"],"gcc","https://detekt.dev/"),c("rubocop",["ruby"],["rubocop"],[".rubocop.yml","Gemfile"],[".rb",".rake"],["rubocop","--format","clang","{file}"],"clang","https://docs.rubocop.org/"),c("phpcs",["php"],["phpcs"],["phpcs.xml","phpcs.xml.dist","composer.json"],[".php"],["phpcs","--report=emacs","{file}"],"gcc","https://github.com/PHPCSStandards/PHP_CodeSniffer"),c("swiftlint",["swift"],["swiftlint"],[".swiftlint.yml","Package.swift"],[".swift"],["swiftlint","lint","--path","{file}"],"gcc","https://github.com/realm/SwiftLint"),c("luacheck",["lua"],["luacheck"],[".luacheckrc"],[".lua"],["luacheck","--formatter","plain","{file}"],"gcc","https://github.com/lunarmodules/luacheck"),c("shellcheck",["shell"],["shellcheck"],[".shellcheckrc"],[".sh",".bash",".zsh"],["shellcheck","-f","gcc","{file}"],"gcc","https://www.shellcheck.net/"),c("stylelint",["css"],["stylelint"],["stylelint.config.js",".stylelintrc.json"],[".css",".scss",".sass",".less"],["stylelint","--formatter","compact","{file}"],"gcc","https://stylelint.io/",void 0,["stylelint"]),c("yamllint",["yaml"],["yamllint"],[".yamllint",".yamllint.yml"],[".yaml",".yml"],["yamllint","-f","parsable","{file}"],"gcc","https://yamllint.readthedocs.io/"),c("markdownlint",["markdown"],["markdownlint"],[".markdownlint.json",".markdownlint.yaml"],[".md",".mdx"],["markdownlint","{file}"],"gcc","https://github.com/DavidAnson/markdownlint"),c("sqlfluff",["sql"],["sqlfluff"],[".sqlfluff","pyproject.toml"],[".sql"],["sqlfluff","lint","--format","sarif","{file}"],"sarif","https://docs.sqlfluff.com/"),c("hadolint",["dockerfile"],["hadolint"],[".hadolint.yaml"],["*"],["hadolint","--format","tty","{file}"],"gcc","https://github.com/hadolint/hadolint"),c("tflint",["terraform"],["tflint"],[".tflint.hcl"],[".tf"],["tflint","--format","compact"],"gcc","https://github.com/terraform-linters/tflint"),c("cmake-lint",["cmake"],["cmake-lint"],[".cmake-format.py","CMakeLists.txt"],[".cmake"],["cmake-lint","{file}"],"gcc","https://cmake-format.readthedocs.io/"),c("htmlhint",["html"],["htmlhint"],[".htmlhintrc"],[".html",".htm"],["htmlhint","--format","unix","{file}"],"gcc","https://htmlhint.com/"),c("jsonlint",["json"],["jsonlint"],["package.json"],[".json",".jsonc"],["jsonlint","-q","{file}"],"gcc","https://github.com/zaach/jsonlint"),c("taplo-check",["toml"],["taplo"],["taplo.toml"],[".toml"],["taplo","check","{file}"],"gcc","https://taplo.tamasfe.dev/"),c("xmllint",["xml"],["xmllint"],[".xmllintrc"],[".xml",".xsd",".xsl"],["xmllint","--noout","{file}"],"gcc","https://gnome.pages.gitlab.gnome.org/libxml2/xmllint.html")];function c(n,t,e,r,i,a,o,l,m,g){return{id:n,name:n,kind:"linter",languages:t,executables:e,configFiles:r,documentation:l,...g&&{dependencies:g},linter:{extensions:i,check:{command:a,successExitCodes:[0,1]},diagnostics:{format:o,...m&&{pattern:m}}}}}s(c,"recipe");var _={protocol:D,apiVersion:1,id:"lint",setup(n){for(let t of $)n.addToolRecipe(t);n.addSetupCheck({id:"effective-config",inspect:U}),n.addCheck({id:"config",title:"Linter",async run(t){try{let e=await f.fromDirectory(t.cwd,{environment:t.env}),r=W(e,t.files,t.cwd);return r.length===0?[{status:"skip",message:"No linter matches the inspected project files"}]:await Promise.all(r.map(async({entry:i,source:a})=>{let o=`${i.id} [${i.layer}] command ${JSON.stringify(i.config.check.command)}`,l=await K(k.join(k.dirname(a),".pi-agent-ide-doctor-")),m=k.join(l,k.basename(a));try{await X(a,m);let g=await p(i.config,{projectRoot:t.cwd,filePath:m,env:t.env});return g.ok?{status:"pass",message:`${o}: probe passed`,detail:i.sourcePath}:{status:"fail",message:`${o}: probe failed`,detail:g.failure??i.sourcePath}}catch(g){return{status:"fail",message:`${o}: ${g instanceof Error?g.message:String(g)}`,detail:i.sourcePath}}finally{await Q(l,{recursive:!0,force:!0})}}))}catch(e){return[{status:"fail",message:e instanceof Error?e.message:String(e)}]}}})}};async function U(n){try{let t=await f.fromDirectory(n.cwd,{environment:n.env}),e=[],r=new Map;for(let[i,a]of n.detectedLanguages){let o=a.map(l=>t.resolveEntry(l,n.cwd)).find(l=>l!==void 0);o!==void 0&&(e.push({kind:"linter",languageId:i,toolId:o.id}),await h(o.config.check,n.cwd,n.env)||r.set(o.id,{id:`linter-${o.id}-unavailable`,message:`Configured linter ${o.id} cannot run ${JSON.stringify(o.config.check.command)}`}))}return{selections:e,actions:[...r.values()]}}catch(t){return{actions:[{id:"linter-config-invalid",message:`Linter configuration cannot load: ${t instanceof Error?t.message:String(t)}`}]}}}s(U,"inspectLinterSetup");function W(n,t,e){let r=new Map;for(let i of t){let a=n.resolveEntry(i,e);a!==void 0&&!r.has(a.id)&&r.set(a.id,{entry:a,source:i})}return[...r.values()]}s(W,"applicableLinters");async function Y(n){let t,e,r=s(o=>((e===void 0||t!==o)&&(t=o,e=Z(o)),e),"registryFor"),i={kind:"linter",name:"pi-agent-ide-lint",priority:200,extensions:["*"],detect:s(async o=>(await r(o.cwd),!0),"detect"),async lint(o,l){let m=await r(l.cwd);return N(m).lint(o,l)}},a={protocol:w,apiVersion:3,id:"lint",setup(o){o.addTool(i),o.addDiagnosticSource({id:"lint",async diagnose(l,m){let g=await r(m.cwd);m.signal.throwIfAborted();let C=g.resolve(l,m.cwd);if(!C)return{status:"unavailable",diagnostics:[],reason:"No linter configured for this file"};let y=await p(C,{projectRoot:m.cwd,filePath:l,signal:m.signal});return!y.ok&&y.diagnostics.length===0?{status:"unavailable",diagnostics:[],reason:y.failure??"Lint check failed"}:{status:"ready",diagnostics:y.diagnostics}}})}};await Promise.all([L(n,a),E(n,_)])}s(Y,"registerLint");async function Z(n){let t=process.env.PI_AGENT_IDE_CONFIG_DIR??n;return f.fromDirectory(t)}s(Z,"loadRegistry");export{Y as a};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{a as N,b as O}from"./chunk-QNZVPFSP.js";import{j as b,k as g}from"./chunk-5A25RATC.js";import"./chunk-2SKAED2I.js";import"./chunk-KINKBPPX.js";import{a as w}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import h from"node:path";import{readdir as $}from"node:fs/promises";import U from"node:path";async function E(e){let n=[],t=await $(e,{withFileTypes:!0});for(let i of t){let r=U.join(e,i.name);i.isDirectory()?n.push(...await E(r)):(i.isFile()||i.isSymbolicLink())&&n.push(r)}return n}s(E,"collectFiles");import{readFile as Y}from"node:fs/promises";var k=256*1024;async function T(e){let n=await Y(e);if(n.byteLength>k)throw new Error(`File exceeds the ${k}-byte AST outline limit: ${e}`);if(n.includes(0))throw new Error(`File appears to be binary and cannot be read as text: ${e}`);let t=n.toString("utf8").replaceAll(`\r
|
|
2
|
+
`,`
|
|
3
|
+
`),i=t.endsWith(`
|
|
4
|
+
`)?t.slice(0,-1):t,r=i.length===0?[]:i.split(`
|
|
5
|
+
`);return{content:t,lines:r}}s(T,"readTextFile");var K=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs",".py",".rs",".c",".cpp",".cxx",".h",".hpp",".json",".jsonc",".yaml",".yml",".toml"]),H=new Set([".json",".jsonc",".yaml",".yml",".toml"]),R=new Set(["class_declaration","class_definition","class_specifier","enum_declaration","enum_definition","enum_item","enum_specifier","export_statement","function_declaration","function_definition","function_item","impl_item","interface_declaration","lexical_declaration","namespace_definition","mod_item","public_field_definition","method_definition","method_signature","property_signature","field_declaration","struct_item","struct_specifier","trait_item","type_alias_declaration","type_item","variable_declaration","assignment"]),X=new Set(["module","program","source_file"]),q=new Set(["import_declaration","import_from_statement","import_statement","use_declaration"]),A=new Set(["arrow_function","function_declaration","function_definition","function_item","function_expression","method_definition"]),Z=new Set(["public_field_definition","variable_declarator","assignment"]),F=new Set(["field_identifier","identifier","property_identifier","shorthand_property_identifier_pattern","type_identifier"]);function I(e){return K.has(h.extname(e).toLowerCase())}s(I,"isSupportedOutlinePath");var _={failureLabel:"PEEK_FAILED",emptyReason:"no entries to peek.",recovery:['Call peek with { peers: [{ path: "path/to/file.ts" }, ...] }.']},z={failureLabel:"AST_OUTLINE_FAILED",emptyReason:"no AST outline was produced."};function Ee(e){return g([e],z)}s(Ee,"formatAstOutline");var v=class{static{s(this,"AstOutlineManager")}fallbackScopeManager=new O;async readFileOutline(n,t){let i=W(n,t),r=h.relative(t,i)||i;if(!I(i))throw new Error(`AST outline is not supported for ${r}.`);let o=await T(i),c=await N(i,t,o.lines);if(!c)throw new Error(`No AST parser is available for ${r}.`);return await this.createSourceViewBlock(c.rootNode,i,r,t,o.lines,o.content,h.extname(i).toLowerCase())}async formatFile(n,t){let i=W(n,t),r=h.relative(t,i)||i;if(!I(i)){let o=await T(i);return g([G(i,r,o.lines)],_)}try{return g([await this.readFileOutline(i,t)],_)}catch(o){let c=o instanceof Error?o.message:String(o);return g([M(r,c)],_)}}async formatSymbol(n,t){let r=(await E(t)).filter(o=>I(o)).sort();for(let o of r){let c;try{c=await T(o)}catch{continue}let l;try{l=await N(o,t,c.lines)}catch{continue}if(!l)continue;let d=ee(l.rootNode,n);if(!d)continue;let a=h.relative(t,o)||o,u=await this.createSourceViewBlock(d,o,a,t,c.lines,c.content,h.extname(o).toLowerCase(),n,[`defined in: ${a}:${d.startPosition.row+1}`]);return g([u],_)}return g([M("",`symbol not found: ${n}`,"PEEK_NOT_FOUND")],_)}async createSourceViewBlock(n,t,i,r,o,c,l,d,a){let u=re(n,c,l),p=await J(this.fallbackScopeManager,t,r,o),S=Q(p),x=u.map(y=>{let f=y.sourceLine,m=f===void 0?void 0:o[f-1]??"",C=(f===void 0?void 0:S.get(f))?.map(D=>` <!-- ${D} -->`).join("")??"";return b({content:y.content,...!(f===void 0||m===void 0)&&{sourceLine:{source:t,lineNumber:f,content:m}},...C.length>0&&{suffix:C}})});return{path:i,...d!==void 0&&{heading:d},...a!==void 0&&{details:a},startLine:n.startPosition.row+1,endLine:n.endPosition.row+1,totalLines:o.length,renderedLines:x}}};function G(e,n,t){return{path:n,startLine:t.length>0?1:0,endLine:t.length,totalLines:t.length,renderedLines:t.map((i,r)=>b({content:i,sourceLine:{source:e,lineNumber:r+1,content:i}}))}}s(G,"formatUnsupportedSourceBlock");function M(e,n,t="PEEK_FAILED"){return{path:e,startLine:0,endLine:0,totalLines:0,renderedLines:[],status:"failed",error:n,code:t}}s(M,"failedSourceViewBlock");function J(e,n,t,i){return e.getDocumentScopes(n,t,i)}s(J,"getOutlineScopes");function Q(e){let n=new Map;for(let t of e){let i=n.get(t.startLine)??[];i.push(t.beginAnchor.value),n.set(t.startLine,i);let r=n.get(t.endLine)??[];r.push(t.endScopeAnchor.value),n.set(t.endLine,r)}return n}s(Q,"buildScopeMarkers");function W(e,n){return e.startsWith("file://")?decodeURIComponent(e.slice(7)):h.isAbsolute(e)?e:h.resolve(n,e)}s(W,"resolvePath");function ee(e,n){let t,i=s(r=>{if(!t){if(R.has(r.type)&&te(r)===n){t=ne(r);return}for(let o of r.namedChildren)i(o)}},"visit");return i(e),t}s(ee,"findSymbol");function te(e){let n=e.childForFieldName("name");if(n&&F.has(n.type))return n.text;for(let t of e.namedChildren)if(F.has(t.type))return t.text;if(e.type==="lexical_declaration"||e.type==="variable_declaration")return e.namedChildren.find(r=>r.type==="variable_declarator")?.childForFieldName("name")?.text;if(e.type==="function_definition"){let t=e.childForFieldName("declarator");return t?B(t):void 0}}s(te,"getNodeName");function B(e){if(F.has(e.type))return e.text;for(let n of e.namedChildren){let t=B(n);if(t)return t}}s(B,"findNestedName");function ne(e){let n=e.parent;return n&&(n.type==="export_statement"||n.type==="decorated_definition"||n.type==="template_declaration")?n:e}s(ne,"unwrapDeclaration");function re(e,n,t){let i=[];H.has(t)?j(e,t,i):V(e,t,i);let r=ie(n,e.startIndex),o=oe(n,e.endIndex),c=i.filter(a=>a.start>=r&&a.end<=o).sort((a,u)=>u.start-a.start),l=se(n,r,o);for(let a of c){let u=a.start-r,p=a.end-r,S=ae(a);l.splice(u,p-u,...S)}for(;l.length>0&&/\s/u.test(w(l.at(-1)).char);)l.pop();let d=[[]];for(let a of l)a.char===`
|
|
6
|
+
`?d.push([]):w(d.at(-1)).push(a);return d.map(a=>{let u=[...new Set(a.flatMap(p=>p.sourceLine===void 0?[]:[p.sourceLine]))];return{content:a.map(p=>p.char).join(""),...u.length===1&&{sourceLine:u[0]}}})}s(re,"renderNodeLines");function ie(e,n){return e.lastIndexOf(`
|
|
7
|
+
`,Math.max(0,n-1))+1}s(ie,"lineStartAt");function oe(e,n){let t=e.indexOf(`
|
|
8
|
+
`,n);return t===-1?e.length:t}s(oe,"lineEndAt");function se(e,n,t){let i=e.slice(0,n).split(`
|
|
9
|
+
`).length,r=[];for(let o of e.slice(n,t))r.push({char:o,sourceLine:i}),o===`
|
|
10
|
+
`&&(i+=1);return r}s(se,"mapSourceRange");function ae(e){let n=e.lineSourceLines??[],t=0,i=[];for(let r=0;r<e.text.length;r+=1){let o=w(e.text[r]),c=n[t];i.push(c===void 0?{char:o}:{char:o,sourceLine:c}),o===`
|
|
11
|
+
`&&(t+=1)}return i}s(ae,"mapReplacement");function j(e,n,t){for(let i of e.namedChildren){if(ce(i,n)){le(i)||t.push({start:i.startIndex,end:i.endIndex,text:"\u2026",lineSourceLines:[i.startPosition.row+1]});continue}j(i,n,t)}}s(j,"collectDataReplacements");function ce(e,n){return(n===".json"||n===".jsonc"?["string","number","true","false","null"]:n===".yaml"||n===".yml"?["string_scalar","integer_scalar","float_scalar","boolean_scalar","null_scalar","block_scalar"]:["string","integer","float","boolean","date_time","offset_date_time","local_date_time","local_date","local_time"]).includes(e.type)}s(ce,"isDataScalar");function le(e){let n=e.parent;for(;n&&!n.type.endsWith("pair")&&n.type!=="pair"&&n.type!=="table";)n=n.parent;let t=n?.namedChildren[0];return t!==void 0&&t.startIndex<=e.startIndex&&t.endIndex>=e.endIndex}s(le,"isDataKey");function V(e,n,t,i=!1){if(i&&!de(e)){t.push({start:e.startIndex,end:e.endIndex,text:"\u2026",lineSourceLines:[e.startPosition.row+1]});return}if(A.has(e.type)){let r=ue(e);if(r){let o=pe(r,n);t.push({start:r.startIndex,end:r.endIndex,text:o.text,lineSourceLines:o.lineSourceLines});return}}if(Z.has(e.type)){let r=e.childForFieldName("value");if(r&&!A.has(r.type)){t.push({start:r.startIndex,end:r.endIndex,text:"\u2026",lineSourceLines:[r.startPosition.row+1]});return}}for(let r of e.namedChildren)V(r,n,t,X.has(e.type))}s(V,"collectReplacements");function de(e){return R.has(e.type)||q.has(e.type)||e.type==="comment"||e.type.startsWith("preproc")}s(de,"isTopLevelInterfaceNode");function ue(e){let n=e.childForFieldName("body");return n||e.namedChildren.find(t=>t.type==="block"||t.type==="compound_statement"||t.type==="statement_block")}s(ue,"findBody");function pe(e,n){let t=e.startPosition.row+1,i=e.endPosition.row+1;if(n===".py")return{text:"...",lineSourceLines:[t]};let r=e.text.split(`
|
|
12
|
+
`),o=r[0]??"",c=r.at(-1)??"",l=o.indexOf("{"),d=c.lastIndexOf("}");if(l===-1||d===-1)return{text:"\u2026",lineSourceLines:[t]};if(r.length===1){let m=o.slice(l+1,d);return m.trim()===""?{text:e.text,lineSourceLines:[t]}:{text:o.slice(0,l+1)+P(m)+o.slice(d),lineSourceLines:[t]}}let a=o.slice(l+1),u=c.slice(0,d),p=r.slice(1,-1).some(m=>m.trim()!==""),S=a.trim()!=="",x=u.trim()!=="";if(!p&&!S&&!x)return{text:e.text,lineSourceLines:r.map((m,L)=>t+L)};let y=[],f=[];if(y.push(S?o.slice(0,l+1)+P(a):o),f.push(t),!S&&p){let m=r.slice(1,-1).find(L=>L.trim()!=="")?.match(/^\s*/u)?.[0]??"";y.push(`${m}\u2026`),f.push(void 0)}return y.push(x?P(u)+c.slice(d):c),f.push(i),{text:y.join(`
|
|
13
|
+
`),lineSourceLines:f}}s(pe,"renderBodyPlaceholder");function P(e){let n=/^\s*/u.exec(e)?.[0]??"",t=/\s*$/u.exec(e)?.[0]??"";return`${n}\u2026${t}`}s(P,"maskSegment");export{v as AstOutlineManager,Ee as formatAstOutline,I as isSupportedOutlinePath};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{e as le,f as ce,g as fe}from"./chunk-VSP2QQPQ.js";import{a as F,b as V,c as U,d as M,e as B,f as ue}from"./chunk-2ZMYT6ZC.js";import{a as oe,b as ie,c as se}from"./chunk-SSZB66C3.js";import{a as I,b as N,c as te,d as ne,g as re}from"./chunk-JASLOB2X.js";import{b as ae,e as de}from"./chunk-EW2KVKCN.js";import{m as J,o as Z,s as ee}from"./chunk-2SKAED2I.js";import{a as L}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import{Type as S}from"typebox";import{DEFAULT_MAX_BYTES as _e,DEFAULT_MAX_LINES as Ie,formatSize as j,truncateHead as Ne}from"@earendil-works/pi-coding-agent";var H=_e,W=Ie;async function D(e,t,r,n){let o=n?.originLine,i=e.content.length===1?e.content[0]:void 0;if(i?.type!=="text")return e;let d=Ne(i.text,{maxBytes:H,maxLines:W});if(d.truncated){let l=r===void 0?void 0:await r(i.text),c=d.firstLineExceedsLimit?Ve(i.text,e.details,t):Ue(d,e.details,t,o),p=l===void 0?c:Fe(c,l);return{...e,content:[{...i,text:pe(d.content,p)}],details:{...je(e.details,d),...l!==void 0&&{temporarySource:l}}}}let a=Be(e.details,t,o);return a===void 0?e:{...e,content:[{...i,text:pe(i.text,a)}]}}s(D,"limitReadOutput");function Fe(e,t){return`${e.slice(0,-1)} Full output: ${t}. Expires after 5 minutes of inactivity.]`}s(Fe,"appendTemporarySource");function Ve(e,t,r){let n=e.split(/\r\n|\r|\n/u,1)[0]??"",o=j(Buffer.byteLength(n,"utf8")),i=K(t,r);return`[${i===void 0?"First output line":`Line ${i}`} is ${o}, exceeds ${j(H)} limit. Use a source-specific tool to read this line in smaller byte ranges.]`}s(Ve,"oversizedFirstLineNotice");function Ue(e,t,r,n){let o=Me(e,t,r);if(o!==void 0&&o.endLine<o.totalLines){let d=e.truncatedBy==="bytes"?` (${j(e.maxBytes)} limit)`:"",a=ge(o.endLine+1,n);return`[Showing lines ${o.startLine}-${o.endLine} of ${o.totalLines}${d}. Use offset=${a} to continue.]`}let i=e.truncatedBy==="lines"?`${e.maxLines} line limit`:`${j(e.maxBytes)} limit`;return`[Output truncated: showing ${e.outputLines} of ${e.totalLines} rendered lines (${i}). Use a smaller line range to read this source.]`}s(Ue,"truncatedOutputNotice");function Me(e,t,r){let n=t.totalLines,o=K(t,r);if(n===void 0||n===0||o===void 0||e.outputLines===0)return;let d=(t.endLine===void 0||t.endLine<o?n:t.endLine)-o+1,a=Math.min(e.outputLines,d);return{startLine:o,endLine:o+a-1,totalLines:n}}s(Me,"shownSourceRange");function Be(e,t,r){if(t.limit===void 0||e.totalLines===void 0||e.totalLines===0)return;let n=K(e,t);if(n===void 0)return;let o=e.endLine===void 0||e.endLine<n?n:e.endLine+1;return o>e.totalLines?void 0:`[${e.totalLines-o+1} more lines in source. Use offset=${ge(o,r)} to continue.]`}s(Be,"explicitLimitNotice");function ge(e,t){return t===void 0?e:e-t+1}s(ge,"continuationOffset");function K(e,t){if(e.startLine!==void 0&&e.startLine>0)return e.startLine;if(e.totalLines===void 0||e.totalLines===0)return;let r=t.offset===void 0?1:Math.trunc(t.offset);return r<0?Math.max(1,e.totalLines+r+1):Math.max(1,r)}s(K,"sourceStartLine");function je(e,t){return{...e,...e.lines!==void 0&&{lines:e.lines.slice(0,t.outputLines)},truncation:t}}s(je,"truncatedDetails");function pe(e,t){return e.length===0?t:`${e}
|
|
2
|
+
|
|
3
|
+
${t}`}s(pe,"appendNotice");function Re(){return{id:"line-numbers",present(e){if(e.lines.length===0)return e;let t=Math.max(...e.lines.map(n=>String(n.lineNumber).length)),r=e.lines.map(n=>({...n,presentation:{...n.presentation,prefix:`${String(n.lineNumber).padStart(t)}|${n.presentation?.prefix??""}`,compactPrefix:n.presentation?.compactPrefix??`${String(n.lineNumber).padStart(t)} \u2502 `}}));return{...e,lines:r}}}}s(Re,"createLineNumberPresenter");function ye(e,t,r,n){if(!Ke(e))return{content:e,source:t,resolvedBy:r,preserveTruncatedOutput:n.preserveTruncatedOutput,textMode:n.textMode,contentKind:"other"};let o=e[0].text;return{content:e,source:t,resolvedBy:r,preserveTruncatedOutput:n.preserveTruncatedOutput,textMode:n.textMode,contentKind:"text",text:J(t,o)}}s(ye,"createReadState");function G(e,t,r){if(e.contentKind!=="text"){if(t.offset!==void 0||t.limit!==void 0)return h({code:"UNSUPPORTED_RANGE",source:e.source,resolverId:e.resolvedBy,message:"Line ranges require textual content"});let c=Ge(e.content);return{content:c.content,details:{...me(e),...c.unsupportedContentBlocks!==void 0&&{unsupportedContentBlocks:c.unsupportedContentBlocks}}}}let n=e.text.lines.length,o=qe(t,n,r?.originLine),i=e.text.lines.slice(o.startIndex,o.endIndex),d=e.textMode==="final"?He(i,o.endIndex<n):Z({...e.text,lines:i.map((c,p)=>({...c,lineEnding:p===i.length-1&&o.endIndex<n?"":c.lineEnding}))}),a=e.content[0];return{content:[{type:"text",text:d,...a.textSignature!==void 0&&{textSignature:a.textSignature}}],details:{...me(e),startLine:i[0]?.lineNumber??0,endLine:i.at(-1)?.lineNumber??0,totalLines:n,lines:i}}}s(G,"projectReadState");function He(e,t){return e.map((r,n)=>`${r.content}${n===e.length-1&&t?"":r.lineEnding}`).join("")}s(He,"renderFinalTextLines");function h(e){return{content:[{type:"text",text:`${e.code}: ${e.message}`}],details:{failure:e},isError:!0}}s(h,"failureResult");function me(e){return{source:e.source,resolvedBy:e.resolvedBy}}s(me,"readDetails");function Ge(e){let t=[],r=[];for(let[o,i]of e.entries()){if(i.type!=="custom"){t.push(i);continue}r.push({index:o,kind:i.kind}),t.push({type:"text",text:`[unsupported_content_block kind=${i.kind} index=${o}]`})}let n=r[0];return{content:t,...n!==void 0&&{unsupportedContentBlocks:[n,...r.slice(1)]}}}s(Ge,"projectAgentContent");function qe(e,t,r){let n=e.offset===void 0?1:Math.trunc(e.offset),o=We(n,t,r),i=e.limit===void 0?t:Math.max(0,Math.trunc(e.limit));return{startIndex:Math.min(t,o-1),endIndex:Math.min(t,o-1+i)}}s(qe,"resolveTextRange");function We(e,t,r){if(r===void 0)return e<0?Math.max(1,t+e+1):Math.max(1,e);let n=e<0?r+e:r+Math.max(1,e)-1;return Math.max(1,n)}s(We,"anchoredStartLine");function Ke(e){return e.length===1&&e[0].type==="text"}s(Ke,"isSingleTextContent");import{randomUUID as Ye}from"node:crypto";import{mkdir as ze,mkdtemp as Xe,readFile as Qe,rm as Je,unlink as he,writeFile as Ze}from"node:fs/promises";import{tmpdir as et}from"node:os";import ve from"node:path";var tt=5*6e4,q=class{static{s(this,"TempResourceStore")}resolver;#e=new Map;#i;#t;#s;#o=!1;#n;constructor(t={}){if(this.#i=t.parentDirectory??et(),this.#t=t.ttlMs??tt,!Number.isFinite(this.#t)||this.#t<=0)throw new TypeError("Temporary resource TTL must be a positive finite number");this.resolver={id:"temp",tryResolve:s(r=>Promise.resolve(this.#d(r)),"tryResolve")}}async save(t){if(this.#o)throw new Error("Temporary resource store is closed");let r=await this.#l(),n=Ye(),o=`temp:${n}`,i=ve.join(r,`${n}.txt`);return await Ze(i,t,{encoding:"utf8",flag:"wx"}),this.#e.set(o,{activeReads:0,filePath:i,lastUsedAt:Date.now()}),this.#r(),o}async dispose(){if(this.#o)return;this.#o=!0,this.#a(),this.#e.clear();let t=this.#s;t!==void 0&&await Je(await t,{recursive:!0,force:!0})}#d(t){if(!t.startsWith("temp:"))return{kind:"not-handled"};let r=this.#e.get(t);return r===void 0?{kind:"failed",error:new Error(`Temporary resource ${t} expired or does not exist`)}:r.activeReads===0&&r.lastUsedAt+this.#t<=Date.now()?(this.#e.delete(t),he(r.filePath).catch(()=>{}),this.#r(),{kind:"failed",error:new Error(`Temporary resource ${t} expired or does not exist`)}):{kind:"resolved",resource:{source:t,read:s(()=>this.#u(t),"read")}}}async#u(t){let r=this.#e.get(t);if(r===void 0)throw new Error(`Temporary resource ${t} expired or does not exist`);r.activeReads+=1,this.#r();try{return[{type:"text",text:await Qe(r.filePath,"utf8")}]}finally{r.activeReads-=1,r.lastUsedAt=Date.now(),this.#r()}}async#l(){return this.#s??=(async()=>(await ze(this.#i,{recursive:!0}),Xe(ve.join(this.#i,"pi-agent-read-"))))(),this.#s}#r(){if(this.#a(),this.#o)return;let t=Date.now(),r;for(let n of this.#e.values()){if(n.activeReads>0)continue;let o=n.lastUsedAt+this.#t;r=r===void 0?o:Math.min(r,o)}r!==void 0&&(this.#n=setTimeout(()=>{this.#n=void 0,this.#c().catch(()=>{this.#r()})},Math.max(0,r-t)),this.#n.unref())}async#c(){let t=Date.now(),r=[...this.#e].filter(([,n])=>n.activeReads===0&&n.lastUsedAt+this.#t<=t);await Promise.all(r.map(async([n,o])=>{await he(o.filePath).catch(i=>{if(!(i instanceof Error)||!("code"in i)||i.code!=="ENOENT")throw i}),this.#e.delete(n)})),this.#r()}#a(){this.#n!==void 0&&(clearTimeout(this.#n),this.#n=void 0)}};var nt=S.Object({path:S.Optional(S.String({description:"Complete source resource reference: a filesystem path, URL, protocol source, temporary resource, or typed SEARCH#... selection."})),offset:S.Optional(S.Number()),limit:S.Optional(S.Number()),views:S.Optional(S.Array(S.String()))}),rt=se({kind:"source"}),ot=["lines"];function it(){return[{view:"lines",presenter:Re()}]}s(it,"createBuiltinViewRegistrations");function Ee(e){let t=new q,r=[{resolver:t.resolver,preserveTruncatedOutput:!1,priority:Number.MIN_SAFE_INTEGER,order:0}],n=[],o=it().map((l,c)=>({pluginId:"core",registration:l,order:c})),i=[],d=[],a="read";return{tool:{name:a,label:a,promptSnippet:"Read files, URLs, temporary resources, search selections, and protocol sources, with optional views projected onto text content",description:`Resolve a supported source into agent-native content. Text output is raw by default; pass optional views (string array) to add annotations: "lines" for a line-number column, or plugin views such as "anchors" (LINE#HASH), "ast", "diagnostics", and "changes" when their extensions are installed. Text output is truncated to ${W} lines or ${H/1024}KB, whichever is reached first. Use offset/limit to read a line range and continue large sources; a negative offset reads from the end. A \`path#anchor\` suffix (for example \`src/x.ts#function main\`) starts reading at the anchor's line: offset/limit then count from that line while output keeps absolute line numbers. For anchored reads, omitted offset, offset 0, and offset 1 are equivalent; positive offsets greater than one count forward and negative offsets count upward.`,get promptGuidelines(){return["Use read to examine files and other supported sources instead of cat, sed, head, tail, or similar shell commands.",'You can use read with `views: ["lines"]` to add a line-number column.',"You can use read with `offset` and `limit` to inspect a line range or continue a large source, and with a negative `offset` to read from the end.","You can combine compatible read views in one request.","When a read result is truncated and provides a `temp:` source, you can use read with that source to continue reading the saved full output.",...e?.()??[]]},parameters:nt,renderCall:ie,renderResult(l,c,p,f){let y=l.details.resolvedBy;return((y===void 0?void 0:r.find(({resolver:g})=>g.id===y)?.renderResult)??rt)(l,c,p,f)},async execute(l,c,p,f,y){let x={cwd:y.cwd,...p!==void 0&&{signal:p}};return xe(c,x,r,n,o,t,i,d)}},execute(l,c){return xe(l,c,r,n,o,t,i,d)},registerContributions(l,c){let p=[...c.resolvers??[]],f=[...c.targetResolvers??[]],y=[...c.handlers??[]],x=[...c.views??[]],g=[...c.fragments??[]];vt(l,p,y,r,n),xt(l,g,i);let v=new Set(d.map(({resolver:u})=>u.id));for(let u of f){if(!F(u))throw new TypeError(`Plugin ${l} provided an invalid text target resolver`);if(v.has(u.resolver.id))throw new Error(`Text target resolver ${u.resolver.id} is already registered`);v.add(u.resolver.id)}let R=new Set(o.map(({registration:u})=>u.view)),C=new Set(o.map(({registration:u})=>`${u.view}/${u.presenter.id}`));for(let u of x){if(!M(u))throw new TypeError(`Plugin ${l} provided an invalid view registration`);let E=`${u.view}/${u.presenter.id}`;if(C.has(E))throw new Error(`View ${u.view} already has a presenter ${u.presenter.id}`);R.add(u.view),C.add(E)}for(let u of p)r.push({resolver:u.resolver,...u.renderResult!==void 0&&{renderResult:u.renderResult},priority:u.priority??0,preserveTruncatedOutput:u.preserveTruncatedOutput??!1,order:r.length});for(let u of f)d.push({resolver:u.resolver,priority:u.priority??0,order:d.length});for(let u of y)n.push({pluginId:l,registration:u});for(let u of x)o.push({pluginId:l,registration:u,order:o.length});for(let u of g)i.push({registration:u,priority:u.priority??0,order:i.length})},dispose(){return t.dispose()}}}s(Ee,"createReadTool");async function xe(e,t,r,n,o,i,d,a){let l=[...r].sort((m,P)=>m.priority-P.priority||m.order-P.order),c=[...n],p=[...o].sort((m,P)=>(m.registration.priority??0)-(P.registration.priority??0)||m.order-P.order),f=[...d].sort((m,P)=>m.priority-P.priority||m.order-P.order),y=[...a].sort((m,P)=>m.priority-P.priority||m.order-P.order),x=new Set(e.views??[]),g=new Set([...ot,...p.map(({registration:m})=>m.view)]),v=[...x].filter(m=>!g.has(m));if(e.path!==void 0&&y.length>0){let m=await dt(e,t,y,l,c,p,x,v);if(m!==void 0)return m}let R={request:{...e},resolverContext:t};if(!R.request.path?.startsWith("temp:")){let m=await Le(R,c);if(m.kind==="return")return b(await D(m.result,R.request),v);R=m.context}let C=R.request.path;if(C===void 0||C.length===0)return h({code:"INVALID_REQUEST",message:"No source was provided"});let u=await Y(R,l),E;if(u.kind==="return"&&u.result.isError===!0&&at(u.result)&&!C.startsWith("temp:")){let m=ut(C);if(m!==void 0){let P={result:u,pipeline:R},X={...R,request:{...R.request,path:m.source}},Q=await Y(X,l);Q.kind==="continue"?(u=Q,R=X,E=m.fragment):u=P.result}}if(u.kind==="return")return D(u.result,R.request);R=u.context;let T;if(E!==void 0){let m=await lt(R,f,E);if(typeof m!="number")return m;T=m}if(R.state?.textMode==="final")return b(await D(G(R.state,R.request,{originLine:T}),R.request,void 0,{originLine:T}),v);let A=await Se(R,c);if(A.kind==="return")return b(await D(A.result,R.request,void 0,{originLine:T}),v);R=A.context,R=await be(R,p,x);let k=G(L(R.state),R.request,{originLine:T});R={...R,result:k};let $=await Ce(R,c),O=$.kind==="return"?$.result:L($.context.result),w=R.request.limit===void 0&&R.state?.preserveTruncatedOutput===!0?m=>i.save(m):void 0;return b(await D(O,R.request,w,{originLine:T}),v)}s(xe,"executeRead");var st=new Set(["INVALID_RESOLVER_RESULT","NO_RESOLVER","READ_FAILED","RESOLVE_FAILED"]);function at(e){let t=e.details.failure?.code;return t!==void 0&&st.has(t)}s(at,"isRetryableFailure");async function dt(e,t,r,n,o,i,d,a){for(let{resolver:l}of r){let c;try{c=await l.tryResolve(e.path??"",t)}catch(g){return h({code:"RESOLVE_FAILED",source:e.path,message:_(`Text target resolver ${l.id} failed`,g),cause:g})}if(!ee(c))return h({code:"INVALID_RESOLVER_RESULT",source:e.path,message:`Text target resolver ${l.id} returned an invalid result`,cause:c});let p=c;if(p.kind==="not-handled")continue;if(p.kind==="rejected")return h({code:"RESOLVE_FAILED",source:e.path,message:p.rejection.reason});if(p.kind==="failed")return h({code:"RESOLVE_FAILED",source:e.path,message:p.error instanceof Error?p.error.message:String(p.error)});if(p.targets.length===0)return h({code:"RESOLVE_FAILED",source:e.path,message:"Text target resolver returned no targets"});let f=[],y;for(let g of p.targets){let v=g.ranges??[{start:{lineNumber:1,column:0},end:{lineNumber:1,column:1}}];for(let R of v){let C=Math.max(1,R.end.lineNumber-R.start.lineNumber),u={request:{...e,path:g.source,limit:e.limit??C},resolverContext:t};if(!g.source.startsWith("temp:")){let w=await Le(u,o);if(w.kind==="return"){if(w.result.isError===!0)return b(w.result,a);for(let m of w.result.content)m.type==="text"&&f.push(m.text);y??=w.result.details;continue}u=w.context}let E=await Y(u,n);if(E.kind==="return")return b(E.result,a);let T=await Se(E.context,o);if(T.kind==="return"){if(T.result.isError===!0)return b(T.result,a);for(let w of T.result.content)w.type==="text"&&f.push(w.text);y??=T.result.details;continue}let A=await be(T.context,i,d),k=G(L(A.state),A.request,{originLine:R.start.lineNumber}),$=await Ce({...A,result:k},o);if(k.isError===!0)return b(k,a);let O=$.kind==="return"?$.result:L($.context.result);if(O.isError===!0)return b(O,a);for(let w of O.content)w.type==="text"&&f.push(w.text);y??=O.details}}let x={content:[{type:"text",text:f.join(`
|
|
4
|
+
`)}],details:y??{source:e.path}};return b(await D(x,{path:e.path,views:e.views}),a)}}s(dt,"resolveTextTargets");var we="#";function ut(e){let t=e.indexOf(we);if(!(t<=0||t===e.length-1))return{source:e.slice(0,t),fragment:e.slice(t+we.length)}}s(ut,"splitAnchoredSource");async function lt(e,t,r){let n=L(e.state);if(n.contentKind!=="text")return h({code:"UNSUPPORTED_RANGE",source:n.source,resolverId:n.resolvedBy,message:"Anchored reads require textual content"});if(t.length===0)return h({code:"NO_FRAGMENT_RESOLVER",source:n.source,message:`No fragment resolver is registered for anchor "${r}"`});for(let{registration:o}of t){let i;try{i=await o.resolve({source:n.source,fragment:r,text:n.text,cwd:e.resolverContext.cwd,...e.resolverContext.signal!==void 0&&{signal:e.resolverContext.signal}})}catch(d){return h({code:"FRAGMENT_FAILED",source:n.source,resolverId:o.id,message:_(`Fragment resolver ${o.id} failed`,d),cause:d})}if(!ue(i))return h({code:"INVALID_RESOLVER_RESULT",source:n.source,resolverId:o.id,message:`Fragment resolver ${o.id} returned an invalid result`,cause:i});if(i.kind!=="not-handled")return i.kind==="failed"?h({code:"FRAGMENT_FAILED",source:n.source,resolverId:o.id,message:i.message}):!Number.isInteger(i.originLine)||i.originLine<1||i.originLine>n.text.lines.length?h({code:"INVALID_RESOLVER_RESULT",source:n.source,resolverId:o.id,message:`Fragment resolver ${o.id} returned out-of-range origin line ${i.originLine}`}):i.originLine}return h({code:"NO_FRAGMENT_RESOLVER",source:n.source,message:`No fragment resolver handled anchor "${r}"`})}s(lt,"resolveAnchoredOrigin");async function Y(e,t){let r=L(e.request.path),n=e.resolverContext;for(let i of t){let{resolver:d}=i,a;try{a=await d.tryResolve(r,n)}catch(p){return{kind:"return",result:h({code:"RESOLVE_FAILED",source:r,resolverId:d.id,message:_(`Resolver ${d.id} failed`,p),cause:p})}}if(!de(a))return{kind:"return",result:h({code:"INVALID_RESOLVER_RESULT",source:r,resolverId:d.id,message:`Resolver ${d.id} returned an invalid result`,cause:a})};if(a.kind==="not-handled")continue;if(a.kind==="failed")return{kind:"return",result:h({code:"RESOLVE_FAILED",source:r,resolverId:d.id,message:_(`Resolver ${d.id} failed`,a.error),cause:a.error})};let l=a.resource;if(l.read===void 0)return{kind:"return",result:h({code:"UNSUPPORTED_CAPABILITY",source:l.source,resolverId:d.id,message:`Resource ${l.source} does not support reading`})};let c;try{c=await l.read({...n.signal!==void 0&&{signal:n.signal}})}catch(p){return{kind:"return",result:h({code:"READ_FAILED",source:l.source,resolverId:d.id,message:_(`Unable to read ${l.source}`,p),cause:p})}}return ae(c)?{kind:"continue",context:{...e,state:ye(c,l.source,d.id,{preserveTruncatedOutput:i.preserveTruncatedOutput,textMode:d.id==="temp"?"final":"normal"})}}:{kind:"return",result:h({code:"INVALID_RESOURCE_CONTENT",source:l.source,resolverId:d.id,message:`Resource ${l.source} returned invalid content`,cause:c})}}let o=`No resolver handled ${r}`;return{kind:"return",result:le(h({code:"NO_RESOLVER",source:r,message:o}),o)}}s(Y,"resolveSource");async function Le(e,t){let r=e;for(let n of t){if(n.registration.stage!=="pre-read")continue;let o=await z(n.registration.handler,r,n.pluginId,"pre-read");if(o.kind==="return")return o;r=o.context}return{kind:"continue",context:r}}s(Le,"runPreReadHandlers");async function Se(e,t){let r=e.state,n=r===void 0?[]:t.filter(i=>i.registration.stage==="read"&&ht(i.registration,r)),o=e;for(let i of n){let d=i.registration;if(d.stage!=="read")continue;let a=await z(d.handler,o,i.pluginId,"read");if(a.kind==="return")return a;o=a.context}return{kind:"continue",context:o}}s(Se,"runReadHandlers");async function be(e,t,r){let n=e.state;if(n?.contentKind!=="text"||r.size===0)return e;let o=n.text,i={purpose:"read",source:n.source,cwd:e.resolverContext.cwd,resolvedBy:n.resolvedBy,...e.resolverContext.signal!==void 0&&{signal:e.resolverContext.signal}},d=t.filter(({registration:f})=>r.has(f.view)),a=new Set(d.flatMap(({registration:f})=>f.includes??[])),l=d.filter(({registration:f})=>!a.has(f.view)),c=await Promise.all(l.map(async({registration:f})=>({presenterId:f.presenter.id,document:await f.presenter.present(o,i)}))),p=ct(o,c);return{...e,state:{...n,text:p}}}s(be,"runTextPresenters");function b(e,t){if(t.length===0)return e;let r=`note: ignored unknown views: ${t.join(", ")}`,n=e.content[0],o=n?.type==="text"?[{...n,text:`${r}
|
|
5
|
+
${n.text}`}]:[...e.content];return{...e,content:o,details:{...e.details,ignoredViews:t}}}s(b,"withIgnoredViews");function ct(e,t){let r=e.lines;for(let n of t)ft(e,n),r=r.map((o,i)=>pt(L(e.lines[i]),o,L(n.document.lines[i])));return r===e.lines?e:{...e,lines:r}}s(ct,"mergeViewContributions");function ft(e,t){let r=t.document;if(r.source!==e.source||r.content!==e.content||r.lines.length!==e.lines.length)throw new Error(`Text presenter ${t.presenterId} changed canonical text`);for(let[n,o]of r.lines.entries()){let i=L(e.lines[n]);if(o.lineNumber!==i.lineNumber||o.content!==i.content||o.lineEnding!==i.lineEnding)throw new Error(`Text presenter ${t.presenterId} changed canonical text`)}}s(ft,"assertPresentationOnly");function pt(e,t,r){let n=gt(e.presentation,t.presentation,r.presentation),o=yt(e.metadata,t.metadata,r.metadata);return n===t.presentation&&o===t.metadata?t:{...t,...n!==void 0&&{presentation:n},...o!==void 0&&{metadata:o}}}s(pt,"mergePresentedLine");function gt(e,t,r){if(r===e)return t;let n=Te(e?.prefix,t?.prefix,r?.prefix),o=Te(e?.suffix,t?.suffix,r?.suffix),i=Pe(e?.before,t?.before,r?.before),d=Pe(e?.after,t?.after,r?.after),a=r?.marker===e?.marker?t?.marker:r?.marker;return n===t?.prefix&&o===t?.suffix&&i===t?.before&&d===t?.after&&a===t?.marker?t:{...t,...n!==void 0&&{prefix:n},...o!==void 0&&{suffix:o},...i!==void 0&&{before:i},...d!==void 0&&{after:d},...a!==void 0&&{marker:a}}}s(gt,"mergeLinePresentation");function Te(e,t,r){if(r===e)return t;let n=e??"",o=t??"",i=r??"";return n.length>0&&i.startsWith(n)?`${o}${i.slice(n.length)}`:n.length>0&&i.endsWith(n)?`${i.slice(0,-n.length)}${o}`:`${o}${i}`}s(Te,"mergePresentedText");function Pe(e,t,r){if(r===e)return t;let n=e??[],o=t??[],i=r??[];return Rt(i,n)?[...o,...i.slice(n.length)]:mt(i,n)?[...i.slice(0,i.length-n.length),...o]:[...o,...i]}s(Pe,"mergePresentedRows");function Rt(e,t){return t.length>0&&t.length<=e.length&&t.every((r,n)=>e[n]===r)}s(Rt,"startsWithRows");function mt(e,t){let r=e.length-t.length;return t.length>0&&r>=0&&t.every((n,o)=>e[r+o]===n)}s(mt,"endsWithRows");function yt(e,t,r){if(r===e||r===void 0)return t;let n=Object.fromEntries(Object.entries(r).filter(([o,i])=>e?.[o]!==i));return Object.keys(n).length===0?t:{...t,...n}}s(yt,"mergeLineMetadata");async function Ce(e,t){let r=e;for(let n of t){if(n.registration.stage!=="post-read")continue;let o=await z(n.registration.handler,r,n.pluginId,"post-read");if(o.kind==="return")return o;r=o.context}return{kind:"continue",context:r}}s(Ce,"runPostReadHandlers");async function z(e,t,r,n){try{return await e(t)}catch(o){return{kind:"return",result:h({code:"PIPELINE_FAILED",...t.state?.source===void 0?t.result?.details.source===void 0?{}:{source:t.result.details.source}:{source:t.state.source},pluginId:r,stage:n,message:`Plugin ${r} failed during ${n}`,cause:o})}}}s(z,"invokeHandler");function ht(e,t){return(e.when.resolvedBy==="any"||e.when.resolvedBy===t.resolvedBy)&&(e.when.contentKind==="any"||e.when.contentKind===t.contentKind)}s(ht,"matchesReadState");function vt(e,t,r,n,o){let i=new Set(n.map(({resolver:a})=>a.id));for(let a of t){if(!V(a))throw new TypeError(`Plugin ${e} provided an invalid resource resolver`);if(i.has(a.resolver.id))throw new Error(`Resource resolver ${a.resolver.id} is already registered`);i.add(a.resolver.id)}let d=new Set(o.filter(a=>a.pluginId===e).map(a=>a.registration.stage));for(let a of r){if(!U(a))throw new TypeError(`Plugin ${e} provided an invalid read handler`);if(d.has(a.stage))throw new Error(`Plugin ${e} already handles ${a.stage}`);d.add(a.stage)}}s(vt,"validateContributions");function xt(e,t,r){let n=new Set(r.map(({registration:o})=>o.id));for(let o of t){if(!B(o))throw new TypeError(`Plugin ${e} provided an invalid fragment resolver`);if(n.has(o.id))throw new Error(`Fragment resolver ${o.id} is already registered`);n.add(o.id)}}s(xt,"validateFragmentRegistrations");function _(e,t){return!(t instanceof Error)||t.message.length===0?e:`${e}: ${t.message}`}s(_,"appendErrorMessage");function $e(){let e=new Set,t=new Map,r=Ee(()=>Pt(t)),n=Promise.resolve();return{read:r,registerPlugin(o){let i=wt(o);if(i!==void 0)return Promise.reject(i);let d=t.get(o.id);if(d?.plugin===o)return d.ready;if(d!==void 0)return Promise.reject(new Error(`Plugin ${o.id} is already registered`));let a={status:"pending"},l=[],c=[],p=Tt(o.id,r,c,l),f=n.then(async()=>{try{await o.setup(p.api),p.commit(),a.status="active";return}catch(x){throw p.close(),x}}),y={lifecycle:a,plugin:o,promptGuidelines:c,promptContributions:l,ready:f};return t.set(o.id,y),e.add(f),n=f.catch(()=>{}),f.then(()=>{e.delete(f)},()=>{e.delete(f),t.get(o.id)===y&&t.delete(o.id)}),f},renderPluginPromptGuideline:s(()=>Et(t),"renderPluginPromptGuideline"),async waitForPendingPlugins(){await Promise.all(e)}}}s($e,"createReadCore");function wt(e){if(e.protocol!==I)return new Error(`Plugin ${e.id} uses an unsupported protocol`);if(e.apiVersion!==N)return new Error(`Plugin ${e.id} uses an unsupported API version`);if(e.id.trim().length===0)return new Error("Plugin ID must not be empty")}s(wt,"getPluginValidationError");function Tt(e,t,r,n){let o=[],i=[],d=[],a=[],l=[],c=[],p=[],f="setup",y=s(()=>{if(f==="closed")throw new Error(`Plugin ${e} API is closed`)},"assertAvailable");return{api:{read(g,v){return y(),t.execute(g,v)},addResolver(g){if(y(),!V(g))throw new TypeError(`Plugin ${e} provided an invalid resource resolver`);if(f==="setup"){d.push(g);return}t.registerContributions(e,{resolvers:[g]})},addTargetResolver(g){if(y(),!F(g))throw new TypeError(`Plugin ${e} provided an invalid text target resolver`);if(f==="setup"){a.push(g);return}t.registerContributions(e,{targetResolvers:[g]})},addHandler(g){if(y(),!U(g))throw new TypeError(`Plugin ${e} provided an invalid read handler`);if(f==="setup"){l.push(g);return}t.registerContributions(e,{handlers:[g]})},addView(g){if(y(),!M(g))throw new TypeError(`Plugin ${e} provided an invalid view registration`);if(f==="setup"){c.push(g);return}t.registerContributions(e,{views:[g]})},addFragmentResolver(g){if(y(),!B(g))throw new TypeError(`Plugin ${e} provided an invalid fragment resolver`);if(f==="setup"){p.push(g);return}t.registerContributions(e,{fragments:[g]})},describe(g){if(y(),o.length>0||n.length>0)throw new Error(`Plugin ${e} provides more than one description`);let v=Ae(g);if(f==="setup"){o.push(v);return}n.push(v)},addPromptGuideline(g){y();let v=Ae(g);if(f==="setup"){i.push(v);return}r.push(v)}},close(){f="closed"},commit(){if(f!=="setup")throw new Error(`Plugin ${e} setup contributions cannot be committed`);t.registerContributions(e,{resolvers:d,targetResolvers:a,handlers:l,views:c,fragments:p}),n.push(...o),r.push(...i),f="active"}}}s(Tt,"createPluginContributionController");function Pt(e){let t=[];for(let r of e.values())if(r.lifecycle.status==="active")for(let n of r.promptGuidelines){let o=De(n);o!==void 0&&t.push(o)}return t}s(Pt,"renderPromptGuidelines");function Et(e){let t=[];for(let r of e.values()){if(r.lifecycle.status!=="active")continue;let n=r.promptContributions[0];if(n===void 0)continue;let o=De(n);o!==void 0&&t.push(Lt(r.plugin.id,o))}return t.length===0?void 0:St(["Read supports these installed protocols:",...t].join(`
|
|
6
|
+
`))}s(Et,"renderPluginPromptGuideline");function Ae(e){if(typeof e=="string")return Oe(e);if(typeof e=="function")return e;throw new TypeError("Read plugin prompt description must be a string or callback")}s(Ae,"normalizeDescriptionSource");function De(e){if(typeof e=="string")return e;let t=e();return t===void 0?void 0:Oe(t)}s(De,"renderDescriptionSource");function Oe(e){if(typeof e!="string")throw new TypeError("Read plugin prompt description must be a string");let t=e.replaceAll(`\r
|
|
7
|
+
`,`
|
|
8
|
+
`).replaceAll("\r",`
|
|
9
|
+
`).split(`
|
|
10
|
+
`).map(n=>n.trimEnd());for(;t[0]?.trim().length===0;)t.shift();for(;t.at(-1)?.trim().length===0;)t.pop();let r=t.join(`
|
|
11
|
+
`);if(r.trim().length===0)throw new Error("Read plugin prompt description is empty");return r}s(Oe,"normalizeDescription");function Lt(e,t){let[r,...n]=t.split(`
|
|
12
|
+
`);return[`- \`${bt(e)}\` \u2014 ${r??""}`,...n.map(o=>` ${o}`)].join(`
|
|
13
|
+
`)}s(Lt,"renderPromptEntry");function St(e){let[t,...r]=e.split(`
|
|
14
|
+
`);return[t??"",...r.map(n=>n.length===0?n:` ${n}`)].join(`
|
|
15
|
+
`)}s(St,"indentGuidelineContinuation");function bt(e){return e.replaceAll("`","\\`")}s(bt,"escapeInlineCode");function Ct(e){return typeof e=="object"&&e!==null}s(Ct,"isRecord");async function ke(e){let t=$e(),r=e.events.on(ne,o=>{if(!re(o))throw new Error("Invalid pi-agent-read plugin registration request");o.accept(t.registerPlugin(o.plugin))});e.on("session_shutdown",async()=>{r(),await t.read.dispose()});let n=new ce;e.registerTool(fe(t.read.tool,n)),e.on("tool_result",o=>{if(!(o.toolName!=="read"||!Ct(o.details)))return{details:oe(o.details,o.content.flatMap(i=>i.type==="text"?[i.text]:[]).join(`
|
|
16
|
+
`)),...o.details.failure!==void 0&&{isError:!0}}}),e.events.emit(te,{protocol:I,apiVersion:N}),await t.waitForPendingPlugins()}s(ke,"registerReadCore");export{ke as a};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{a as j,b as D}from"./chunk-QNZVPFSP.js";import{b as _}from"./chunk-U4D6FT66.js";import{a as x}from"./chunk-ERVMDQGX.js";import{a as v,b as w}from"./chunk-VFBLX4TG.js";import{c as E}from"./chunk-SSZB66C3.js";import{a as T}from"./chunk-ORAPGW7W.js";import{a as P,b as L}from"./chunk-JASLOB2X.js";import{a as M}from"./chunk-E2RESHYR.js";import{a as O,b as k}from"./chunk-T2RPMEM2.js";import{a as N}from"./chunk-EEH4WYI7.js";import{a as $,b as C,c as I}from"./chunk-266RH77Z.js";import{a as y,b as A,c as R,l as S}from"./chunk-5A25RATC.js";import{g as b}from"./chunk-7NDBZ4WX.js";import{a as i}from"./chunk-EI7MMDWY.js";import{readFile as W}from"node:fs/promises";var h=new Set(["c","cpp","javascript","typescript","python","rust","json","yaml","toml"]),H={protocol:v,apiVersion:1,id:"ast",setup(n){n.addSetupCheck({id:"structural-search",async inspect(e){return[...e.detectedLanguageIds].some(r=>h.has(r))?await b({command:["ast-grep"]},e.cwd,e.env)?{}:{actions:[{id:"ast-grep-unavailable",message:"Structural search is unavailable because ast-grep was not found"}]}:{}}}),n.addCheck({id:"parsers",title:"AST",async run(e){let s=[];for(let r of e.detectedLanguageIds){if(!h.has(r))continue;let t=e.files.find(o=>Z(o,r));if(t!==void 0)try{let o=await W(t,"utf8"),a=await j(t,e.cwd,o.replaceAll(`\r
|
|
2
|
+
`,`
|
|
3
|
+
`).split(`
|
|
4
|
+
`));s.push(a===void 0?{status:"fail",message:`${r} parser did not return a tree`}:{status:"pass",message:`${r} parser loaded`,detail:t})}catch(o){s.push({status:"fail",message:`${r}: ${o instanceof Error?o.message:String(o)}`})}}return s.length>0?s:[{status:"skip",message:"No supported AST files found"}]}}),n.addCheck({id:"ast-grep",title:"Structural search",async run(e){if(![...e.detectedLanguageIds].some(r=>h.has(r)))return[{status:"skip",message:"No supported structural-search files found"}];let s=await _("ast-grep",["--version"],e.cwd,e.env);return[s.ok?{status:"pass",message:"ast-grep is available",detail:s.detail}:{status:"fail",message:"ast-grep is not available",detail:s.detail}]}})}};function Z(n,e){let s=n.slice(n.lastIndexOf(".")).toLowerCase();return{c:[".c",".h"],cpp:[".cc",".cpp",".cxx",".hh",".hpp",".hxx"],javascript:[".js",".jsx",".mjs",".cjs"],typescript:[".ts",".tsx",".mts",".cts"],python:[".py",".pyi"],rust:[".rs"],json:[".json",".jsonc"],yaml:[".yaml",".yml"],toml:[".toml"]}[e]?.includes(s)??!1}i(Z,"matchesLanguage");var Q,q;function V(n){return{id:"ast",tryResolve(e,s){return Promise.resolve(ee(e,s,n))}}}i(V,"createAstOutlineResolver");function ee(n,e,s){let r;try{r=y(n,"ast")}catch(a){return{kind:"failed",error:a}}if(r===void 0)return{kind:"not-handled"};let t;try{t=A(r.path,e.cwd)}catch(a){return{kind:"failed",error:a}}return{kind:"resolved",resource:{source:R("ast",t),async read({signal:a}){a?.throwIfAborted();let d=await(q??=import("./chunk-4KQOODGE.js")),u=await(s??(Q??=new d.AstOutlineManager)).readFileOutline(t,e.cwd);return a?.throwIfAborted(),[d.formatAstOutline(u)]}}}}i(ee,"resolveAstOutlineSource");var B="pi-agent-ast";function G(n){return{id:"ast-scopes",async present(e,s){if(s.resolvedBy!=="filesystem")return e;try{let r=await n.getDocumentScopes(e.source,s.cwd,e.lines.map(o=>o.content)),t=te(e.lines,r);return t===e.lines?e:{...e,lines:t}}catch{return e}}}}i(G,"createAstScopePresenter");function Y(){return n=>{let e=n.state,s=n.result;if(e?.contentKind!=="text"||s===void 0)return{kind:"continue",context:n};let r=s.details.lines;if(r===void 0)return{kind:"continue",context:n};let t=new Map(e.text.lines.map(c=>[c.lineNumber,c])),o=new Set(r.map(c=>c.lineNumber)),a=new Map;for(let c of r){let l=t.get(c.lineNumber),p=F(l);for(let m of p?.boundaries??[]){if(o.has(m.endLine))continue;let g=t.get(m.endLine);g!==void 0&&a.set(m.endLine,g)}}if(a.size===0)return{kind:"continue",context:n};let d=[...a.values()].sort((c,l)=>c.lineNumber-l.lineNumber),f=[...r,...d],u=ne(s,f,r.at(-1));return{kind:"continue",context:{...n,result:u}}}}i(Y,"createAstScopePostReadHandler");function te(n,e){if(e.length===0)return n;let s=new Map,r=new Map;for(let t of e){let o=s.get(t.startLine)??[];o.push(t.beginAnchor.value),s.set(t.startLine,o);let a=r.get(t.startLine)??[];a.push({endLine:t.endLine}),r.set(t.startLine,a);let d=s.get(t.endLine)??[];d.push(t.endScopeAnchor.value),s.set(t.endLine,d)}return n.map(t=>{let o=s.get(t.lineNumber),a=r.get(t.lineNumber);return o===void 0&&a===void 0?t:{...t,...o!==void 0&&{presentation:{...t.presentation,suffix:`${t.presentation?.suffix??""}${o.map(d=>` <!-- ${d} -->`).join("")}`}},metadata:{...t.metadata,[B]:{...F(t),...a!==void 0&&{boundaries:a}}}}})}i(te,"addScopeMarkers");function F(n){let e=n?.metadata?.[B];if(!(typeof e!="object"||e===null))return e}i(F,"getAstScopeMetadata");function ne(n,e,s){let r=n.content.length===1?n.content[0]:void 0;if(r?.type!=="text"||n.details.lines===void 0)return n;let t=e.slice(n.details.lines.length);if(t.length===0)return n;let o=s?.lineEnding!==void 0&&s.lineEnding.length>0?s.lineEnding:t[0]?.lineEnding!==void 0&&t[0].lineEnding.length>0?t[0].lineEnding:`
|
|
5
|
+
`,a=t.map((u,c)=>{let p=c===t.length-1?u.lineEnding:u.lineEnding||o,m=u.presentation?.prefix??"",g=u.presentation?.suffix??"";return`${m}${u.content}${g}${p}`}).join(""),d=/(?:\r\n|\r|\n)$/.test(r.text)?"":o,f=`${r.text}${d}${a}`;return{...n,content:[{...r,text:f}],details:{...n.details,lines:e}}}i(ne,"appendTextLines");var K=/^scope-(begin|end)-[A-Z0-9]{3,4}(?:-[1-9]\d*)?$/;function X(n){return{id:"ast-scope",description:"Use `scope-begin-HASH` or `scope-end-HASH` as shown beside source lines; a numeric suffix may distinguish repeated scopes.",renderFull(e){return e},renderCompact(e){return K.exec(e)?.[1]==="begin"?"scope start":"scope end"},async tryResolve(e,s){if(!K.test(e))return{kind:"not-handled"};try{let t=(await n.getDocumentScopes(s.source,s.cwd,s.lines)).find(o=>o.beginAnchor.value===e||o.endScopeAnchor.value===e);return t===void 0?{kind:"rejected",rejection:{code:"stale",reason:`AST scope anchor ${e} is stale`}}:{kind:"resolved",anchor:t.beginAnchor.value===e?t.beginAnchor:t.endScopeAnchor}}catch(r){return{kind:"failed",error:r}}}}}i(X,"createAstScopeAnchorResolver");import{spawn as re}from"node:child_process";function U(){return{id:"ast",async tryResolve(n,e){if(!n.query.startsWith("ast:"))return{kind:"not-handled"};let s=n.query.slice(4).trim();if(s.length===0)return{kind:"failed",error:new Error("ast: pattern must not be empty")};let r=await se(s,n,e.cwd,e.signal),t=n.limit??100;return{kind:"resolved",payload:{pattern:s,matches:r.slice(0,t),complete:r.length<=t}}},format(n){let e=n;if(e.matches.length===0)return{content:[{type:"text",text:"No AST matches found."}],details:e};let s=e.matches.flatMap((r,t)=>[`${String(t+1)}. ${r.file}:${String(r.range.start.line+1)}:${String(r.range.start.column+1)} ${r.language}`,` ${r.lines.trim()}`]);return e.complete||s.push("Result limit reached."),{content:[{type:"text",text:s.join(`
|
|
6
|
+
`)}],details:e}}}}i(U,"createAstSearchResolver");function se(n,e,s,r){let t=["run","--pattern",n,"--json=compact","--no-ignore","parent"];for(let o of J(e.include))t.push("--globs",o);for(let o of J(e.exclude))t.push("--globs",`!${o}`);return t.push(e.path??"."),new Promise((o,a)=>{let d=re("ast-grep",t,{cwd:s,stdio:["ignore","pipe","pipe"]}),f="",u="";d.stdout.setEncoding("utf8"),d.stderr.setEncoding("utf8"),d.stdout.on("data",l=>f+=l),d.stderr.on("data",l=>u+=l);let c=i(()=>{d.kill("SIGTERM")},"abort");r?.addEventListener("abort",c,{once:!0}),d.once("error",a),d.once("close",l=>{if(r?.removeEventListener("abort",c),r?.aborted===!0){a(r.reason instanceof Error?r.reason:new Error("AST search aborted"));return}if(l!==0&&l!==1){a(new Error(u.trim()||`ast-grep exited with code ${String(l)}`));return}try{let p=JSON.parse(f.length===0?"[]":f);if(!Array.isArray(p))throw new TypeError("ast-grep returned non-array JSON");o(p)}catch(p){a(p instanceof Error?p:new Error(String(p)))}})})}i(se,"runAstGrep");function J(n){return n?.split(",").map(e=>e.trim()).filter(Boolean)??[]}i(J,"splitGlobs");var oe=E({kind:"code-view",label:"AST"});async function z(n){let e=new D,s=G(e),r={protocol:P,apiVersion:L,id:"ast",setup(o){o.addResolver({resolver:V(),renderResult:oe}),o.addHandler({stage:"read",when:{resolvedBy:"ast",contentKind:"text"},handler:S()}),o.addView({view:"ast",presenter:s}),o.addHandler({stage:"post-read",handler:Y()}),o.describe("Provides compact structural outlines of source files through `ast:<path>` and the `ast` view."),o.addPromptGuideline("You can use read with `ast:<path>` for a compact structural overview of a source file, including its classes, functions, signatures, and other declarations."),o.addPromptGuideline('You can use read with `views: ["ast"]` to add scope boundaries alongside the file\'s source text.')}},t={protocol:$,apiVersion:C,id:"ast",setup(o){o.addAnchorResolver({resolver:X(e),kind:I,type:"auxiliary"}),o.addTextPresenter({presenter:s})}};await Promise.all([T(n,r),x(n,H),N(n,t),M(n,{protocol:O,apiVersion:k,id:"ast-search",setup(o){o.addResolver({resolver:U()}),o.describe("Use `ast:<pattern>` for structural code search through ast-grep. Optional path and glob fields limit the workspace scope."),o.addPromptGuideline("You can use search with `ast:<pattern>` for structural code search. You can limit it with `path`, `include`, and `exclude`.")}})])}i(z,"registerAst");export{z as a};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{j as V}from"./chunk-2SKAED2I.js";import{a as m}from"./chunk-KINKBPPX.js";import{a as y}from"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import x from"node:path";import{fileURLToPath as R}from"node:url";function T(e,n){let t=`${n}:`;if(!e.startsWith(t))return;let o=e.slice(t.length),r=o.indexOf("#"),i=r===-1?o:o.slice(0,r);if(i.length===0)throw new TypeError(`${n}: requires a file path.`);let s=$(i,`${n}: path`),c=r===-1?void 0:o.slice(r+1);if(n==="ast"){if(c!==void 0)throw new TypeError("ast: accepts only a file path and does not accept a symbol selector.");return{scheme:n,path:s}}if(n==="symbol"&&c===void 0)throw new TypeError("symbol: requires #<symbol-selector> after the file path.");if(c===void 0)return{scheme:n,path:s};if(c.length===0)throw new TypeError(`${n}: symbol selector must not be empty.`);let d=c.split("/").map(f=>{if(f.length===0)throw new TypeError(`${n}: symbol selector contains an empty segment.`);return $(f,`${n}: symbol selector`)});return{scheme:n,path:s,selector:d}}a(T,"parseCodeViewReference");function C(e,n){return e.startsWith("file://")?R(new URL(e)):x.isAbsolute(e)?x.normalize(e):x.resolve(n,e)}a(C,"resolveCodeViewPath");function D(e,n,t){let o=n.replaceAll("%","%25").replaceAll("#","%23"),r=t===void 0?"":`#${t.map(i=>encodeURIComponent(i)).join("/")}`;return`${e}:${o}${r}`}a(D,"formatCodeViewReference");function k(e){return e.map(n=>encodeURIComponent(n)).join("/")}a(k,"formatSymbolSelector");function $(e,n){try{return decodeURIComponent(e)}catch(t){throw new TypeError(`${n} contains invalid percent encoding.`,{cause:t})}}a($,"decodePart");import v from"node:path";function N(e,n,t){let o=`${n}:`;if(!e.startsWith(o))return;let r=e.slice(o.length);if(r.length===0)throw new Error(`${n}: requires a file path.`);return v.resolve(t,r)}a(N,"resolveDiagnosticViewPath");function M(e,n){return`${e}:${n}`}a(M,"formatDiagnosticViewSource");function j(e,n,t,o={}){let r=n.split(/\r\n|\r|\n/u),i=b(t,r.length);if(i.size===0)return{type:"text",text:w(t)||"No diagnostics.",sourceLines:{}};let s=o.contextLines??5;if(!Number.isInteger(s)||s<0)throw new TypeError("Diagnostic contextLines must be a non-negative integer.");let c=new Set;for(let l of i.keys()){let u=Math.max(1,l-s),p=Math.min(r.length,l+s);for(let g=u;g<=p;g+=1)c.add(g)}let d=w(t),f=d?[d]:[],S={};for(let l of[...c].sort((u,p)=>u-p)){let u=r[l-1]??"",p=(i.get(l)??[]).map(({diagnostic:g,source:h})=>`<!-- ${h}: ${m(g,h)} -->`).join(" ");f.push(p.length===0?u:`${u} ${p}`),S[String(f.length)]={source:e,lineNumber:l,content:u}}return{type:"text",text:f.join(`
|
|
2
|
+
`),sourceLines:S}}a(j,"createDiagnosticViewContent");function O(e,n){let t=b(n,e.lines.length),o=e.lines.map(r=>{let i=t.get(r.lineNumber);if(i===void 0)return r;let s=i.map(({diagnostic:c,source:d})=>`<!-- ${d}: ${m(c,d)} -->`).join(" ");return{...r,presentation:{...r.presentation,suffix:`${r.presentation?.suffix??""} ${s}`}}});return{...e,lines:o}}a(O,"addDiagnosticAnnotations");function w(e){return e.filter(n=>n.status&&n.status!=="ready").map(n=>`${n.source}: ${n.status}${n.reason?` (${n.reason})`:""}.`).join(" ")}a(w,"diagnosticStatus");function b(e,n){let t=new Map;for(let{diagnostics:o,source:r}of e)for(let i of o){if(!Number.isInteger(i.line)||i.line<1||i.line>n)continue;let s=t.get(i.line)??[];s.push({diagnostic:i,source:r}),t.set(i.line,s)}return t}a(b,"diagnosticsByValidLine");function B(e){return{text:`${e.content}${e.suffix??""}`,...e.sourceLine!==void 0&&{sourceLine:e.sourceLine}}}a(B,"renderSourceViewLine");function E(e,n){if(e.length===0)return L([{text:"<empty-result>"}]);if(e.length===1&&y(e[0]).status==="failed"&&y(e[0]).path===""){let o=y(e[0]),r=n.recovery===void 0?[]:["","Recovery:",...n.recovery],i=n.includeNoChange===!0?["","No file was changed."]:[];return L([o.code??n.failureLabel,"",`Reason: ${o.error??n.unknownFailure??"unknown failure"}`,...i,...r].map(s=>({text:s})))}let t=[];for(let[o,r]of e.entries())o>0&&t.push({text:""},{text:""}),t.push(...P(r,n));return L(t)}a(E,"formatSourceViewResults");function F(){return e=>{let n=e.state;if(n?.contentKind!=="text")return{kind:"continue",context:e};let t=A(n.content[0]);if(t===void 0)return{kind:"continue",context:e};let o=n.text.lines.map(r=>{let i=t[String(r.lineNumber)];return i===void 0?r:V(r,i)});return{kind:"continue",context:{...e,state:{...n,text:{...n.text,lines:o}}}}}}a(F,"createSourceMappedTextReadHandler");function P(e,n){if(e.status==="failed")return[...e.heading===void 0?[`## file: ${e.path||"<unknown>"}`]:[`## ${e.heading}`,...e.details??[]],`${n.failureLabel} | ${e.error??n.unknownFailure??"unknown failure"}`].map(s=>({text:s}));let t=e.heading===void 0?[`## file: ${e.path}`]:[`## ${e.heading}`,...e.details??[]],o=e.continuation??"",r=e.warning===void 0?[]:[{text:""},{text:e.warning}];return[...t.map(i=>({text:i})),{text:`Lines: ${e.startLine}-${e.endLine} of ${e.totalLines}${o}`},{text:""},...e.renderedLines,...r]}a(P,"formatSourceViewBlock");function L(e){let n={};for(let[t,o]of e.entries())o.sourceLine!==void 0&&(n[String(t+1)]=o.sourceLine);return{type:"text",text:e.map(t=>t.text).join(`
|
|
3
|
+
`),sourceLines:n}}a(L,"sourceMappedContent");function A(e){if(typeof e!="object"||e===null||!("sourceLines"in e))return;let n=e.sourceLines;if(!(typeof n!="object"||n===null)){for(let t of Object.values(n))if(!I(t))return;return n}}a(A,"sourceLineMap");function I(e){if(typeof e!="object"||e===null)return!1;let n=e;return typeof n.source=="string"&&n.source.length>0&&Number.isInteger(n.lineNumber)&&(n.lineNumber??0)>0&&typeof n.content=="string"}a(I,"isTextSourceLine");export{T as a,C as b,D as c,k as d,N as e,M as f,j as g,O as h,w as i,B as j,E as k,F as l};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as d}from"./chunk-EEH4WYI7.js";import{a as s,b as l,c}from"./chunk-266RH77Z.js";import{a as i}from"./chunk-2SKAED2I.js";import{a as t}from"./chunk-EI7MMDWY.js";var o=class extends i{static{t(this,"ConstantTextAnchor")}constructor(n,r){super(n,r)}};function p(){return{id:"file-position",description:"`begin` and `end` select the first and last existing lines.",renderFull(e){return e},renderCompact(e){return e==="begin"?"file start":"file end"},tryResolve(e,n){return Promise.resolve(a(e,n))}}}t(p,"createConstantTextAnchorResolver");function a(e,n){return e!=="begin"&&e!=="end"?{kind:"not-handled"}:n.lines.length===0?{kind:"failed",error:new Error(`${e} cannot resolve in an empty file`)}:{kind:"resolved",anchor:new o(e,e==="begin"?1:n.lines.length)}}t(a,"resolveConstantAnchor");async function T(e){await d(e,{protocol:s,apiVersion:l,id:"text-anchor-constant",setup(r){r.addAnchorResolver({resolver:p(),kind:c,type:"constant"})}})}t(T,"registerConstantTextAnchors");export{T as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{v as r}from"./chunk-EW2KVKCN.js";import{p as e}from"./chunk-2SKAED2I.js";import{a as t}from"./chunk-EI7MMDWY.js";var n={target:{provider:"web",capability:"read"},converter:e(),priority:300};async function i(o){await r(o,n)}t(i,"registerWebText");export{i as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as x,e as T}from"./chunk-PETQCA7G.js";import{a as p}from"./chunk-ORAPGW7W.js";import{a as l,b as m}from"./chunk-JASLOB2X.js";import{a as f}from"./chunk-EEH4WYI7.js";import{a as u,b as h,c as P}from"./chunk-266RH77Z.js";import{i as d}from"./chunk-2SKAED2I.js";import{a as s}from"./chunk-EI7MMDWY.js";function g(){return{id:"line-hash",present(r,o){let i=r.lines.map(e=>{let n=o.resolvedBy==="filesystem"?{lineNumber:e.lineNumber,content:e.content}:d(e);return n===void 0?void 0:{anchor:x(n.lineNumber,n.content),lineNumber:n.lineNumber}}),a=Math.max(0,...i.map(e=>e?.anchor.value.length??0)),t=Math.max(0,...i.map(e=>String(e?.lineNumber??"").length)),E=r.lines.map((e,n)=>{let c=i[n];return c===void 0?e:{...e,presentation:{...e.presentation,prefix:`${c.anchor.value.padStart(a)}|${e.presentation?.prefix??""}`,compactPrefix:e.presentation?.compactPrefix??`${String(c.lineNumber).padStart(t)} \u2502 `}}});return{...r,lines:E}}}}s(g,"createLineHashPresenter");async function A(r){let o=g(),i={protocol:l,apiVersion:m,id:"text-anchor-line-hash",setup(t){t.addView({view:"anchors",includes:["lines"],presenter:o}),t.describe("Adds `LINE#HASH` anchors to textual read results that request the `anchors` view."),t.addPromptGuideline('You can use read with `views: ["anchors"]` to add `LINE#HASH` anchors for later edits.')}},a={protocol:u,apiVersion:h,id:"text-anchor-line-hash",setup(t){t.addAnchorResolver({resolver:T(),kind:P,type:"major"}),t.addTextPresenter({presenter:o})}};await Promise.all([p(r,i),f(r,a)])}s(A,"registerLineHashTextAnchor");export{A as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as m}from"./chunk-ZC65Z3CK.js";import{a as i}from"./chunk-EI7MMDWY.js";import N from"cross-spawn";import{constants as F}from"node:fs";import{access as O,readFile as h,writeFile as b}from"node:fs/promises";import S from"node:os";import s from"node:path";import{fileURLToPath as I}from"node:url";var j=1;function A(e){return s.join(e,".pi","pi-agent-ide")}i(A,"projectIdeConfigDirectory");function M(e,o){return s.join(A(e),`${o}.json`)}i(M,"projectIdeConfigPath");function _(e,o,n={}){let t=(n.environment??process.env).PI_CODING_AGENT_DIR?.trim(),c=t===void 0||t.length===0?s.join(n.homeDirectory??S.homedir(),".pi","agent"):s.resolve(t);return{project:M(e,o),global:s.join(c,"extensions","pi-agent-ide",`${o}.json`),builtIn:I(new URL(`tool-config/${o}.json`,new URL("../src/api/tool-config.ts",import.meta.url).href))}}i(_,"resolveToolConfigPaths");async function Q(e,o,n,r={}){let t=_(e,o,r),c=[{layer:"project",sourcePath:t.project,optional:!0},{layer:"global",sourcePath:t.global,optional:!0},{layer:"built-in",sourcePath:t.builtIn,optional:!1}],a=[],g=new Set;for(let d of c){let w=await J(d,o,n);for(let[l,y]of Object.entries(w))g.has(l)||(g.add(l),a.push({id:l,config:y,layer:d.layer,sourcePath:d.sourcePath}))}return{entries:a,paths:t}}i(Q,"loadLayeredToolConfig");function Y(e,o,n){let r=s.extname(o).toLowerCase();if(e.extensions.every(a=>!(G(a)===r||a==="*")))return!1;let t=s.relative(n,o).split(s.sep).join("/"),c=i(a=>a?.some(g=>s.matchesGlob(t,g))??!1,"matches");return(e.include===void 0||c(e.include))&&!c(e.exclude)}i(Y,"matchesConfiguredFile");async function Z(e,o,n=process.env){p(e,"process");let r=m(e.command[0]).replaceAll("{project}",o),t=L(e,o,n),c=s.isAbsolute(r)||s.dirname(r)!=="."?[s.resolve(o,r)]:(t.PATH??"").split(s.delimiter).filter(Boolean).map(a=>s.join(a,r));for(let a of c)try{return await O(a,F.X_OK),!0}catch{}return!1}i(Z,"hasConfiguredExecutable");async function D(e,o){p(e,"process");let n=e.command.map(d=>B(d,o)),r=m(n[0]),t=n.slice(1),c=e.cwd==="file"?s.dirname(o.filePath):o.projectRoot,a=e.successExitCodes??[0],g=L(e,o.projectRoot,o.env??process.env);return new Promise((d,w)=>{let l=N(r,t,{cwd:c,env:g,signal:o.signal,killSignal:"SIGKILL",stdio:["ignore","pipe","pipe"]}),y="",P="",v=m(l.stdout),T=m(l.stderr),E=!1,x=setTimeout(()=>{E=!0,l.kill("SIGKILL")},e.timeoutMs??3e4);v.setEncoding("utf8"),T.setEncoding("utf8"),v.on("data",f=>{y+=f}),T.on("data",f=>{P+=f}),l.on("error",f=>{clearTimeout(x),w(f)}),l.on("close",f=>{clearTimeout(x),d({ok:!E&&f!==null&&a.includes(f),exitCode:f,stdout:y,stderr:P})})})}i(D,"runConfiguredProcess");async function ee(e,o){let n=await h(o.filePath,"utf8"),r=await D(e.run,o);if(!r.ok)return e.output==="in-place"&&await h(o.filePath,"utf8")!==n&&await b(o.filePath,n,"utf8"),{ok:!1,changed:!1};e.output==="stdout"&&r.stdout!==n&&await b(o.filePath,r.stdout,"utf8");let t=await h(o.filePath,"utf8");return{ok:!0,changed:n!==t}}i(ee,"runConfiguredFormatter");function oe(e){let o=R(e,"formatters");for(let[n,r]of Object.entries(o.entries)){let t=u(r,`formatter ${n}`);if(k(t,`formatter ${n}`),p(t.run,`formatter ${n}.run`),t.output!=="in-place"&&t.output!=="stdout")throw new Error(`formatter ${n}.output must be in-place or stdout`)}return e}i(oe,"parseFormattersConfig");function ne(e){let o=R(e,"linters"),n=new Set(["pi-json","eslint-json","sarif","checkstyle","gcc","clang","regex"]);for(let[r,t]of Object.entries(o.entries)){let c=u(t,`linter ${r}`);k(c,`linter ${r}`),p(c.check,`linter ${r}.check`),c.fix!==void 0&&p(c.fix,`linter ${r}.fix`);let a=u(c.diagnostics,`linter ${r}.diagnostics`);if(!n.has(String(a.format)))throw new Error(`linter ${r} has an unsupported diagnostics format`);if(a.format==="regex"&&typeof a.pattern!="string")throw new Error(`linter ${r} regex diagnostics require pattern`)}return e}i(ne,"parseLintersConfig");function R(e,o){let n=u(e,"tool config");if(n.version!==j)throw new Error(`tool config version must be ${j}`);return{entries:u(n[o],o)}}i(R,"configRoot");function k(e,o){C(e.extensions,`${o}.extensions`,!1),e.include!==void 0&&C(e.include,`${o}.include`,!1),e.exclude!==void 0&&C(e.exclude,`${o}.exclude`,!0)}i(k,"assertMatcher");function p(e,o){let n=u(e,o);if(C(n.command,`${o}.command`,!1),n.cwd!==void 0&&n.cwd!=="project"&&n.cwd!=="file")throw new Error(`${o}.cwd must be project or file`);if(n.timeoutMs!==void 0&&(!Number.isFinite(n.timeoutMs)||Number(n.timeoutMs)<=0))throw new Error(`${o}.timeoutMs must be positive`);if(n.successExitCodes!==void 0&&(!Array.isArray(n.successExitCodes)||n.successExitCodes.some(r=>!Number.isInteger(r))))throw new Error(`${o}.successExitCodes must contain integers`);if(n.env!==void 0){let r=u(n.env,`${o}.env`);if(Object.values(r).some(t=>typeof t!="string"))throw new Error(`${o}.env values must be strings`)}}i(p,"assertProcessConfig");function C(e,o,n){if(!Array.isArray(e)||!n&&e.length===0||e.some(r=>typeof r!="string"||r.length===0))throw new Error(`${o} must be ${n?"an":"a non-empty"} array of strings`)}i(C,"assertStringArray");function u(e,o){if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`${o} must be an object`);return e}i(u,"configRecord");function G(e){return e.startsWith(".")?e.toLowerCase():`.${e.toLowerCase()}`}i(G,"normalizeExtension");async function J(e,o,n){let r;try{r=await h(e.sourcePath,"utf8")}catch(t){if(e.optional&&V(t))return{};throw new Error(`Cannot read ${e.layer} ${o} config at ${e.sourcePath}: ${$(t)}`,{cause:t})}try{return n(JSON.parse(r))}catch(t){throw new Error(`Invalid ${e.layer} ${o} config at ${e.sourcePath}: ${$(t)}`,{cause:t})}}i(J,"readToolConfigLayer");function V(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}i(V,"isMissingFile");function $(e){return e instanceof Error?e.message:String(e)}i($,"errorMessage");function L(e,o,n){let r={...n,...e.env},t=s.resolve(o,"node_modules",".bin");return r.PATH=[t,r.PATH].filter(Boolean).join(s.delimiter),r}i(L,"createConfiguredProcessEnvironment");function B(e,o){let n=s.relative(o.projectRoot,o.filePath);return e.replaceAll("{project}",o.projectRoot).replaceAll("{fileDir}",s.dirname(o.filePath)).replaceAll("{relativeFile}",n).replaceAll("{file}",o.filePath)}i(B,"expandPlaceholders");export{j as a,A as b,M as c,_ as d,Q as e,Y as f,Z as g,D as h,ee as i,oe as j,ne as k,L as l};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as p}from"./chunk-ERVMDQGX.js";import{a as l,b as c}from"./chunk-VFBLX4TG.js";import{a as e}from"./chunk-EI7MMDWY.js";var m=[t("c","C",[".c",".h"],["CMakeLists.txt","meson.build","compile_commands.json"],"tree-sitter"),t("cpp","C++",[".cc",".cpp",".cxx",".hh",".hpp",".hxx"],["CMakeLists.txt","meson.build","compile_commands.json","conanfile.py","vcpkg.json"],"tree-sitter"),t("csharp","C#",[".cs"],[".sln",".csproj","global.json"]),t("go","Go",[".go"],["go.mod","go.work"]),t("java","Java",[".java"],["pom.xml","build.gradle","build.gradle.kts"]),t("kotlin","Kotlin",[".kt",".kts"],["build.gradle.kts","settings.gradle.kts"]),t("javascript","JavaScript",[".js",".jsx",".mjs",".cjs"],["package.json"],"tree-sitter"),t("typescript","TypeScript",[".ts",".tsx",".mts",".cts"],["tsconfig.json","package.json"],"tree-sitter"),t("python","Python",[".py",".pyi"],["pyproject.toml","requirements.txt","setup.py"],"tree-sitter"),t("rust","Rust",[".rs"],["Cargo.toml"],"tree-sitter"),t("ruby","Ruby",[".rb",".rake"],["Gemfile",".ruby-version"]),t("php","PHP",[".php"],["composer.json"]),t("swift","Swift",[".swift"],["Package.swift"]),t("lua","Lua",[".lua"],[".luarc.json","stylua.toml"]),t("shell","Shell",[".sh",".bash",".zsh"],[".shellcheckrc"]),t("html","HTML",[".html",".htm"],[]),t("css","CSS",[".css",".scss",".sass",".less"],["stylelint.config.js"]),t("json","JSON",[".json",".jsonc"],[],"tree-sitter"),t("yaml","YAML",[".yaml",".yml"],[".yamllint"],"tree-sitter"),t("toml","TOML",[".toml"],["taplo.toml"],"tree-sitter"),t("xml","XML",[".xml",".xsd",".xsl"],[]),t("markdown","Markdown",[".md",".mdx"],[".markdownlint.json"]),t("sql","SQL",[".sql"],[".sqlfluff"]),t("dockerfile","Dockerfile",[],["Dockerfile","compose.yaml"],void 0,["Dockerfile","Containerfile"]),t("terraform","Terraform",[".tf",".tfvars"],[".terraform.lock.hcl"]),t("cmake","CMake",[".cmake"],["CMakeLists.txt"],void 0,["CMakeLists.txt"])];function t(o,i,s,r,n,a){return{id:o,name:i,extensions:s,projectMarkers:r,...n&&{ast:n},...a&&{fileNames:a}}}e(t,"language");function g(o){return p(o,{protocol:l,apiVersion:1,id:"languages",setup(s){for(let r of m)s.addLanguage(r)}})}e(g,"registerLanguages");export{g as a};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{e as O,f as N,g as M}from"./chunk-VSP2QQPQ.js";import{c as A}from"./chunk-YHUTTZC6.js";import{a as k,b as I,c as C,d as D,g as $}from"./chunk-T2RPMEM2.js";import{a as o}from"./chunk-EI7MMDWY.js";import{keyText as re}from"@earendil-works/pi-coding-agent";import{Text as te}from"@earendil-works/pi-tui";import ne from"node:os";import{Type as p}from"typebox";function L(){let e=[],r=new Map,a=new Map,i=new Map,s=Promise.resolve(),l={registerPlugin(n){if(n.id.trim().length===0)return Promise.reject(new Error("Plugin ID must not be empty"));let c=i.get(n.id);if(c!==void 0)return c;let u=s.then(async()=>{let f=[],h=[],m,g=[],d={addResolver(t){U(t),f.push(t)},addAction(t){z(t),h.push(t)},describe(t){if(m!==void 0)throw new Error(`Plugin ${n.id} provides more than one description`);m=j(t)},addPromptGuideline(t){g.push(j(t))},search:o((t,S)=>l.execute(t,S),"search"),runAction(t,S){return l.runAction(t.reference,t.capability,t.resolverId,t.input,S)}};await n.setup(d);let y=new Set(e.map(({registration:t})=>t.resolver.id));for(let t of f){if(y.has(t.resolver.id))throw new Error(`Search resolver ${t.resolver.id} is already registered`);y.add(t.resolver.id)}for(let t of h){let S=v(t.resolverId,t.capability);if(r.has(S)||h.some(x=>x!==t&&v(x.resolverId,x.capability)===S))throw new Error(`Search action ${S} is already registered`)}for(let t of f)e.push({pluginId:n.id,registration:t,order:e.length});for(let t of h)r.set(v(t.resolverId,t.capability),t);g.length>0&&a.set(n.id,g)});return i.set(n.id,u),s=u.catch(()=>{}),u.catch(()=>{i.delete(n.id)}),u},async waitForPendingPlugins(){await Promise.all(i.values())},async execute(n,c){if(n.query.trim().length===0)return w("INVALID_REQUEST","Search query must not be empty");let u=[...e].sort((g,d)=>+(g.registration.fallback===!0)-+(d.registration.fallback===!0)||(g.registration.priority??0)-(d.registration.priority??0)||g.order-d.order),f=/^[a-z][\w-]*:\s*$/iu.test(n.query),h=/^[a-z][\w-]*:/iu.test(n.query);for(let g of u){if(f&&!g.registration.fallback)continue;let d=g.registration.resolver,y;try{c.signal?.throwIfAborted(),y=await d.tryResolve(n,c)}catch(t){return w("RESOLVE_FAILED",T(t,`Resolver ${d.id} failed`),d.id,t)}if(!B(y))return w("INVALID_RESOLVER_RESULT",`Resolver ${d.id} returned an invalid result`,d.id);if(y.kind!=="not-handled"){if(y.kind==="failed")return w("RESOLVE_FAILED",T(y.error,`Resolver ${d.id} failed`),d.id,y.error);try{let t=await d.format(y.payload,c);return _(t)?{content:g.registration.fallback&&h?[{type:"text",text:f?"Search fallback: empty protocol query; searched the original text.":"Search fallback: unhandled protocol query; searched the original text."},...t.content]:t.content,details:{resolverId:d.id,payload:t.details},...t.usage!==void 0&&{usage:t.usage}}:w("FORMAT_FAILED",`Resolver ${d.id} formatter returned an invalid result`,d.id)}catch(t){return w("FORMAT_FAILED",T(t,`Resolver ${d.id} formatter failed`),d.id,t)}}}let m=`No search resolver handled ${n.query}`;return O(w("NO_RESOLVER",m),m)},runAction(n,c,u,f,h){let m=r.get(v(u,c));if(m===void 0)throw new Error(`Search reference does not support ${c}`);return m.execute(n,f,h)},renderPromptGuidelines(){return[...a.values()].flat().flatMap(n=>{let c=K(n);return c===void 0?[]:[c]})},renderer(n){return e.find(({registration:c})=>c.resolver.id===n)?.registration.resolver.renderResult}};return l}o(L,"createSearchCore");function U(e){if(!b(e)||!b(e.resolver))throw new TypeError("Invalid search resolver registration");let r=e.resolver;if(typeof r.id!="string"||r.id.trim().length===0||typeof r.tryResolve!="function"||typeof r.format!="function")throw new TypeError("Invalid search resolver registration");if(e.priority!==void 0&&(typeof e.priority!="number"||!Number.isFinite(e.priority)))throw new TypeError("Invalid search resolver priority")}o(U,"assertResolver");function z(e){if(!b(e)||typeof e.resolverId!="string"||e.resolverId.trim().length===0||typeof e.capability!="string"||e.capability.trim().length===0||typeof e.execute!="function")throw new TypeError("Invalid search action registration")}o(z,"assertAction");function b(e){return typeof e=="object"&&e!==null}o(b,"isRecord");function B(e){if(typeof e!="object"||e===null||!("kind"in e))return!1;let r=e.kind;return r==="not-handled"||r==="resolved"&&"payload"in e||r==="failed"&&"error"in e}o(B,"isAttempt");function _(e){return typeof e=="object"&&e!==null&&Array.isArray(e.content)}o(_,"isAgentToolResult");function w(e,r,a,i){return{content:[{type:"text",text:r}],details:{failure:{code:e,message:r,...a!==void 0&&{resolverId:a},...i!==void 0&&{cause:i}}}}}o(w,"failure");function j(e){if(typeof e=="function")return e;if(typeof e!="string"||e.trim().length===0)throw new TypeError("Search description must not be empty");return e.trim()}o(j,"normalizeDescriptionSource");function K(e){let r=typeof e=="function"?e():e;if(r!==void 0){if(typeof r!="string"||r.trim().length===0)throw new TypeError("Search description must not be empty");return r.trim()}}o(K,"renderDescription");function v(e,r){return`${e}:${r}`}o(v,"actionKey");function T(e,r){return!(e instanceof Error)||e.message.trim().length===0?r:e instanceof SyntaxError?e.message:`${r}: ${e.message}`}o(T,"messageFor");import{readFile as Q}from"node:fs/promises";import Y from"node:os";import P from"node:path";var X=3e4;function q(e=process.env,r=Y.homedir(),a=process.cwd()){let i=e.PI_CODING_AGENT_DIR?.trim(),s=i===void 0||i.length===0?P.join(r,".pi","agent"):P.resolve(i);return{globalPath:P.join(s,"pi-agent-ide","search.json"),projectPath:P.resolve(a,".pi","pi-agent-ide","search.json")}}o(q,"resolveSearchConfigPaths");async function G(e){let[r,a]=await Promise.all([F(e.globalPath),F(e.projectPath)]),i=a!==void 0?a:r;return{timeoutMs:i===void 0?X:i}}o(G,"loadSearchConfig");async function F(e){let r;try{r=await Q(e,"utf8")}catch(l){if(Z(l))return;throw new Error(`Cannot read Pi Agent IDE search config at ${e}`,{cause:l})}let a;try{a=JSON.parse(r)}catch(l){throw new Error(`Invalid JSON in Pi Agent IDE search config at ${e}`,{cause:l})}if(!H(a))throw new TypeError(`Pi Agent IDE search config at ${e} must be a JSON object`);let i=Object.keys(a).find(l=>l!=="timeoutMs");if(i!==void 0)throw new TypeError(`Pi Agent IDE search config at ${e} contains unknown key ${i}`);let s=a.timeoutMs;if(s==null)return s;if(typeof s!="number"||!Number.isSafeInteger(s)||s<=0)throw new TypeError(`timeoutMs must be a positive integer or null in Pi Agent IDE search config at ${e}`);return s}o(F,"readTimeout");function Z(e){return H(e)&&e.code==="ENOENT"}o(Z,"isMissingFile");function H(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}o(H,"isRecord");var V=Symbol("search-timeout"),E=class extends Error{static{o(this,"SearchTimeoutError")}constructor(r){super(r),this.name="SearchTimeoutError"}};async function W(e,r,a){if(e===null)return a(r);let i=new AbortController,s=r===void 0?i.signal:AbortSignal.any([r,i.signal]),l,n=new Promise(c=>{l=setTimeout(()=>{c(V),i.abort()},e)});try{let c=await Promise.race([a(s),n]);if(c===V)throw new E(`Search timed out after ${ee(e)}. Try a smaller path scope.`);return c}finally{clearTimeout(l)}}o(W,"runWithSearchTimeout");function ee(e){if(e%1e3!==0)return`${String(e)}ms`;let r=e/1e3;return`${String(r)} ${r===1?"second":"seconds"}`}o(ee,"formatDuration");var oe=p.Object({query:p.String({minLength:1,description:"Search query. Local text tries literal terms, then regex, then eligible word fallback. Quotes keep terms literal and Boolean conditions stay intact. Empty or unhandled prefixes are text; nonempty installed prefixes select specialized search protocols."}),path:p.Optional(p.String({description:"Optional file or directory scope for local search"})),include:p.Optional(p.String({description:"Optional include glob for local search"})),exclude:p.Optional(p.String({description:"Optional exclude glob for local search"})),caseSensitive:p.Optional(p.Boolean({description:"Match letter case in local search"})),wholeWord:p.Optional(p.Boolean({description:"Match complete words in local search"})),limit:p.Optional(p.Integer({minimum:1,maximum:1e3,description:"Maximum results (default 100)"}))},{additionalProperties:!1});function ie(e,r){let a=[...e.path===void 0?[]:[{text:`in ${e.path}`,color:"accent",underline:!0,truncate:"start"}],...e.include===void 0?[]:[{text:`include ${e.include}`}],...e.exclude===void 0?[]:[{text:`exclude ${e.exclude}`}],...e.caseSensitive===!0?[{text:"case sensitive"}]:[],...e.wholeWord===!0?[{text:"whole word"}]:[],...e.limit===void 0?[]:[{text:`limit ${String(e.limit)}`}]];return{tool:"search",primary:{text:JSON.stringify(e.query),color:"accent",truncate:"end"},qualifiers:a,details:se(e),expanded:r}}o(ie,"searchCallModel");async function J(e){let r=L(),a=new N,i=e.events.on(D,s=>{if(!$(s))throw new Error("Invalid pi-agent-search plugin registration request");s.accept(r.registerPlugin(s.plugin))});e.on("session_shutdown",i),e.registerTool(M({name:"search",label:"search",description:"Search workspace text and paths through installed local, language, and structural search protocols.",promptSnippet:"Search files and text with literals or regular expressions, plus syntax trees and language symbols",get promptGuidelines(){return["Use search instead of grep, rg, or find to search workspace text and paths.","Use the narrowest useful search query and scope; broaden when needed.","Do not use search merely to rediscover a file path already named in the request; use that path directly. Search within it only when you need to locate content.",...r.renderPromptGuidelines()]},parameters:oe,renderCall(s,l,n){return A(n.lastComponent,ie(s,n.expanded),l)},renderResult(s,l,n,c){let u=s.details,f=u?.resolverId===void 0?void 0:r.renderer(u.resolverId);if(f!==void 0){let h={...s,details:u?.payload};return f(h,l,n,c)}return ae(s,l,n)},async execute(s,l,n,c,u){let f=await G(q(process.env,ne.homedir(),u.cwd));return W(f.timeoutMs,n,async h=>(await r.waitForPendingPlugins(),r.execute(l,{cwd:u.cwd,...h!==void 0&&{signal:h},...c!==void 0&&{onUpdate:o(m=>{c(m)},"onUpdate")}})))}},a)),e.events.emit(C,{protocol:k,apiVersion:I}),await r.waitForPendingPlugins()}o(J,"registerSearchCore");function se(e){return[{label:"query",value:JSON.stringify(e.query)},...R("path",e.path),...R("include",e.include),...R("exclude",e.exclude),...R("caseSensitive",e.caseSensitive===void 0?void 0:String(e.caseSensitive)),...R("wholeWord",e.wholeWord===void 0?void 0:String(e.wholeWord)),...R("limit",e.limit===void 0?void 0:String(e.limit))]}o(se,"searchCallDetails");function R(e,r){return r===void 0?[]:[{label:e,value:r}]}o(R,"optionalDetail");function ae(e,r,a){let i=e.content.flatMap(n=>n.type==="text"?[n.text]:[]).join(`
|
|
2
|
+
`),s=r.expanded?i:i.split(`
|
|
3
|
+
`).slice(0,8).join(`
|
|
4
|
+
`),l=!r.expanded&&i.split(`
|
|
5
|
+
`).length>8?`
|
|
6
|
+
${a.fg("dim",`${re("app.tools.expand")} to expand`)}`:"";return new te(`${a.fg("muted",s)}${l}`,0,0)}o(ae,"fallbackResult");export{J as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as l}from"./chunk-ZC65Z3CK.js";import{a as u}from"./chunk-EI7MMDWY.js";import{createHash as w}from"node:crypto";import{diffLines as v}from"diff";var f=3,G=4;function P(t,a,r,n){let e=S(a,n),s=I(e,a,n),d=S(a,r),c=new Map,g=s.map(i=>{let o=N(i,a,r,n,d),E=j(n,i.currentStart),C=B(n,i.currentEnd),h=JSON.stringify({contextAfter:C,contextBefore:E,headText:o.headText,repositoryPath:t,worktreeText:o.worktreeText}),m=c.get(h)??0;c.set(h,m+1);let b=H(`${h}\0${m}`).toUpperCase();return{selector:b,digest:b,duplicateOrder:m,repositoryPath:t,state:O(o),currentStartLine:R(n,i.currentStart),currentEndLine:R(n,Math.max(i.currentStart,i.currentEnd-1)),contextBefore:E,contextAfter:C,canonicalContent:h,segments:[o]}});return g.map(i=>({...i,selector:`CHANGE#${L(i.digest,g.map(({digest:o})=>o))}`}))}u(P,"createChangeGroups");function U(t,a){let r=t;for(let n of[...a.segments].sort((e,s)=>s.currentStart-e.currentStart)){if(r.slice(n.currentStart,n.currentEnd)!==n.worktreeText)return;r=r.slice(0,n.currentStart)+n.headText+r.slice(n.currentEnd)}return r}u(U,"reverseChangeGroup");function _(t,a,r,n,e){let s=x(r,n,S(t,a));return a.slice(0,s.start)+e+a.slice(s.end)}u(_,"replaceHeadRangeInIndex");function N(t,a,r,n,e){let s=x(t.headStart,t.headEnd,e);return{headText:a.slice(t.headStart,t.headEnd),indexText:r.slice(s.start,s.end),worktreeText:n.slice(t.currentStart,t.currentEnd),headStart:t.headStart,headEnd:t.headEnd,indexStart:s.start,indexEnd:s.end,currentStart:t.currentStart,currentEnd:t.currentEnd}}u(N,"createSegment");function O(t){return t.indexText===t.worktreeText?"staged":t.indexText===t.headText?"unstaged":"partial"}u(O,"changeState");function S(t,a){let r=v(t,a),n=[],e=0,s=0,d=0;for(;d<r.length;){let c=l(r[d]);if(!c.added&&!c.removed){e+=c.value.length,s+=c.value.length,d++;continue}let g={head:e,current:s};for(;d<r.length&&(l(r[d]).added||l(r[d]).removed);){let i=l(r[d]);i.removed?e+=i.value.length:s+=i.value.length,d++}n.push({headStart:g.head,headEnd:e,currentStart:g.current,currentEnd:s})}return n}u(S,"collectRawChanges");function I(t,a,r){let n=[];for(let e of t){let s=n.at(-1);if(s!==void 0&&p(r.slice(s.currentEnd,e.currentStart))<=f*2&&p(a.slice(s.headEnd,e.headStart))<=f*2){n[n.length-1]={headStart:s.headStart,headEnd:e.headEnd,currentStart:s.currentStart,currentEnd:e.currentEnd};continue}n.push(e)}return n}u(I,"mergeNearbyChanges");function x(t,a,r){return{start:y(t,"start",r),end:y(a,"end",r)}}u(x,"projectHeadRange");function y(t,a,r){let n=0;for(let e of r){if(t<e.headStart)return t+n;if(e.headStart===e.headEnd&&t===e.headStart)return a==="start"?e.currentStart:e.currentEnd;if(t===e.headStart)return e.currentStart;if(t<e.headEnd)return a==="start"?e.currentStart:e.currentEnd;if(t===e.headEnd)return e.currentEnd;n=e.currentEnd-e.headEnd}return t+n}u(y,"projectHeadBoundary");function j(t,a){return t.slice(0,a).split(/(?<=\n)/u).filter(Boolean).slice(-f)}u(j,"linesBefore");function B(t,a){return t.slice(a).split(/(?<=\n)/u).filter(Boolean).slice(0,f)}u(B,"linesAfter");function R(t,a){return p(t.slice(0,a))+1}u(R,"lineAtOffset");function p(t){return[...t.matchAll(/\n/gu)].length}u(p,"lineBreakCount");function H(t){return w("sha256").update(t).digest("hex")}u(H,"sha256");function L(t,a){for(let r=G;r<=t.length;r++){let n=t.slice(0,r);if(a.filter(e=>e.startsWith(n)).length===1)return n}return t}u(L,"shortestUniquePrefix");export{P as a,U as b,_ as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c,d,e as u}from"./chunk-T2RPMEM2.js";import{a as r}from"./chunk-EI7MMDWY.js";function E(t,o){let s=r(()=>{let e,i={plugin:o,accept(g){if(e!==void 0)throw new Error(`Plugin ${o.id} registration was accepted more than once`);e=g}};return t.events.emit(d,i),e},"announce"),n=r(()=>{},"unsubscribe");n=t.events.on(c,e=>{if(!u(e))throw new Error("Invalid pi-agent-search core readiness event");let i=s();if(i===void 0)throw new Error("pi-agent-search core announced readiness without accepting the plugin");n(),i.catch(()=>{})}),t.on("session_shutdown",n);let a=s();if(a!==void 0)return n(),a}r(E,"connectSearchPlugin");export{E as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as j,b as _,c as B}from"./chunk-DEP55R35.js";import{a as U,b as M}from"./chunk-U4D6FT66.js";import{a as H}from"./chunk-ERVMDQGX.js";import{a as R,b as S}from"./chunk-VFBLX4TG.js";import{a as N}from"./chunk-ORAPGW7W.js";import{a as $,b as D}from"./chunk-JASLOB2X.js";import{a as O}from"./chunk-EEH4WYI7.js";import{a as L,b as F}from"./chunk-266RH77Z.js";import{a as I}from"./chunk-2SKAED2I.js";import{a as x}from"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import{access as te}from"node:fs/promises";import ne from"node:path";var V={protocol:R,apiVersion:1,id:"changes",setup(r){r.addSetupCheck({id:"git",async inspect(e){return await re(e.cwd)?await U("git",e.cwd,e.env)?{}:{actions:[{id:"git-unavailable",message:"Git integration is unavailable because Git was not found"}]}:{}}}),r.addCheck({id:"git",title:"Git changes",async run(e){let t=await M("git",["--version"],e.cwd,e.env);return[t.ok?{status:"pass",message:"Git is available",detail:t.detail}:{status:"warn",message:"Git is not available; change anchors and index tools are disabled",detail:t.detail}]}})}};async function re(r){try{return await te(ne.join(r,".git")),!0}catch{return!1}}a(re,"isGitProject");import{mkdtemp as oe,rm as ie,writeFile as ae}from"node:fs/promises";import se from"node:os";import h from"node:path";var w=class r{constructor(e,t){this.executor=e;this.repositoryRoot=t}static{a(this,"GitChangesBackend")}static async create(e,t,n){let o=await e.exec("git",["rev-parse","--show-toplevel"],{cwd:t,...n!==void 0&&{signal:n}});return o.code!==0?{status:"unavailable",reason:"no-worktree",message:o.stderr.trim()||"not inside a Git worktree"}:{status:"ready",backend:new r(e,h.resolve(o.stdout.trim()))}}async readTrackedFile(e,t,n){let o=h.resolve(t,e),i=h.relative(this.repositoryRoot,o);return i===".."||i.startsWith(`..${h.sep}`)||h.isAbsolute(i)?{status:"unavailable",reason:"outside-worktree",message:`${o} is outside ${this.repositoryRoot}`}:this.readTrackedRepositoryFile(i.split(h.sep).join("/"),n)}async readTrackedRepositoryFile(e,t){let n=await this.git(["rev-parse","--verify","HEAD"],t);if(n.code!==0)return{status:"unavailable",reason:"missing-head",message:n.stderr.trim()||"Git HEAD does not exist"};let o=await this.git(["--literal-pathspecs","ls-tree","-z","HEAD","--",e],t);if(o.code!==0)return{status:"unavailable",reason:"head-file-lookup-failed",message:o.stderr.trim()||`could not inspect HEAD:${e}`};let i=de(o.stdout);if(i===void 0)return{status:"untracked"};let d=await this.readBlob(i.blob,"HEAD",e,t);if(d.status!=="found")return d;let c=await this.git(["--literal-pathspecs","ls-files","--stage","-z","--",e],t);if(c.code!==0)return{status:"unavailable",reason:"index-file-lookup-failed",message:c.stderr.trim()||`could not inspect the index entry for ${e}`};let s=ce(c.stdout);if(s.some(({stage:g})=>g!==0))return{status:"unavailable",reason:"conflicted",message:`${e} has unresolved Git index entries`};let u=s.find(({stage:g})=>g===0),l="";if(u!==void 0){let g=await this.readBlob(u.blob,"index",e,t);if(g.status!=="found")return g;l=g.text}return{status:"found",head:n.stdout.trim(),repositoryPath:e,repositoryRoot:this.repositoryRoot,headText:d.text,indexText:l,indexMode:u?.mode??i.mode}}async writeIndexFile(e,t,n,o){let i=await oe(h.join(se.tmpdir(),"pi-agent-index-")),d=h.join(i,"content");try{await ae(d,n,"utf8");let c=await this.git(["hash-object","-w",`--path=${e}`,d],o);if(c.code!==0||c.stdout.trim().length===0)throw new Error(c.stderr.trim()||`could not write a Git blob for ${e}`);let s=await this.git(["update-index","--add","--cacheinfo",t,c.stdout.trim(),e],o);if(s.code!==0)throw new Error(s.stderr.trim()||`could not update the Git index entry for ${e}`)}finally{await ie(i,{recursive:!0,force:!0})}}async readBlob(e,t,n,o){let i=await this.git(["cat-file","blob",e],o);return i.code!==0?{status:"unavailable",reason:t==="HEAD"?"head-file-lookup-failed":"index-file-lookup-failed",message:i.stderr.trim()||`could not read ${t}:${n}`}:{status:"found",text:i.stdout}}git(e,t){return this.executor.exec("git",e,{cwd:this.repositoryRoot,...t!==void 0&&{signal:t}})}};function de(r){let e=r.split("\0",1)[0];if(e===void 0||e.length===0)return;let t=e.indexOf(" ");if(t===-1)return;let[n,o,i]=e.slice(0,t).split(" ",3);return n===void 0||o!=="blob"||i===void 0?void 0:{mode:n,blob:i,path:e.slice(t+1)}}a(de,"parseTreeEntry");function ce(r){return r.split("\0").filter(Boolean).flatMap(e=>{let t=e.indexOf(" ");if(t===-1)return[];let[n,o,i]=e.slice(0,t).split(" ",3),d=Number(i);return n===void 0||o===void 0||!Number.isInteger(d)?[]:[{mode:n,blob:o,stage:d,path:e.slice(t+1)}]})}a(ce,"parseIndexEntries");function z(r){return{exec:a((e,t,n)=>r.exec(e,t,n),"exec")}}a(z,"extensionGitExecutor");var f=class r{constructor(e){this.git=e}static{a(this,"ChangeService")}static async create(e,t,n){let o=await w.create(e,t,n);return o.status==="unavailable"?o:{status:"ready",service:new r(o.backend)}}async inspect(e){if(e.worktreeText.includes("\0"))return{status:"unavailable",reason:"binary",message:"worktree file contains binary content"};let t=await this.git.readTrackedFile(e.source,e.cwd,e.signal);if(t.status!=="found")return t.status==="untracked"?{status:"not-applicable",reason:"untracked"}:t;if(t.headText.includes("\0")||t.indexText.includes("\0"))return{status:"unavailable",reason:"binary",message:"Git file state contains binary content"};let n=j(t.repositoryPath,t.headText,t.indexText,e.worktreeText);return n.length===0?{status:"not-applicable",reason:"clean"}:{status:"applicable",head:t.head,repositoryRoot:t.repositoryRoot,repositoryPath:t.repositoryPath,groups:n}}async changeIndex(e,t,n){let o=await this.inspect(e);if(o.status!=="applicable")return o;let i=o.groups.find(u=>u.selector===t);if(i===void 0)return k(t,o.groups.map(({selector:u})=>u));let d=n==="stage"?"staged":"unstaged";if(i.state===d)return{status:"unchanged",state:d,group:i};let c=x(i.segments[0]),s={head:o.head,repositoryPath:o.repositoryPath,headStart:c.headStart,headEnd:c.headEnd,replacementText:n==="stage"?c.worktreeText:c.headText};try{await this.applyIndexUpdate(s,e.signal)}catch(u){return{status:"unavailable",reason:"index-write-failed",message:ue(u)}}return{status:"applied",state:d,group:i}}async prepareUndo(e,t){let n=await this.inspect(e);if(n.status!=="applicable")return n;let o=n.groups.find(s=>s.selector===t);if(o===void 0)return k(t,n.groups.map(({selector:s})=>s));let i=_(e.worktreeText,o);if(i===void 0)return k(t,n.groups.map(({selector:s})=>s));let d=x(o.segments[0]),c=o.state==="unstaged"?void 0:{head:n.head,repositoryPath:n.repositoryPath,headStart:d.headStart,headEnd:d.headEnd,replacementText:d.headText};return{status:"applied",worktreeText:i,group:o,...c!==void 0&&{indexUpdate:c}}}async applyIndexUpdate(e,t){let n=await this.git.readTrackedRepositoryFile(e.repositoryPath,t);if(n.status!=="found")throw new Error(n.status==="untracked"?`${e.repositoryPath} is no longer tracked by HEAD`:n.message);if(n.head!==e.head)throw new Error(`Git HEAD changed while updating ${e.repositoryPath}`);let o=B(n.headText,n.indexText,e.headStart,e.headEnd,e.replacementText);o!==n.indexText&&await this.git.writeIndexFile(e.repositoryPath,n.indexMode,o,t)}};function k(r,e){return{status:"unavailable",reason:"stale-selector",message:`${r} is not available in the current file state`,availableSelectors:e}}a(k,"staleSelector");function ue(r){return r instanceof Error?r.message:String(r)}a(ue,"errorMessage");var b="pi-agent-ide-changes/change",le=/^CHANGE#[0-9A-F]{4,64}$/,ge=/^[A-Za-z][A-Za-z\d+.-]*:\/\//,E=class extends I{static{a(this,"ChangeTextAnchor")}constructor(e){super(e.selector,e.currentStartLine)}};function Q(r){return{resolver:pe(a(async t=>{if(ge.test(t.source))return;let n=await f.create(r,t.cwd,t.signal);if(n.status!=="ready")throw new Error(n.message);return n.service.inspect({source:t.source,worktreeText:t.content,cwd:t.cwd,...t.signal!==void 0&&{signal:t.signal}})},"inspect"))}}a(Q,"createChangeAnchorRegistration");function pe(r){return{id:"git-change",description:"Use the complete `CHANGE#HASH` shown beside a current Git change.",renderFull(e){return e},renderCompact(e){return e},async tryResolve(e,t){if(!le.test(e))return{kind:"not-handled"};try{let n=await r(t);if(n===void 0)return{kind:"not-handled"};if(n.status==="unavailable")return{kind:"failed",error:new Error(n.message)};let o=n.status==="applicable"?n.groups.find(i=>i.selector===e):void 0;return o===void 0?{kind:"rejected",rejection:{code:"stale",reason:`Change anchor ${e} is stale or unknown`}}:{kind:"resolved",anchor:new E(o)}}catch(n){return{kind:"failed",error:n}}}}}a(pe,"createChangeAnchorResolver");import{diffLines as fe}from"diff";var he="filesystem";function Y(r){return{id:"current-git-changes",async present(e,t){if(t.purpose!=="read"||t.resolvedBy!==he)return e;let n=await f.create(r,t.cwd,t.signal);if(n.status!=="ready")return e;let o=await n.service.inspect({source:t.source,worktreeText:e.content,cwd:t.cwd,...t.signal!==void 0&&{signal:t.signal}});return o.status!=="applicable"?e:me(e,o.groups)}}}a(Y,"createCurrentChangePresenter");function me(r,e){let t=new Map;for(let n of e)xe(r,n,t);return{...r,lines:r.lines.map(n=>we(n,t.get(n.lineNumber)))}}a(me,"presentChangeGroups");function xe(r,e,t){let n=x(e.segments[0]),o=fe(n.headText,n.worktreeText),i=e.currentStartLine,d,c;for(let s of o){let u=Te(s.value);if(s.removed){let l=be(r,i),g=P(t,l.lineNumber),p=l.after?g.after:g.before;for(let m of u){let y={kind:"synthetic",rows:p,index:p.length};p.push({marker:"-",prefix:"|",content:m}),d??=y,c=y}continue}if(s.added){for(let l of u){let g=P(t,i),p={kind:"current",lineNumber:i};g.added=!0,d??=p,c=p,i++}continue}i+=u.length}if(d!==void 0&&c!==void 0){let s=`${e.selector} \xB7 ${e.state}`;ye(d,c)?G(t,d,`<!-- change: ${s} -->`):(G(t,d,`<!-- change-begin: ${s} -->`),G(t,c,`<!-- change-end: ${s} -->`))}}a(xe,"presentChangeGroup");function ye(r,e){return r.kind==="current"&&e.kind==="current"?r.lineNumber===e.lineNumber:r.kind==="synthetic"&&e.kind==="synthetic"?r.rows===e.rows&&r.index===e.index:!1}a(ye,"sameTarget");function G(r,e,t){if(e.kind==="current"){P(r,e.lineNumber).annotations.push(t);return}let n=x(e.rows[e.index]);e.rows[e.index]={...n,suffix:`${n.suffix??""} ${t}`}}a(G,"annotateTarget");function we(r,e){if(e===void 0)return r;let t=e.annotations.length===0?"":` ${e.annotations.join(" ")}`;return{...r,presentation:{...r.presentation,...e.added&&{marker:"+"},before:[...r.presentation?.before??[],...e.before],after:[...e.after,...r.presentation?.after??[]],suffix:`${r.presentation?.suffix??""}${t}`}}}a(we,"presentLine");function P(r,e){let t=r.get(e);if(t!==void 0)return t;let n={before:[],after:[],annotations:[],added:!1};return r.set(e,n),n}a(P,"presentationsFor");function be(r,e){return e<=r.lines.length?{lineNumber:Math.max(1,e),after:!1}:{lineNumber:r.lines.length,after:!0}}a(be,"placementFor");function Te(r){if(r.length===0)return[];let e=r.split(/\r\n|\r|\n/u);return e.at(-1)===""&&e.pop(),e}a(Te,"splitLines");var T=class{static{a(this,"IndexMutationQueue")}tail=Promise.resolve();run(e){let t=this.tail.then(e,e);return this.tail=t.then(()=>{},()=>{}),t}};import{createHash as Ce}from"node:crypto";import{realpathSync as ve}from"node:fs";import X from"node:path";import{fileURLToPath as ke}from"node:url";var C=class{static{a(this,"LastTextTransactionStore")}#e=new Map;observe(e){let t=K(e.resourceSource,e.cwd);if(e.intent!=="edit"||!e.existed||e.before.content===e.after.content){this.#e.delete(t);return}this.#e.set(t,{before:e.before.content,afterDigest:q(e.after.content)})}restore(e,t,n){let o=K(e,t),i=this.#e.get(o);if(i===void 0)throw new Error(`No last text transaction is available for ${e}.`);if(i.afterDigest!==q(n))throw this.#e.delete(o),new Error(`${e} changed after its last text transaction; refusing to overwrite newer text.`);return i.before}};function K(r,e){return r.startsWith("file://")?W(ke(new URL(r))):/^[a-z][a-z\d+.-]*:/iu.test(r)?r:W(X.resolve(e,r))}a(K,"sourceKey");function W(r){try{return ve.native(r)}catch{return X.normalize(r)}}a(W,"canonicalFile");function q(r){return Ce("sha256").update(r).digest("hex")}a(q,"textDigest");import{readFile as Ee}from"node:fs/promises";import Ge from"node:path";import{defineTool as Pe,withFileMutationQueue as Ae}from"@earendil-works/pi-coding-agent";import{Type as A}from"typebox";var Ie=A.Object({file:A.String({description:"Path to the tracked text file"}),change:A.String({description:"Complete CHANGE#HASH anchor shown by read",pattern:"^CHANGE#[0-9A-F]{4,64}$"})},{additionalProperties:!1});function J(r,e,t){r.registerTool(Z("stage",e,t)),r.registerTool(Z("unstage",e,t))}a(J,"registerIndexChangeTools");function Z(r,e,t){let n=r==="stage"?"staged":"unstaged",o=r==="stage"?"Staged":"Unstaged";return Pe({name:r,label:r,promptSnippet:`${o.slice(0,-1)} a selected Git change`,description:`${o.slice(0,-1)} one current Git change selected by a CHANGE# anchor without changing the worktree.`,promptGuidelines:[`You can use ${r} with a complete \`CHANGE#...\` anchor to ${r} only that current Git change without changing the worktree.`],parameters:Ie,async execute(i,d,c,s,u){let l=Re(d.file,u.cwd);return Ae(l,()=>t.run(async()=>{let g=await Ee(l,"utf8"),p=await f.create(e,u.cwd,c);if(p.status!=="ready")throw new Error(p.message);let m=await p.service.changeIndex({source:l,worktreeText:g,cwd:u.cwd,...c!==void 0&&{signal:c}},d.change,r);if(m.status==="unavailable")throw new Error(m.message);if(m.status==="not-applicable")throw new Error(`${r} is not applicable to ${l}: ${m.reason}`);let y=m.status==="unchanged";return{content:[{type:"text",text:y?`${d.change} is already ${n} in ${d.file}.`:`${o} ${d.change} in ${d.file}.`}],details:{action:r,change:d.change,file:l,state:n,unchanged:y}}}))}})}a(Z,"createIndexChangeTool");function Re(r,e){let t=r.startsWith("@")?r.slice(1):r;return Ge.resolve(e,t)}a(Re,"resolveFile");import{diffChars as Se}from"diff";import{Type as v}from"typebox";var He=v.Object({file:v.Optional(v.String({description:"File to restore; may be omitted to inherit the previous batched source"})),change:v.String({description:"Complete CHANGE#HASH anchor shown by read, or last for this file's latest text-editor transaction",pattern:"^(?:CHANGE#[0-9A-F]{4,64}|last)$"})},{additionalProperties:!1});function ee(r,e,t){return{name:"undo",description:"Restore one selected current Git change to HEAD in the worktree and index, or restore one file to its state before its latest text-editor transaction.",promptSnippet:"Restore a Git change or the latest text edit",promptGuidelines:["You can use undo with a complete `CHANGE#...` anchor to restore that current Git change to HEAD in both the worktree and index.",'You can use undo with `change: "last"` to restore a file to its state before its latest text-editor transaction.'],parameters:He,intent:"restore",source:{field:"file",inherited:!0},anchors:[{field:"change",sourceField:"file",kinds:[b],nonAnchorValues:["last"]}],async mutate(n,o){let i=n.sourceFor("file"),d,c;if(o.change==="last")d=e.restore(i,n.cwd,n.sourceDocument.content);else{await n.resolveAnchor("change");let s=await f.create(r,n.cwd,n.signal);if(s.status!=="ready")throw new Error(s.message);let u=await s.service.prepareUndo({source:i,worktreeText:n.sourceDocument.content,cwd:n.cwd,...n.signal!==void 0&&{signal:n.signal}},o.change);if(u.status!=="applied")throw u.status==="unavailable"?new Error(u.message):new Error(`Undo is not applicable to ${i}: ${u.reason}`);if(d=u.worktreeText,u.indexUpdate!==void 0){let l=u.indexUpdate;c=a(()=>t.run(()=>s.service.applyIndexUpdate(l,n.signal)),"afterWrite")}}return{edits:new Map([[i,{changes:$e(n.sourceDocument.content,d),action:"edited"}]]),...c!==void 0&&{afterWrite:c}}}}}a(ee,"createUndoMutationTool");function $e(r,e){let t=[],n=0,o,i=0,d="",c=a(()=>{o!==void 0&&(t.push({from:o,to:o+i,insert:d}),o=void 0,i=0,d="")},"flush");for(let s of Se(r,e)){if(!s.added&&!s.removed){c(),n+=s.value.length;continue}o??=n,s.removed?(n+=s.value.length,i+=s.value.length):d+=s.value}return c(),t}a($e,"createTextChanges");async function De(r){if(process.argv.includes("--old-tools"))return;let e=z(r),t=new C,n=new T,o=Y(e),i=Q(e),d={protocol:$,apiVersion:D,id:"current-git-changes",setup(s){s.addView({view:"changes",presenter:o}),s.describe("Adds CHANGE anchors and Git index state to current changes in tracked text files that request the `changes` view. Use these anchors with undo, stage, and unstage."),s.addPromptGuideline('You can use read with `views: ["changes"]` to add `CHANGE#...` anchors and Git index state for current file changes.')}},c={protocol:L,apiVersion:F,id:"current-git-changes",setup(s){s.addAnchorResolver({...i,kind:b,type:"auxiliary"}),s.onDidEdit(u=>{t.observe(u)}),s.addMutationTool(ee(e,t,n)),s.addTextPresenter({presenter:o})}};await Promise.all([H(r,V),N(r,d),O(r,c)]),J(r,e,n)}a(De,"registerGitChanges");export{De as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as u,f as E,k as a}from"./chunk-266RH77Z.js";import{a as n}from"./chunk-EI7MMDWY.js";function T(o,r){let s=n(()=>{let e,i={plugin:r,accept(c){if(e!==void 0)throw new Error(`Plugin ${r.id} registration was accepted more than once`);e=c}};return o.events.emit(E,i),e},"announce"),t=n(()=>{},"unsubscribe");t=o.events.on(u,e=>{if(!a(e))throw new Error("Invalid pi-agent-text-editor core readiness event");let i=s();if(i===void 0)throw new Error("pi-agent-text-editor core announced readiness without accepting the plugin");t(),i.catch(()=>{})}),o.on("session_shutdown",t);let d=s();if(d!==void 0)return t(),d}n(T,"connectTextEditorPlugin");export{T as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var c=Object.defineProperty;var d=(a,b)=>c(a,"name",{value:b,configurable:!0});export{d as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as d,d as u,e as a}from"./chunk-VFBLX4TG.js";import{a as t}from"./chunk-EI7MMDWY.js";function E(r,i){let s=t(()=>{let o,n={plugin:i,accept(f){if(o!==void 0)throw new Error(`Doctor plugin ${i.id} was accepted more than once`);o=f}};return r.events.emit(u,n),o},"announce"),e=t(()=>{},"unsubscribe");e=r.events.on(d,o=>{if(!a(o))throw new Error("Invalid doctor core readiness event");let n=s();if(n===void 0)throw new Error("Doctor core did not accept the plugin");e(),n.catch(()=>{})}),r.on("session_shutdown",e);let c=s();if(c!==void 0)return e(),c}t(E,"connectDoctorPlugin");export{E as a};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as o}from"./chunk-EI7MMDWY.js";function G(t,e){if(e.length===0)return;let c=t.trim();if(c.length===0||/[\r\n]/u.test(c))throw new TypeError("Content provider summary must be one non-empty line");return[c,...e.map(({id:a,description:r})=>`- \`${W(a)}\` \u2014 ${r}`)].join(`
|
|
2
|
+
`)}o(G,"renderContentDescription");function W(t){return t.replaceAll("`","\\`")}o(W,"escapeInlineCode");import{Type as i}from"typebox";import{Value as et}from"typebox/value";import{Type as n}from"typebox";import{Value as Y}from"typebox/value";var u={additionalProperties:!0},E=n.Function([],n.Unknown()),C=n.String({minLength:1}),B=n.Object({type:n.Literal("text"),text:n.String(),textSignature:n.Optional(n.String())},u),z=n.Object({type:n.Literal("image"),data:n.String(),mimeType:n.String()},u),J=n.Object({type:n.Literal("custom"),kind:C,data:n.Unknown()},u),M=n.Array(n.Union([B,z,J]),{minItems:1}),L=n.Union([n.Object({source:C,link:n.Optional(C),read:E,write:n.Optional(n.Never())},u),n.Object({source:C,link:n.Optional(C),read:n.Optional(n.Never()),write:E},u),n.Object({source:C,link:n.Optional(C),read:E,write:E},u)]),Q=n.Object({id:C,tryResolve:E},u),X=n.Union([n.Object({kind:n.Literal("not-handled")},u),n.Object({kind:n.Literal("resolved"),resource:L},u),n.Object({kind:n.Literal("failed"),error:n.Unknown()},u)]);function A(t){return x(M,t)?b(()=>t.every(e=>e.type!=="text"||!("textSignature"in e)||typeof e.textSignature=="string")):!1}o(A,"isAgentContent");function H(t){return x(L,t)?b(()=>{let e=t,c=!("read"in e)||typeof e.read=="function",a=!("write"in e)||typeof e.write=="function";return c&&a}):!1}o(H,"isResource");function Z(t){return x(Q,t)}o(Z,"isResourceResolver");function tt(t){return x(X,t)?b(()=>{let e=t;return e.kind!=="resolved"||H(e.resource)}):!1}o(tt,"isResourceResolutionAttempt");function x(t,e){return b(()=>Y.Check(t,e))}o(x,"safeCheck");function b(t){try{return t()}catch{return!1}}o(b,"safeEvaluate");var d={additionalProperties:!0},nt=i.Function([],i.Unknown()),k=i.String({minLength:1}),ot=i.Object({provider:k,capability:i.Union([i.Literal("read"),i.Literal("write")])},d),rt=i.Object({source:k,bytes:i.Unknown(),mediaType:i.Optional(i.String())},d),it=i.Object({signal:i.Optional(i.Unknown())},d),st=i.Object({id:k,description:k,tryConvert:nt},d),ct=i.Union([i.Object({kind:i.Literal("not-handled")},d),i.Object({kind:i.Literal("converted"),content:i.Unknown()},d),i.Object({kind:i.Literal("failed"),error:i.Unknown()},d)]),at=i.Object({target:i.Unknown(),converter:i.Unknown(),priority:i.Optional(i.Number())},d);function f(t){return g(ot,t)&&v(()=>t.provider.trim().length>0)}o(f,"isContentTarget");function j(t){return g(rt,t)?v(()=>{let e=t;return e.bytes instanceof Uint8Array&&(!("mediaType"in e)||typeof e.mediaType=="string")}):!1}o(j,"isContentInput");function I(t){return g(it,t)?v(()=>{let e=t;return!("signal"in e)||e.signal instanceof AbortSignal}):!1}o(I,"isContentConversionContext");function q(t){return g(st,t)?v(()=>{let e=t;return e.id.trim().length>0&&e.description.trim().length>0&&!/[\r\n]/u.test(e.description)}):!1}o(q,"isContentConverter");function _(t){return g(ct,t)?v(()=>{let e=t;return e.kind!=="converted"||A(e.content)}):!1}o(_,"isContentConversionAttempt");function m(t){return g(at,t)?v(()=>{let e=t;return f(e.target)&&q(e.converter)&&(!("priority"in e)||typeof e.priority=="number"&&Number.isFinite(e.priority))}):!1}o(m,"isContentConverterRegistration");function g(t,e){return v(()=>et.Check(t,e))}o(g,"safeCheck");function v(t){try{return t()}catch{return!1}}o(v,"safeEvaluate");var N=class extends Error{static{o(this,"UnsupportedContentError")}source;target;constructor(e,c){super(`No content converter for ${e} in ${c.provider}/${c.capability}`),this.name="UnsupportedContentError",this.source=e,this.target=c}};function V(t){if(!f(t))throw new TypeError("Invalid content target");let e={...t},c=[],a=o(()=>[...c].sort((r,s)=>r.priority-s.priority||r.order-s.order),"snapshotConverters");return{target:e,register(r){if(!m(r))throw new TypeError("Invalid content converter registration");if(!R(e,r.target))throw new Error(`Content converter ${r.converter.id} targets ${r.target.provider}/${r.target.capability}, not ${e.provider}/${e.capability}`);if(c.some(({converter:s})=>s.id===r.converter.id))throw new Error(`Content converter ${r.converter.id} is already registered for ${e.provider}/${e.capability}`);c.push({converter:r.converter,priority:r.priority??0,order:c.length})},listDescriptions(){return a().map(({converter:r})=>({id:r.id,description:r.description}))},async convert(r,s){if(!j(r))throw new TypeError("Invalid content input");if(!I(s))throw new TypeError("Invalid content conversion context");P(s.signal);let p=a();for(let{converter:O}of p){P(s.signal);let T=await O.tryConvert(r,s);if(P(s.signal),!_(T))throw new TypeError(`Content converter ${O.id} returned an invalid outcome`);if(T.kind!=="not-handled"){if(T.kind==="failed")throw T.error;return T.content}}throw new N(r.source,e)}}}o(V,"createContentRunner");function R(t,e){return t.provider===e.provider&&t.capability===e.capability}o(R,"targetsEqual");function P(t){t?.throwIfAborted()}o(P,"throwIfAborted");import{Type as l}from"typebox";import{Value as pt}from"typebox/value";var y="pi-agent-resource/content-conversion",S=2,w=`${y}/host/ready`,h=`${y}/converter/register`,K={additionalProperties:!0},ut=l.Function([],l.Unknown()),Ct=l.Object({protocol:l.Literal(y),apiVersion:l.Literal(S),target:l.Unknown()},K),dt=l.Object({registration:l.Unknown(),accept:ut},K);function D(t){return F(Ct,t)&&$(()=>f(t.target))}o(D,"isContentHostReady");function U(t){return F(dt,t)&&$(()=>m(t.registration))}o(U,"isContentConverterRegistrationRequest");function F(t,e){return $(()=>pt.Check(t,e))}o(F,"safeCheck");function $(t){try{return t()}catch{return!1}}o($,"safeEvaluate");function lt(t,e){let c=V(e),a=t.events.on(h,r=>{if(!U(r))throw new Error("Invalid content converter registration request");if(!R(c.target,r.registration.target))return;let s;try{c.register(r.registration),s=Promise.resolve()}catch(p){s=Promise.reject(p instanceof Error?p:new Error("Content converter registration failed",{cause:p}))}r.accept(s)});return t.on("session_shutdown",a),t.events.emit(w,{protocol:y,apiVersion:S,target:c.target}),{target:c.target,listDescriptions(){return c.listDescriptions()},convert(r,s){return c.convert(r,s)}}}o(lt,"createContentHost");function mt(t,e){if(!m(e))throw new TypeError("Invalid content converter registration");let c=o(()=>{let s,p={registration:e,accept(O){if(s!==void 0)throw new Error(`Content converter ${e.converter.id} registration was accepted more than once`);s=O}};return t.events.emit(h,p),s},"announce"),a=o(()=>{},"unsubscribe");a=t.events.on(w,s=>{if(!D(s))throw new Error("Invalid content conversion host readiness event");if(!R(e.target,s.target))return;let p=c();if(p===void 0)throw new Error(`${s.target.provider}/${s.target.capability} announced readiness without accepting content converter ${e.converter.id}`);a(),p.catch(()=>{})}),t.on("session_shutdown",a);let r=c();if(r!==void 0)return a(),r}o(mt,"connectContentConverter");export{G as a,A as b,H as c,Z as d,tt as e,f,j as g,I as h,q as i,_ as j,m as k,N as l,V as m,R as n,y as o,S as p,w as q,h as r,D as s,U as t,lt as u,mt as v};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{a as s}from"./chunk-XNXQYPVT.js";import{a as l}from"./chunk-EEH4WYI7.js";import{a as c,b as u}from"./chunk-266RH77Z.js";import{a}from"./chunk-EI7MMDWY.js";function g(r,n){let t=Object.keys(n.properties??{}),o=Object.keys(r),e=-1;for(let d of o){let i=t.indexOf(d);if(i===-1){if(n.additionalProperties===!1)return{observedOrder:o,expectedOrder:t,unknownKey:d};continue}if(i<e)return{observedOrder:o,expectedOrder:t};e=i}}a(g,"checkArgumentOrder");function p(r,n){let t=n.unknownKey?` Unknown key: "${n.unknownKey}".`:"";return{annotation:{kind:"custom",label:"Argument Order",color:"warning"},message:{customType:"text-editor-argument-order-block",content:`[SYSTEM] ${r} blocked: argument order violation.${t}
|
|
2
|
+
Observed order: ${n.observedOrder.join(", ")||"(none)"}.
|
|
3
|
+
Expected schema order: ${n.expectedOrder.join(", ")||"(none)"}.
|
|
4
|
+
Call ${r} again with arguments in schema order.`,display:!1,details:n}}}a(p,"makeBlockResult");function m(r){let n=new Map,t=[],o={name:"text-editor-argument-order-guard",blockExecution:!0,toolNames:t,intercept(e){let d=n.get(e.toolCall.name);if(!d)return;let i=g(e.partialArgs??e.args,d);return i?p(e.toolCall.name,i):void 0}};return s(r,o),e=>{n.set(e.name,e.schema),t.push(e.name),s(r,o)}}a(m,"registerArgumentOrderGuard");async function f(r){await l(r,{protocol:c,apiVersion:u,id:"text-editor-argument-order",setup(t){let o=m(r);t.onMutationTool(e=>{o({name:e.name,schema:e.parameters})})}})}a(f,"registerTextEditorArgumentOrder");export{f as a};
|