pi-agent-ide 0.9.8 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +72 -0
- package/README.md +5 -3
- package/dist/chunk-26SMC6OS.js +2 -0
- package/dist/chunk-2EY3LEZ7.js +1 -0
- package/dist/chunk-2QCE7GOV.js +1 -0
- package/dist/chunk-3BRGWFEI.js +2 -0
- package/dist/chunk-3JBQYLJ4.js +5 -0
- package/dist/chunk-3KM5DSWL.js +37 -0
- package/dist/chunk-3V3OQO5S.js +118 -0
- package/dist/chunk-45EJ4762.js +33 -0
- package/dist/chunk-4DLSZYUO.js +1 -0
- package/dist/chunk-54EFJYUB.js +1 -0
- package/dist/{chunk-5DN2XBVI.js → chunk-5TPYHUJV.js} +1 -1
- package/dist/{chunk-KQV2ZXLP.js → chunk-6DC2Q5BI.js} +1 -1
- package/dist/chunk-72WO7H5T.js +1 -0
- package/dist/chunk-72X24ARV.js +2 -0
- package/dist/chunk-7OAAM5FL.js +1 -0
- package/dist/chunk-AB6RSWMB.js +23 -0
- package/dist/chunk-ASVMQMPX.js +10 -0
- package/dist/chunk-BW3XONMZ.js +1 -0
- package/dist/chunk-C327T6YP.js +19 -0
- package/dist/{chunk-R2U5WXYR.js → chunk-D23NS4VV.js} +1 -1
- package/dist/chunk-E4V4VNRM.js +3 -0
- package/dist/chunk-E7JBYW43.js +1 -0
- package/dist/chunk-GDIF3WT6.js +12 -0
- package/dist/chunk-GNYFA6FS.js +2 -0
- package/dist/{chunk-DHOIQZUF.js → chunk-GQXZEOND.js} +1 -1
- package/dist/chunk-GT2JPOBM.js +1 -0
- package/dist/chunk-GTZOIJCH.js +1 -0
- package/dist/chunk-HRZAIZGR.js +1 -0
- package/dist/{chunk-H6FEBUAP.js → chunk-HSAGZWPO.js} +1 -1
- package/dist/{chunk-2DSY4U73.js → chunk-I3G6K7QU.js} +1 -1
- package/dist/chunk-IRLWXPL4.js +7 -0
- package/dist/chunk-IZTOXSTR.js +6 -0
- package/dist/chunk-J5CKSIH7.js +1 -0
- package/dist/chunk-JKM4E5VB.js +5 -0
- package/dist/chunk-JMCI2ZE2.js +3 -0
- package/dist/{chunk-YZTVC7ME.js → chunk-JY63UUC2.js} +1 -1
- package/dist/chunk-KM4NOIOB.js +5 -0
- package/dist/chunk-L2YDUMZC.js +13 -0
- package/dist/chunk-MCHU3BLO.js +53 -0
- package/dist/chunk-MJMRV76H.js +1 -0
- package/dist/chunk-MMQIHUU5.js +1 -0
- package/dist/chunk-MNAIMZRO.js +9 -0
- package/dist/chunk-NKI4TZSS.js +2 -0
- package/dist/chunk-NSBRKTZ7.js +1 -0
- package/dist/chunk-NWCTAVGR.js +4 -0
- package/dist/chunk-O2C3F3MA.js +1 -0
- package/dist/chunk-OA26FH5G.js +1 -0
- package/dist/chunk-OEEE5BLN.js +16 -0
- package/dist/chunk-OLMACWQX.js +11 -0
- package/dist/{chunk-72FL5FHZ.js → chunk-PBMHSK6J.js} +1 -1
- package/dist/chunk-QCAGAJHJ.js +1 -0
- package/dist/{chunk-P7FUD4WY.js → chunk-QR7JR3P2.js} +1 -1
- package/dist/chunk-QSU5AEKW.js +1 -0
- package/dist/chunk-QUK5ZEYX.js +1 -0
- package/dist/chunk-R7576HPO.js +25 -0
- package/dist/{chunk-B5UJCNQU.js → chunk-RNDSWVJF.js} +1 -1
- package/dist/chunk-RYJEEBET.js +1 -0
- package/dist/chunk-S4GTWS2J.js +6 -0
- package/dist/chunk-SF44YQCB.js +2 -0
- package/dist/chunk-SJQGFUXR.js +6 -0
- package/dist/chunk-SKZTIAE4.js +4 -0
- package/dist/chunk-SZRC24OB.js +1 -0
- package/dist/chunk-T5PXAYWC.js +1 -0
- package/dist/chunk-TIZ4QDF3.js +1 -0
- package/dist/chunk-UN3XLVPR.js +18 -0
- package/dist/chunk-V2LLMBTA.js +1 -0
- package/dist/chunk-VB5P3TXJ.js +111 -0
- package/dist/chunk-VNG4QPPT.js +12 -0
- package/dist/chunk-VNNAVC4S.js +15 -0
- package/dist/chunk-VPBGKSFI.js +3 -0
- package/dist/chunk-VQ2RA43A.js +7 -0
- package/dist/chunk-VWYI4WF7.js +3 -0
- package/dist/chunk-W25HNEMR.js +4 -0
- package/dist/chunk-X7CHS7JB.js +1 -0
- package/dist/chunk-XEPCURYZ.js +1 -0
- package/dist/chunk-XKVU6AAS.js +7 -0
- package/dist/chunk-XLTAP5YC.js +24 -0
- package/dist/chunk-XQMNVPNS.js +1 -0
- package/dist/chunk-YI32H7Z2.js +4 -0
- package/dist/chunk-ZYG5E3DI.js +9 -0
- package/dist/entry-0.js +1 -1
- package/dist/entry-12.js +1 -1
- package/dist/entry-15.js +1 -1
- package/dist/entry-17.js +1 -1
- package/dist/entry-18.js +1 -1
- package/dist/entry-19.js +1 -1
- package/dist/entry-20.js +1 -1
- package/dist/entry-21.js +1 -1
- package/dist/entry-22.js +1 -1
- package/dist/entry-27.js +1 -1
- package/dist/entry-28.js +1 -1
- package/dist/entry-31.js +2 -2
- package/dist/entry-32.js +1 -1
- package/dist/entry-33.js +1 -1
- package/dist/entry-34.js +1 -1
- package/dist/entry-35.js +1 -1
- package/dist/entry-36.js +1 -1
- package/dist/entry-37.js +1 -1
- package/dist/entry-38.js +19 -13
- package/dist/entry-4.js +1 -1
- package/dist/entry-40.js +1 -1
- package/dist/entry-41.js +1 -1
- package/dist/entry-43.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +1 -1
- package/dist/entry-48.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +1 -1
- package/dist/entry-51.js +1 -1
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-54.js +1 -1
- package/dist/entry-55.js +1 -1
- package/dist/entry-56.js +1 -1
- package/dist/entry-57.js +1 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-59.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-61.js +1 -1
- package/dist/entry-62.js +1 -1
- package/dist/entry-63.js +1 -1
- package/dist/entry-64.js +1 -1
- package/dist/entry-65.js +1 -1
- package/dist/entry-66.js +1 -1
- package/dist/entry-67.js +1 -1
- package/dist/entry-68.js +1 -0
- package/dist/entry-69.js +1 -1
- package/dist/entry-71.js +1 -1
- package/dist/entry-72.js +0 -1
- package/dist/entry-73.js +1 -1
- package/dist/entry-74.js +1 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-76.js +1 -1
- package/dist/entry-77.js +1 -1
- package/dist/entry-78.js +1 -0
- package/dist/entry-79.js +1 -1
- package/dist/entry-8.js +1 -1
- package/dist/entry-80.js +1 -0
- package/dist/entry-81.js +0 -1
- package/dist/entry-82.js +1 -1
- package/dist/entry-83.js +1 -1
- package/dist/entry-84.js +0 -1
- package/dist/entry-85.js +1 -1
- package/dist/entry-86.js +1 -2
- package/dist/entry-87.js +1 -1
- package/dist/entry-88.js +1 -1
- package/dist/entry-89.js +1 -1
- package/dist/entry-90.js +1 -1
- package/dist/entry-91.js +1 -3
- package/dist/entry-92.js +1 -1
- package/dist/entry-93.js +1 -1
- package/dist/entry-94.js +1 -1
- package/dist/entry-95.js +3 -0
- package/dist/entry-96.js +1 -0
- package/dist/entry-97.js +1 -0
- package/dist/entry-98.js +1 -0
- package/dist/pi-agent-ide.js +26 -13
- package/docs/agent-guides/ast-search.md +15 -4
- package/docs/agent-guides/debugger.md +1 -1
- package/docs/agent-guides/git-changes.md +1 -0
- package/docs/agent-guides/ssh.md +27 -7
- package/docs/agent-guides/terminal.md +4 -0
- package/docs/configuration.md +65 -11
- package/docs/development.md +4 -0
- package/docs/extensions.md +6 -4
- package/docs/nightly.md +7 -1
- package/docs/releases.md +1 -1
- package/docs/structured-results.md +29 -15
- package/docs/tools.md +95 -29
- package/docs/user-hooks.md +1 -1
- package/node_modules/pi-agent-doctor/package.json +1 -1
- package/node_modules/pi-agent-doctor/src/catalog.ts +2 -0
- package/node_modules/pi-agent-doctor/src/executable.ts +1 -1
- package/node_modules/pi-agent-documentation/package.json +1 -1
- package/node_modules/pi-agent-filesystem/package.json +7 -7
- package/node_modules/pi-agent-filesystem/src/file-write-lock.ts +6 -4
- package/node_modules/pi-agent-filesystem/src/replace-file.ts +5 -2
- package/node_modules/pi-agent-filesystem/src/resolver.ts +26 -10
- package/node_modules/pi-agent-filesystem-image/package.json +3 -3
- package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
- package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
- package/node_modules/pi-agent-filesystem-text/package.json +3 -3
- package/node_modules/pi-agent-ide-ast/package.json +13 -13
- package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +56 -65
- package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +197 -130
- package/node_modules/pi-agent-ide-ast/src/ast/read-text.ts +2 -1
- package/node_modules/pi-agent-ide-ast/src/ast-grep-binary.ts +46 -0
- package/node_modules/pi-agent-ide-ast/src/doctor-plugin.ts +119 -97
- package/node_modules/pi-agent-ide-ast/src/extension.ts +9 -24
- package/node_modules/pi-agent-ide-ast/src/outline-page.ts +96 -0
- package/node_modules/pi-agent-ide-ast/src/outline-resolver.ts +42 -78
- package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +5 -1
- package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +2 -1
- package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +24 -5
- package/node_modules/pi-agent-ide-ast/src/search-presentation.ts +2 -1
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +406 -200
- package/node_modules/pi-agent-ide-ast/src/tool-ast-search.ts +27 -9
- package/node_modules/pi-agent-ide-ast/src/tool-outline.ts +191 -0
- package/node_modules/pi-agent-ide-changes/package.json +8 -8
- package/node_modules/pi-agent-ide-changes/src/changes/change-service.ts +63 -20
- package/node_modules/pi-agent-ide-changes/src/changes/change-types.ts +1 -0
- package/node_modules/pi-agent-ide-changes/src/changes/git-changes-backend.ts +25 -0
- package/node_modules/pi-agent-ide-changes/src/changes/git-paths.ts +13 -6
- package/node_modules/pi-agent-ide-changes/src/index-mutation-queue.ts +12 -8
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +88 -78
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +29 -3
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-formatter/src/formatter.ts +39 -3
- package/node_modules/pi-agent-ide-formatter/src/rustfmt.ts +101 -0
- package/node_modules/pi-agent-ide-languages/package.json +2 -2
- package/node_modules/pi-agent-ide-lint/package.json +7 -7
- package/node_modules/pi-agent-ide-lint/src/catalog.ts +20 -14
- package/node_modules/pi-agent-ide-lint/src/registry.ts +2 -2
- package/node_modules/pi-agent-ide-lsp/index.ts +15 -88
- package/node_modules/pi-agent-ide-lsp/package.json +12 -12
- package/node_modules/pi-agent-ide-lsp/src/catalog.ts +21 -9
- package/node_modules/pi-agent-ide-lsp/src/lsp/clang-coverage.ts +265 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/clangd-launch.ts +48 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +94 -11
- package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +514 -207
- package/node_modules/pi-agent-ide-lsp/src/lsp/corrected-names.ts +222 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/declaration-scan.ts +116 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/diagnostics.ts +20 -1
- package/node_modules/pi-agent-ide-lsp/src/lsp/files-containing.ts +70 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/index.ts +1 -1
- package/node_modules/pi-agent-ide-lsp/src/lsp/initialization-options.ts +37 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/line-breaks.ts +16 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +185 -131
- package/node_modules/pi-agent-ide-lsp/src/lsp/missing-sources.ts +21 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/navigation.ts +45 -24
- package/node_modules/pi-agent-ide-lsp/src/lsp/position-map.ts +17 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/project.ts +40 -12
- package/node_modules/pi-agent-ide-lsp/src/lsp/range-match.ts +49 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/rename.ts +16 -5
- package/node_modules/pi-agent-ide-lsp/src/lsp/server-request-handlers.mjs +7 -1
- package/node_modules/pi-agent-ide-lsp/src/lsp/shared-server-host.mjs +133 -37
- package/node_modules/pi-agent-ide-lsp/src/lsp/shared-servers.ts +164 -13
- package/node_modules/pi-agent-ide-lsp/src/lsp/source-changes.ts +18 -6
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +414 -174
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-selectors.ts +424 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbols.ts +67 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/workspace-owner.ts +10 -0
- package/node_modules/pi-agent-ide-lsp/src/name-captures.ts +66 -0
- package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +384 -93
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +356 -79
- package/node_modules/pi-agent-ide-lsp/src/tool-lsp-search.ts +33 -11
- package/node_modules/pi-agent-image/package.json +2 -2
- package/node_modules/pi-agent-image/src/image-converter.ts +13 -2
- package/node_modules/pi-agent-invariant/package.json +1 -1
- package/node_modules/pi-agent-pdf/package.json +2 -2
- package/node_modules/pi-agent-read/package.json +7 -7
- package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +1 -1
- package/node_modules/pi-agent-read/src/api/read-parameters.ts +51 -12
- package/node_modules/pi-agent-read/src/api/tools/read.ts +39 -3
- package/node_modules/pi-agent-read/src/core/extension.ts +80 -3
- package/node_modules/pi-agent-read/src/core/read-core.ts +6 -0
- package/node_modules/pi-agent-read/src/core/tools/read/list-result.ts +79 -0
- package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +45 -4
- package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +18 -9
- package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +16 -3
- package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +37 -9
- package/node_modules/pi-agent-read/src/core/tools/read/result-target.ts +15 -4
- package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +49 -18
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +158 -51
- package/node_modules/pi-agent-resource/package.json +5 -1
- package/node_modules/pi-agent-resource/src/file-text-read.ts +86 -0
- package/node_modules/pi-agent-resource/src/index.ts +54 -0
- package/node_modules/pi-agent-resource/src/json-structured-arguments.ts +131 -0
- package/node_modules/pi-agent-resource/src/line-map.ts +750 -0
- package/node_modules/pi-agent-resource/src/resolver.ts +2 -0
- package/node_modules/pi-agent-resource/src/resource-scheduler.ts +63 -23
- package/node_modules/pi-agent-resource/src/resource.ts +5 -0
- package/node_modules/pi-agent-resource/src/result-targets.ts +693 -66
- package/node_modules/pi-agent-resource/src/script-calls.ts +21 -0
- package/node_modules/pi-agent-resource/src/tool-deadline.ts +199 -0
- package/node_modules/pi-agent-resource/src/tool-result.ts +14 -5
- package/node_modules/pi-agent-resource/src/unchanged-read.ts +62 -0
- package/node_modules/pi-agent-search/package.json +8 -9
- package/node_modules/pi-agent-search/runtime/entry-57.js +0 -1
- package/node_modules/pi-agent-search/src/api/fuzzy.ts +2 -1
- package/node_modules/pi-agent-search/src/api/null-fields.ts +50 -0
- package/node_modules/pi-agent-search/src/api/path-list.ts +68 -0
- package/node_modules/pi-agent-search/src/api/presentation.ts +2 -1
- package/node_modules/pi-agent-search/src/api/search-call-policy.ts +16 -0
- package/node_modules/pi-agent-search/src/api/search-capture.ts +56 -0
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +26 -4
- package/node_modules/pi-agent-search/src/api/search-scope.ts +38 -2
- package/node_modules/pi-agent-search/src/api/search.ts +46 -3
- package/node_modules/pi-agent-search/src/api/structured-result.ts +121 -26
- package/node_modules/pi-agent-search/src/core/extension.ts +75 -42
- package/node_modules/pi-agent-search/src/core/search-config.ts +2 -2
- package/node_modules/pi-agent-search/src/core/search-core.ts +103 -39
- package/node_modules/pi-agent-search-text/index.ts +62 -20
- package/node_modules/pi-agent-search-text/package.json +15 -15
- package/node_modules/pi-agent-search-text/runtime/entry-59.js +1 -0
- package/node_modules/pi-agent-search-text/src/current-matches.ts +314 -0
- package/node_modules/pi-agent-search-text/src/file-search.ts +178 -99
- package/node_modules/pi-agent-search-text/src/fuzzy-search.ts +40 -17
- package/node_modules/pi-agent-search-text/src/persisted-result.ts +3 -8
- package/node_modules/pi-agent-search-text/src/resolvers.ts +395 -103
- package/node_modules/pi-agent-search-text/src/ripgrep.ts +142 -0
- package/node_modules/pi-agent-search-text/src/scoped-search.ts +24 -12
- package/node_modules/pi-agent-search-text/src/search-backend.ts +333 -108
- package/node_modules/pi-agent-search-text/src/search-presentation.ts +6 -0
- package/node_modules/pi-agent-search-text/src/search-query.ts +69 -34
- package/node_modules/pi-agent-search-text/src/search-recipe.ts +80 -8
- package/node_modules/pi-agent-search-text/src/search-renderer.ts +2 -1
- package/node_modules/pi-agent-search-text/src/search-result.ts +10 -1
- package/node_modules/pi-agent-search-text/src/search-session.ts +449 -58
- package/node_modules/pi-agent-search-text/src/tool-file-search.ts +51 -6
- package/node_modules/pi-agent-text/package.json +3 -3
- package/node_modules/pi-agent-text/runtime/entry-63.js +1 -0
- package/node_modules/pi-agent-text/src/index.ts +18 -0
- package/node_modules/pi-agent-text/src/line-anchors.ts +211 -0
- package/node_modules/pi-agent-text/src/no-final-line-break.ts +12 -0
- package/node_modules/pi-agent-text/src/search-highlight.ts +8 -0
- package/node_modules/pi-agent-text/src/source-line.ts +7 -1
- package/node_modules/pi-agent-text/src/text-anchor.ts +34 -3
- package/node_modules/pi-agent-text/src/text-converter.ts +2 -1
- package/node_modules/pi-agent-text/src/text-document.ts +9 -23
- package/node_modules/pi-agent-text/src/text-target.ts +14 -6
- package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
- package/node_modules/pi-agent-text-anchor-constant/runtime/entry-64.js +2 -0
- package/node_modules/pi-agent-text-anchor-exact/index.ts +1 -65
- package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-65.js +0 -1
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-66.js +2 -0
- package/node_modules/pi-agent-text-anchor-exact/src/anchor.ts +185 -184
- package/node_modules/pi-agent-text-anchor-exact/src/anchored-literal-view.ts +122 -0
- package/node_modules/pi-agent-text-anchor-exact/src/fuzzy-worker.ts +2 -1
- package/node_modules/pi-agent-text-anchor-exact/src/literal-match.ts +359 -0
- package/node_modules/pi-agent-text-anchor-exact/src/recovery.ts +1 -0
- package/node_modules/pi-agent-text-anchor-line-hash/index.ts +5 -3
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-67.js +0 -1
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-68.js +2 -0
- package/node_modules/pi-agent-text-anchor-line-hash/src/anchor.ts +92 -67
- package/node_modules/pi-agent-text-anchor-line-hash/src/range-history.ts +105 -0
- package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +22 -17
- package/node_modules/pi-agent-text-editor/index.ts +0 -10
- package/node_modules/pi-agent-text-editor/package.json +37 -26
- package/node_modules/pi-agent-text-editor/runtime/entry-84.js +0 -1
- package/node_modules/pi-agent-text-editor/runtime/entry-85.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-86.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-88.js +2 -0
- package/node_modules/pi-agent-text-editor/src/api/anchor-excerpt.ts +7 -0
- package/node_modules/pi-agent-text-editor/src/api/anchor-inspection.ts +2 -1
- package/node_modules/pi-agent-text-editor/src/api/delete-guard.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +40 -8
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +6 -1
- package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +37 -2
- package/node_modules/pi-agent-text-editor/src/api/native-edit-batch-event.ts +2 -2
- package/node_modules/pi-agent-text-editor/src/api/native-files.ts +16 -2
- package/node_modules/pi-agent-text-editor/src/api/pi-edit-text.ts +82 -0
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +9 -2
- package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +1 -0
- package/node_modules/pi-agent-text-editor/src/api/stale-anchor-message.ts +13 -2
- package/node_modules/pi-agent-text-editor/src/api/text-selector-fields.ts +210 -0
- package/node_modules/pi-agent-text-editor/src/api/tool-call-interceptor.ts +1 -0
- package/node_modules/pi-agent-text-editor/src/api/tool-renderer.ts +3 -0
- package/node_modules/pi-agent-text-editor/src/core/already-done.ts +123 -0
- package/node_modules/pi-agent-text-editor/src/core/anchor-candidates.ts +116 -0
- package/node_modules/pi-agent-text-editor/src/core/anchor-preview.ts +32 -0
- package/node_modules/pi-agent-text-editor/src/core/delete-policy.ts +109 -23
- package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +19 -5
- package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +6 -5
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +54 -21
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +7 -3
- package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +14 -5
- package/node_modules/pi-agent-text-editor/src/core/file-result-targets.ts +32 -11
- package/node_modules/pi-agent-text-editor/src/core/file-transfers.ts +67 -38
- package/node_modules/pi-agent-text-editor/src/core/file-write-observations.ts +287 -0
- package/node_modules/pi-agent-text-editor/src/core/image-write.ts +16 -4
- package/node_modules/pi-agent-text-editor/src/core/lookalike-bytes.ts +254 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +29 -12
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/compact-receipt.ts +48 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/diff.ts +2 -1
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +24 -34
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +13 -20
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +32 -3
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +36 -2
- package/node_modules/pi-agent-text-editor/src/core/mutation-result-targets.ts +26 -19
- package/node_modules/pi-agent-text-editor/src/core/native-snapshot-source.ts +13 -0
- package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +526 -148
- package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +28 -3
- package/node_modules/pi-agent-text-editor/src/core/read-fragment-resolver.ts +34 -14
- package/node_modules/pi-agent-text-editor/src/core/reference-list.ts +95 -0
- package/node_modules/pi-agent-text-editor/src/core/result-scope.ts +129 -0
- package/node_modules/pi-agent-text-editor/src/core/result-target-anchors.ts +20 -8
- package/node_modules/pi-agent-text-editor/src/core/result-transfer.ts +86 -69
- package/node_modules/pi-agent-text-editor/src/core/source-aliases.ts +92 -0
- package/node_modules/pi-agent-text-editor/src/core/source-change-retry.ts +92 -7
- package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/core/text-anchor-registry.ts +162 -47
- package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +321 -101
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +206 -134
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -2
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +133 -18
- package/node_modules/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +13 -0
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +823 -226
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +51 -1
- package/node_modules/pi-agent-text-editor/src/core/write-agent-result.ts +7 -4
- package/node_modules/pi-agent-text-editor/src/tools/display-marker.ts +15 -0
- package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +268 -159
- package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +37 -32
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +24 -70
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +23 -36
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +31 -45
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +33 -65
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +80 -42
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +27 -16
- package/node_modules/pi-agent-text-editor-renderer/index.ts +0 -14
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-renderer/runtime/entry-89.js +2 -0
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +204 -78
- package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +75 -8
- package/node_modules/pi-agent-text-editor-renderer/src/frozen-viewport.ts +4 -1
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +4 -3
- package/node_modules/pi-agent-text-editor-renderer/src/persisted-result.ts +44 -30
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +170 -26
- package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +83 -83
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -6
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-91.js +1 -0
- package/node_modules/pi-agent-tool-ui/package.json +3 -3
- package/node_modules/pi-agent-tool-ui/runtime/entry-92.js +1 -0
- package/node_modules/pi-agent-tool-ui/runtime/entry-93.js +1 -0
- package/node_modules/pi-agent-web/index.ts +0 -3
- package/node_modules/pi-agent-web/package.json +8 -8
- package/node_modules/pi-agent-web/src/search.ts +1 -2
- package/node_modules/pi-agent-web-html/package.json +3 -3
- package/node_modules/pi-agent-web-html/runtime/entry-95.js +2 -0
- package/node_modules/pi-agent-web-image/package.json +4 -4
- package/node_modules/pi-agent-web-image/runtime/entry-96.js +2 -0
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/runtime/entry-97.js +2 -0
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/node_modules/pi-agent-web-text/runtime/entry-98.js +2 -0
- package/package.json +38 -38
- package/skills/capture-code-review-rule/SKILL.md +1 -1
- package/skills/configure-agent-ide/SKILL.md +1 -1
- package/src/api/code-view.ts +0 -2
- package/src/api/tool-config/linters.json +1 -0
- package/src/api/tool-config/lsp-servers.json +5 -0
- package/src/api/tool-config.ts +23 -2
- package/src/backend/config.ts +2 -0
- package/src/backend/configured-process.ts +1 -0
- package/src/backend/dap-java-transport.ts +4 -2
- package/src/backend/dap-java-worker.py +11 -4
- package/src/backend/dap-node-transport.ts +4 -2
- package/src/backend/dap-tcp-transport.ts +2 -3
- package/src/backend/debugger-workspace-owner.ts +6 -6
- package/src/backend/doctor-probe-worker.py +23 -15
- package/src/backend/doctor-workspace.ts +19 -18
- package/src/backend/file-transfer.ts +160 -56
- package/src/backend/formatter-registration.ts +54 -2
- package/src/backend/identity.ts +81 -12
- package/src/backend/lsp-file-watchers.ts +7 -9
- package/src/backend/lsp-workspace-owner.ts +25 -1
- package/src/backend/object-transfer.ts +28 -15
- package/src/backend/owned-command.ts +2 -1
- package/src/backend/owned-read-command.ts +2 -1
- package/src/backend/packaged-source.ts +12 -0
- package/src/backend/process-environment.ts +7 -9
- package/src/backend/process-metadata.ts +5 -5
- package/src/backend/recipe-evidence-worker.py +2 -0
- package/src/backend/recipe-evidence.ts +7 -8
- package/src/backend/registration.ts +2 -1
- package/src/backend/registry.ts +12 -2
- package/src/backend/resource-resolver.ts +11 -32
- package/src/backend/search-environment.ts +61 -4
- package/src/backend/ssh-channel-worker.py +6 -304
- package/src/backend/ssh-channel.ts +287 -36
- package/src/backend/ssh-connection-loss.ts +123 -0
- package/src/backend/ssh-file-stream.ts +216 -0
- package/src/backend/ssh-master.ts +443 -0
- package/src/backend/ssh-transfer-worker-windows.py +84 -0
- package/src/backend/ssh-transfer-worker.py +43 -10
- package/src/backend/ssh-transport.ts +238 -24
- package/src/backend/ssh-worker.py +7 -728
- package/src/backend/ssh.ts +83 -35
- package/src/backend/ssh_channel_common.py +68 -0
- package/src/backend/ssh_channel_posix.py +324 -0
- package/src/backend/ssh_channel_windows.py +527 -0
- package/src/backend/ssh_paths.py +23 -0
- package/src/backend/ssh_windows_files.py +254 -0
- package/src/backend/ssh_worker_common.py +96 -0
- package/src/backend/ssh_worker_posix.py +780 -0
- package/src/backend/ssh_worker_windows.py +687 -0
- package/src/backend/tool-config-access.ts +14 -11
- package/src/backend/tool-project.ts +4 -3
- package/src/backend/web-browser.ts +2 -3
- package/src/backend/web-http.ts +5 -5
- package/src/code-view/diagnostic-view.ts +12 -30
- package/src/code-view/reference.ts +9 -18
- package/src/code-view/source-view.ts +2 -1
- package/src/composite/codemode-tool-names.ts +79 -0
- package/src/composite/detached-results.ts +25 -6
- package/src/composite/ide-alias-rendering.ts +26 -4
- package/src/composite/module-labels.ts +2 -2
- package/src/composite/module-settings.ts +1 -0
- package/src/composite/nested-tool-rendering.ts +70 -24
- package/src/composite/output-limits.ts +12 -5
- package/src/composite/parallel-tool-guidance.ts +38 -0
- package/src/composite/script-values/ast-search.ts +56 -0
- package/src/composite/script-values/copy.ts +8 -0
- package/src/composite/script-values/delete.ts +5 -0
- package/src/composite/script-values/diff.ts +28 -0
- package/src/composite/script-values/edit-selection.ts +48 -0
- package/src/composite/script-values/failures.ts +170 -0
- package/src/composite/script-values/file-receipts.ts +63 -0
- package/src/composite/script-values/file-search.ts +10 -0
- package/src/composite/script-values/index.ts +55 -0
- package/src/composite/script-values/insert.ts +5 -0
- package/src/composite/script-values/lsp-search.ts +136 -0
- package/src/composite/script-values/match.ts +53 -0
- package/src/composite/script-values/move.ts +8 -0
- package/src/composite/script-values/path-list.ts +25 -0
- package/src/composite/script-values/provider-value.ts +21 -0
- package/src/composite/script-values/read.ts +206 -0
- package/src/composite/script-values/replace.ts +5 -0
- package/src/composite/script-values/result-reference.ts +9 -0
- package/src/composite/script-values/search-matches.ts +113 -0
- package/src/composite/script-values/search.ts +64 -0
- package/src/composite/script-values/semantic-search.ts +8 -0
- package/src/composite/script-values/terminal.ts +112 -0
- package/src/composite/script-values/text.ts +7 -0
- package/src/composite/script-values/types.ts +56 -0
- package/src/composite/script-values/undo.ts +5 -0
- package/src/composite/script-values/write.ts +8 -0
- package/src/composite/settings-panel.ts +18 -2
- package/src/composite/text-results.ts +488 -175
- package/src/composite/tool-availability.ts +29 -16
- package/src/composite/tool-discovery-guidance.ts +97 -0
- package/src/documentation/attachment.ts +31 -0
- package/src/documentation/extension.ts +6 -2
- package/src/documentation/search.ts +1 -7
- 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 +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/file-write-lock.ts +6 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/replace-file.ts +5 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/resolver.ts +26 -10
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +0 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -8
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-95.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-96.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-97.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-98.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-94.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/search.ts +1 -2
- package/src/extensions/pi-agent-read/package.json +7 -7
- package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +51 -12
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +39 -3
- package/src/extensions/pi-agent-read/src/core/extension.ts +80 -3
- package/src/extensions/pi-agent-read/src/core/read-core.ts +6 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/list-result.ts +79 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +45 -4
- package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +18 -9
- package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +16 -3
- package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +37 -9
- package/src/extensions/pi-agent-read/src/core/tools/read/result-target.ts +15 -4
- package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +49 -18
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +158 -51
- package/src/extensions/pi-agent-search/package.json +8 -9
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +62 -20
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +15 -15
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-59.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-62.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/current-matches.ts +314 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +178 -99
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/fuzzy-search.ts +40 -17
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/persisted-result.ts +3 -8
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +395 -103
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/ripgrep.ts +142 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +24 -12
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +333 -108
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-presentation.ts +6 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-query.ts +69 -34
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +80 -8
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +2 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +10 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +449 -58
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/tool-file-search.ts +51 -6
- package/src/extensions/pi-agent-search/runtime/entry-57.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-58.js +2 -0
- package/src/extensions/pi-agent-search/src/api/fuzzy.ts +2 -1
- package/src/extensions/pi-agent-search/src/api/null-fields.ts +50 -0
- package/src/extensions/pi-agent-search/src/api/path-list.ts +68 -0
- package/src/extensions/pi-agent-search/src/api/presentation.ts +2 -1
- package/src/extensions/pi-agent-search/src/api/search-call-policy.ts +16 -0
- package/src/extensions/pi-agent-search/src/api/search-capture.ts +56 -0
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +26 -4
- package/src/extensions/pi-agent-search/src/api/search-scope.ts +38 -2
- package/src/extensions/pi-agent-search/src/api/search.ts +46 -3
- package/src/extensions/pi-agent-search/src/api/structured-result.ts +121 -26
- package/src/extensions/pi-agent-search/src/core/extension.ts +75 -42
- package/src/extensions/pi-agent-search/src/core/search-config.ts +2 -2
- package/src/extensions/pi-agent-search/src/core/search-core.ts +103 -39
- package/src/extensions/pi-agent-text-editor/index.ts +0 -10
- package/src/extensions/pi-agent-text-editor/package.json +37 -26
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-64.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/index.ts +1 -65
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-65.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-66.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchor.ts +185 -184
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchored-literal-view.ts +122 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/fuzzy-worker.ts +2 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/literal-match.ts +359 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/recovery.ts +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +5 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-67.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-68.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/anchor.ts +92 -67
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/range-history.ts +105 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/read-handler.ts +22 -17
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +0 -14
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-89.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +204 -78
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +75 -8
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/frozen-viewport.ts +4 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +4 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/persisted-result.ts +44 -30
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +170 -26
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/index.ts +83 -83
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -6
- package/src/extensions/pi-agent-text-editor/runtime/entry-84.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-85.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-86.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-87.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-88.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/anchor-excerpt.ts +7 -0
- package/src/extensions/pi-agent-text-editor/src/api/anchor-inspection.ts +2 -1
- package/src/extensions/pi-agent-text-editor/src/api/delete-guard.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +40 -8
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +6 -1
- package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +37 -2
- package/src/extensions/pi-agent-text-editor/src/api/native-edit-batch-event.ts +2 -2
- package/src/extensions/pi-agent-text-editor/src/api/native-files.ts +16 -2
- package/src/extensions/pi-agent-text-editor/src/api/pi-edit-text.ts +82 -0
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +9 -2
- package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +1 -0
- package/src/extensions/pi-agent-text-editor/src/api/stale-anchor-message.ts +13 -2
- package/src/extensions/pi-agent-text-editor/src/api/text-selector-fields.ts +210 -0
- package/src/extensions/pi-agent-text-editor/src/api/tool-call-interceptor.ts +1 -0
- package/src/extensions/pi-agent-text-editor/src/api/tool-renderer.ts +3 -0
- package/src/extensions/pi-agent-text-editor/src/core/already-done.ts +123 -0
- package/src/extensions/pi-agent-text-editor/src/core/anchor-candidates.ts +116 -0
- package/src/extensions/pi-agent-text-editor/src/core/anchor-preview.ts +32 -0
- package/src/extensions/pi-agent-text-editor/src/core/delete-policy.ts +109 -23
- package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +19 -5
- package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +6 -5
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +54 -21
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +7 -3
- package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +14 -5
- package/src/extensions/pi-agent-text-editor/src/core/file-result-targets.ts +32 -11
- package/src/extensions/pi-agent-text-editor/src/core/file-transfers.ts +67 -38
- package/src/extensions/pi-agent-text-editor/src/core/file-write-observations.ts +287 -0
- package/src/extensions/pi-agent-text-editor/src/core/image-write.ts +16 -4
- package/src/extensions/pi-agent-text-editor/src/core/lookalike-bytes.ts +254 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +29 -12
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/compact-receipt.ts +48 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/diff.ts +2 -1
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +24 -34
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +13 -20
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +32 -3
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +36 -2
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result-targets.ts +26 -19
- package/src/extensions/pi-agent-text-editor/src/core/native-snapshot-source.ts +13 -0
- package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +526 -148
- package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +28 -3
- package/src/extensions/pi-agent-text-editor/src/core/read-fragment-resolver.ts +34 -14
- package/src/extensions/pi-agent-text-editor/src/core/reference-list.ts +95 -0
- package/src/extensions/pi-agent-text-editor/src/core/result-scope.ts +129 -0
- package/src/extensions/pi-agent-text-editor/src/core/result-target-anchors.ts +20 -8
- package/src/extensions/pi-agent-text-editor/src/core/result-transfer.ts +86 -69
- package/src/extensions/pi-agent-text-editor/src/core/source-aliases.ts +92 -0
- package/src/extensions/pi-agent-text-editor/src/core/source-change-retry.ts +92 -7
- package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-anchor-registry.ts +162 -47
- package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +321 -101
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +206 -134
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -2
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +133 -18
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +13 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +823 -226
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +51 -1
- package/src/extensions/pi-agent-text-editor/src/core/write-agent-result.ts +7 -4
- package/src/extensions/pi-agent-text-editor/src/tools/display-marker.ts +15 -0
- package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +268 -159
- package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +37 -32
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +24 -70
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +23 -36
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +31 -45
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +33 -65
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +80 -42
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +27 -16
- package/src/pi-agent-ide.ts +41 -32
- package/src/plugins/pi-agent-ide-ast/package.json +13 -13
- package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +56 -65
- package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +197 -130
- package/src/plugins/pi-agent-ide-ast/src/ast/read-text.ts +2 -1
- package/src/plugins/pi-agent-ide-ast/src/ast-grep-binary.ts +46 -0
- package/src/plugins/pi-agent-ide-ast/src/doctor-plugin.ts +119 -97
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +9 -24
- package/src/plugins/pi-agent-ide-ast/src/outline-page.ts +96 -0
- package/src/plugins/pi-agent-ide-ast/src/outline-resolver.ts +42 -78
- package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +5 -1
- package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +2 -1
- package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +24 -5
- package/src/plugins/pi-agent-ide-ast/src/search-presentation.ts +2 -1
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +406 -200
- package/src/plugins/pi-agent-ide-ast/src/tool-ast-search.ts +27 -9
- package/src/plugins/pi-agent-ide-ast/src/tool-outline.ts +191 -0
- package/src/plugins/pi-agent-ide-changes/package.json +8 -8
- package/src/plugins/pi-agent-ide-changes/src/changes/change-service.ts +63 -20
- package/src/plugins/pi-agent-ide-changes/src/changes/change-types.ts +1 -0
- package/src/plugins/pi-agent-ide-changes/src/changes/git-changes-backend.ts +25 -0
- package/src/plugins/pi-agent-ide-changes/src/changes/git-paths.ts +13 -6
- package/src/plugins/pi-agent-ide-changes/src/index-mutation-queue.ts +12 -8
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +88 -78
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +29 -3
- package/src/plugins/pi-agent-ide-debugger/index.ts +42 -32
- package/src/plugins/pi-agent-ide-debugger/src/string-enum.ts +14 -0
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +124 -79
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +39 -3
- package/src/plugins/pi-agent-ide-formatter/src/rustfmt.ts +101 -0
- package/src/plugins/pi-agent-ide-languages/package.json +2 -2
- package/src/plugins/pi-agent-ide-lint/package.json +7 -7
- package/src/plugins/pi-agent-ide-lint/src/catalog.ts +20 -14
- package/src/plugins/pi-agent-ide-lint/src/registry.ts +2 -2
- package/src/plugins/pi-agent-ide-lsp/index.ts +15 -88
- package/src/plugins/pi-agent-ide-lsp/package.json +12 -12
- package/src/plugins/pi-agent-ide-lsp/src/catalog.ts +21 -9
- package/src/plugins/pi-agent-ide-lsp/src/lsp/clang-coverage.ts +265 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/clangd-launch.ts +48 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +94 -11
- package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +514 -207
- package/src/plugins/pi-agent-ide-lsp/src/lsp/corrected-names.ts +222 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/declaration-scan.ts +116 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/diagnostics.ts +20 -1
- package/src/plugins/pi-agent-ide-lsp/src/lsp/files-containing.ts +70 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/index.ts +1 -1
- package/src/plugins/pi-agent-ide-lsp/src/lsp/initialization-options.ts +37 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/line-breaks.ts +16 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +185 -131
- package/src/plugins/pi-agent-ide-lsp/src/lsp/missing-sources.ts +21 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/navigation.ts +45 -24
- package/src/plugins/pi-agent-ide-lsp/src/lsp/position-map.ts +17 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/project.ts +40 -12
- package/src/plugins/pi-agent-ide-lsp/src/lsp/range-match.ts +49 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/rename.ts +16 -5
- package/src/plugins/pi-agent-ide-lsp/src/lsp/server-request-handlers.mjs +7 -1
- package/src/plugins/pi-agent-ide-lsp/src/lsp/shared-server-host.mjs +133 -37
- package/src/plugins/pi-agent-ide-lsp/src/lsp/shared-servers.ts +164 -13
- package/src/plugins/pi-agent-ide-lsp/src/lsp/source-changes.ts +18 -6
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +414 -174
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-selectors.ts +424 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbols.ts +67 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/workspace-owner.ts +10 -0
- package/src/plugins/pi-agent-ide-lsp/src/name-captures.ts +66 -0
- package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +384 -93
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +356 -79
- package/src/plugins/pi-agent-ide-lsp/src/tool-lsp-search.ts +33 -11
- package/src/plugins/pi-agent-ide-processes/src/registry.ts +64 -3
- package/src/plugins/pi-agent-ide-processes/src/ui.ts +57 -1
- package/src/plugins/pi-agent-ide-semantic/src/backend.ts +18 -6
- package/src/plugins/pi-agent-ide-semantic/src/vera-backend.ts +16 -9
- package/src/plugins/pi-agent-ide-terminal/index.ts +23 -7
- package/src/plugins/pi-agent-ide-terminal/src/list.ts +79 -0
- package/src/plugins/pi-agent-ide-terminal/src/output-limits.ts +22 -0
- package/src/plugins/pi-agent-ide-terminal/src/process-provider.ts +3 -0
- package/src/plugins/pi-agent-ide-terminal/src/renderer.ts +18 -6
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +132 -18
- package/src/plugins/pi-agent-ide-terminal/src/search.ts +117 -50
- package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +94 -10
- package/src/plugins/pi-agent-ide-terminal/src/shell-profile.ts +24 -1
- package/src/plugins/pi-agent-ide-terminal/src/shell-result.ts +5 -2
- package/src/plugins/pi-agent-ide-terminal/src/terminal-text.ts +173 -0
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +266 -112
- package/src/plugins/pi-agent-ide-terminal/src/types.ts +6 -1
- package/src/plugins/pi-agent-ide-terminal/src/ui.ts +11 -6
- package/src/plugins/pi-agent-ide-terminal/src/unix-pty-output.ts +47 -0
- package/src/post-edit/gate.ts +16 -1
- package/src/semantic/extension.ts +8 -2
- package/src/standalone/scoped-api.ts +85 -18
- package/src/toolchain/types.ts +4 -0
- package/dist/chunk-2AANEKFS.js +0 -1
- package/dist/chunk-33U3RUM3.js +0 -12
- package/dist/chunk-34IYWKY5.js +0 -1
- package/dist/chunk-4CSNQX54.js +0 -23
- package/dist/chunk-53IV6EKV.js +0 -1
- package/dist/chunk-5AROEOJB.js +0 -1
- package/dist/chunk-5D4C225L.js +0 -1
- package/dist/chunk-5W6QQZFI.js +0 -2
- package/dist/chunk-6W4OJLCJ.js +0 -1
- package/dist/chunk-6ZYCTWQE.js +0 -1
- package/dist/chunk-756K3LJY.js +0 -1
- package/dist/chunk-AMSNDWBT.js +0 -2
- package/dist/chunk-APWMLLSE.js +0 -17
- package/dist/chunk-BMSAVDRD.js +0 -13
- package/dist/chunk-BRJIXNFU.js +0 -5
- package/dist/chunk-C2GZLLSP.js +0 -5
- package/dist/chunk-ECSMTGVM.js +0 -6
- package/dist/chunk-EWTVVPUA.js +0 -11
- package/dist/chunk-FBR7ZLLN.js +0 -1
- package/dist/chunk-FGN2ZMEN.js +0 -1
- package/dist/chunk-FJSYWOE6.js +0 -1
- package/dist/chunk-FTECKRK6.js +0 -1
- package/dist/chunk-GRZTKMXQ.js +0 -1
- package/dist/chunk-HFCHOFLV.js +0 -2
- package/dist/chunk-HFF4GY7R.js +0 -3
- package/dist/chunk-HJXSEPO7.js +0 -111
- package/dist/chunk-HSEDKYH4.js +0 -1
- package/dist/chunk-II7AOJNH.js +0 -9
- package/dist/chunk-J34VKQGJ.js +0 -1
- package/dist/chunk-J6CDIH3S.js +0 -84
- package/dist/chunk-JHWLRL4U.js +0 -1
- package/dist/chunk-JMQ67UNK.js +0 -3
- package/dist/chunk-JRIP33PC.js +0 -13
- package/dist/chunk-K5M65CAF.js +0 -1
- package/dist/chunk-KJAR2WDO.js +0 -1
- package/dist/chunk-KX7MG72M.js +0 -1
- package/dist/chunk-L2B4DTVS.js +0 -1
- package/dist/chunk-LEKC4GQK.js +0 -5
- package/dist/chunk-LIGOOMJS.js +0 -10
- package/dist/chunk-LY2UANKU.js +0 -6
- package/dist/chunk-M7P7V4WI.js +0 -25
- package/dist/chunk-MXLSGMRZ.js +0 -3
- package/dist/chunk-N2NEFXHB.js +0 -13
- package/dist/chunk-NF74ITWT.js +0 -2
- package/dist/chunk-NQYUIQRH.js +0 -1
- package/dist/chunk-OCU6NW5Y.js +0 -1
- package/dist/chunk-OIEA4QWF.js +0 -4
- package/dist/chunk-ON5HDFNL.js +0 -10
- package/dist/chunk-P43GGKUC.js +0 -28
- package/dist/chunk-PPCWY4BB.js +0 -1
- package/dist/chunk-QGXZ4RWX.js +0 -1
- package/dist/chunk-S3T5NOSL.js +0 -1
- package/dist/chunk-S7E2D5K7.js +0 -5
- package/dist/chunk-SIYPD5MM.js +0 -3
- package/dist/chunk-STUZZM5B.js +0 -1
- package/dist/chunk-T4FTT3U4.js +0 -1
- package/dist/chunk-T5ACAOKJ.js +0 -4
- package/dist/chunk-TILMPAF2.js +0 -1
- package/dist/chunk-TSNY2FSU.js +0 -1
- package/dist/chunk-TWJINFQB.js +0 -9
- package/dist/chunk-TWQ6ACOI.js +0 -1
- package/dist/chunk-UDVVKVG4.js +0 -1
- package/dist/chunk-V2D5MLGE.js +0 -1
- package/dist/chunk-VDSSAP6Y.js +0 -1
- package/dist/chunk-VHYJTAXX.js +0 -1
- package/dist/chunk-WCSWQDJ2.js +0 -22
- package/dist/chunk-WQTF6Q2X.js +0 -3
- package/dist/chunk-XE4W5YTE.js +0 -2
- package/dist/chunk-YFPU2LRR.js +0 -23
- package/dist/chunk-YLEERRX3.js +0 -33
- package/dist/chunk-YOJHCARZ.js +0 -1
- package/dist/chunk-YPTDPMK5.js +0 -1
- package/docs/agent-guides/editing.md +0 -43
- package/docs/agent-guides/search.md +0 -38
- package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +0 -73
- package/node_modules/pi-agent-text-anchor-constant/runtime/entry-63.js +0 -2
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-64.js +0 -1
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-66.js +0 -1
- package/node_modules/pi-agent-text-editor/runtime/entry-68.js +0 -1
- package/node_modules/pi-agent-text-editor-renderer/runtime/entry-85.js +0 -2
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-86.js +0 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-88.js +0 -1
- package/node_modules/pi-agent-tool-ui/runtime/entry-89.js +0 -1
- package/node_modules/pi-agent-web-html/runtime/entry-91.js +0 -2
- package/node_modules/pi-agent-web-image/runtime/entry-92.js +0 -2
- package/node_modules/pi-agent-web-pdf/runtime/entry-93.js +0 -2
- package/src/composite/search-facts.ts +0 -45
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-91.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-92.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-93.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-94.js +0 -2
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-58.js +0 -2
- package/src/extensions/pi-agent-search/runtime/entry-54.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-63.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-64.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-66.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-85.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-86.js +0 -2
- package/src/extensions/pi-agent-text-editor/runtime/entry-68.js +0 -1
- package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +0 -73
- /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-54.js +0 -0
- /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-58.js +0 -0
- /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-62.js +0 -0
- /package/node_modules/{pi-agent-tool-call-interception → pi-agent-text-editor}/runtime/entry-87.js +0 -0
- /package/node_modules/{pi-agent-web → pi-agent-text-editor-stale-anchor}/runtime/entry-90.js +0 -0
- /package/node_modules/{pi-agent-web-text → pi-agent-web}/runtime/entry-94.js +0 -0
- /package/src/extensions/{pi-agent-read/extensions/pi-agent-web → pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor}/runtime/entry-90.js +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import{e as q,f as $e,g as Ae}from"./chunk-JXULBI4S.js";import{a as De,b as ke,c as _e,d as K,e as X,f as L,g as Ce,h as Ie,i as Ne,k as Fe,l as Ve,m as Be,n as Me,o as se,p as Y,q as J,r as Q,s as Z,t as ee,u as Ue}from"./chunk-SJQGFUXR.js";import{a as je,c as Ge,d as He}from"./chunk-IZTOXSTR.js";import{a as G,b as H,c as Pe,d as be,g as Le}from"./chunk-HSAGZWPO.js";import{B as he,H as we,I as ve,K as Te,N as z,b as fe,fa as xe,p as Re,q as pe,s as ge,ta as Ee,v as ie,w as me,x as ye}from"./chunk-OEEE5BLN.js";import{C as Oe,z as Se}from"./chunk-IRLWXPL4.js";import{a as k}from"./chunk-ZC65Z3CK.js";import{a as l}from"./chunk-EI7MMDWY.js";import{stat as gt}from"node:fs/promises";import{DEFAULT_MAX_BYTES as mt,DEFAULT_MAX_LINES as yt,formatSize as te,truncateHead as ht}from"@earendil-works/pi-coding-agent";var re=mt,ae=yt;function We(e,t){if(t.outputLines===0||!(e.presented??e.content).startsWith(t.content))return;let n=l(s=>s?.match(/\n/gu)?.length??0,"countLf"),o=l(s=>(s??[]).reduce((c,p)=>c+1+n(p.prefix)+n(p.content)+n(p.suffix),0),"annotationRows"),r=t.outputLines-(t.lastLinePartial?1:0),i=0,a;for(let s of e.lines){let c=e.presented===void 0?void 0:s.presentation;if(i+=o(c?.before)+n(c?.prefix),i>=r)break;a=s,i+=n(c?.suffix)+o(c?.after)+n(s.lineEnding)}return a}l(We,"lastShownReadLine");async function ze(e,t,n,o){let r=o?.originLine,i=e.content.length===1?e.content[0]:void 0;if(i?.type!=="text")return e;let a=`
|
|
2
|
+
${Oe}`,s=e.details.noFinalLineBreak===!0&&i.text.endsWith(a)?i.text.slice(0,-a.length):i.text,c=ht(s,{maxBytes:re,maxLines:ae});if(c.truncated){let p=n===void 0?void 0:await n(s),m=c.firstLineExceedsLimit?await Tt(s,e.details,t):xt(c,e.details,t,r),g=p===void 0?m:vt(m,p);return{...e,content:[{...i,text:Ke(c.content,g)}],details:{...Lt(e.details,c),outputNotice:(c.content.length?`
|
|
3
|
+
|
|
4
|
+
`:"")+g,...p!==void 0&&{temporarySource:p}}}}return ne(e,t,o)}l(ze,"limitReadOutput");function ne(e,t,n){let o=e.content.length===1?e.content[0]:void 0;if(e.isError||o?.type!=="text")return e;let r=o.text.length===0?wt(e,t,n?.originLine):Pt(e.details,t,n?.originLine);return r===void 0?e:{...e,content:[{...o,text:Ke(o.text,r)}],details:{...e.details,outputNotice:(o.text.length?`
|
|
5
|
+
|
|
6
|
+
`:"")+r}}}l(ne,"explainReadWindow");function wt(e,t,n){let o=e.script;if(e.isError||o?.kind!=="text"||o.lines.length!==0)return;if(o.totalLines===0)return"[Empty source.]";if(t.limit!==void 0&&Math.trunc(t.limit)<=0)return"[No lines selected: limit=0.]";let r=Math.trunc(t.offset??1);if(Ie(r,o.totalLines,n)>o.totalLines)return`[Offset ${r} is beyond the end of the source (${o.totalLines} ${o.totalLines===1?"line":"lines"}).]`}l(wt,"emptyTextNotice");function vt(e,t){let n=t.startsWith("temp:")?t:JSON.stringify(t);return`${e.slice(0,-1)} Full output: ${n}. Available until this runtime is disposed.]`}l(vt,"appendTemporarySource");async function Tt(e,t,n){let o=e.split(/\r\n|\r|\n/u,1)[0]??"",r=te(Buffer.byteLength(o,"utf8")),i=de(t,n),a=i===void 0?"First output line":`Line ${i}`,s=te(re);return t.resolvedBy==="filesystem"&&n.views?.some(c=>c.startsWith("jq:"))===!0?`[Output line ${i??1} is ${r}, exceeds the ${s} output limit. This line was not returned. Narrow the jq filter to return a smaller value.]`:t.resolvedBy==="filesystem"&&t.source!==void 0&&(await gt(t.source).catch(()=>{}))?.isFile()===!0?`[${a} is ${r}, exceeds the ${s} output limit. This line was not returned. Read ${JSON.stringify(`raw:${t.source}`)} with offset=0 and limit=4096 to inspect the original bytes.]`:`[${a} is ${r}, exceeds ${s} limit. Use a source-specific tool to read this line in smaller byte ranges.]`}l(Tt,"oversizedFirstLineNotice");function xt(e,t,n,o){let r=Et(e,t,n);if(r!==void 0&&r.endLine<r.totalLines){let a=e.truncatedBy==="lines"?`${e.maxLines}-line limit`:`${te(e.maxBytes)} limit`,s=qe(t,n,r.endLine+1,o);return`[Showing lines ${r.startLine}-${r.endLine} of ${r.totalLines} (${a}). ${s} to continue.]`}let i=e.truncatedBy==="lines"?`${e.maxLines}-line limit`:`${te(e.maxBytes)} limit`;return`[Output truncated: showing ${e.outputLines} of ${e.totalLines} output lines (${i}). No single source-line continuation is available. Retry Read with a smaller limit, keeping the same source and views.]`}l(xt,"truncatedOutputNotice");function Et(e,t,n){let o=t.totalLines,r=de(t,n);if(o===void 0||o===0||r===void 0||e.outputLines===0)return;let a=(t.endLine===void 0||t.endLine<r?o:t.endLine)-r+1,s=Math.min(e.outputLines,a);return{startLine:r,endLine:r+s-1,totalLines:o}}l(Et,"shownSourceRange");function Pt(e,t,n){if(t.limit===void 0||e.totalLines===void 0||e.totalLines===0)return;let o=de(e,t);if(o===void 0)return;let r=e.endLine===void 0||e.endLine<o?o:e.endLine+1;if(r>e.totalLines)return;let i=e.totalLines-r+1,a=i===1?"line":"lines",s=qe(e,t,r,n);return`[${i} more ${a} in source. ${s} to continue.]`}l(Pt,"explicitLimitNotice");function qe(e,t,n,o){let r=e.source===void 0?`Use offset=${bt(n,o)}`:`Read ${JSON.stringify(e.source)} with offset=${n}`,i=t.views===void 0||t.views.length===0?"":` and views=${JSON.stringify(t.views)}`;return r+i}l(qe,"sourceContinuationAction");function bt(e,t){return t===void 0?e:e-t+1}l(bt,"continuationOffset");function de(e,t){if(e.startLine!==void 0&&e.startLine>0)return e.startLine;if(e.totalLines===void 0||e.totalLines===0)return;let n=t.offset===void 0?1:Math.trunc(t.offset);return n<0?Math.max(1,e.totalLines+n+1):Math.max(1,n)}l(de,"sourceStartLine");function Lt(e,t){let{noFinalLineBreak:n,...o}=e;return{...o,...e.lines!==void 0&&{lines:e.lines.slice(0,t.outputLines)},truncation:t}}l(Lt,"truncatedDetails");function Ke(e,t){return e.length===0?t:`${e}
|
|
7
|
+
|
|
8
|
+
${t}`}l(Ke,"appendNotice");import{Text as et}from"@earendil-works/pi-tui";import{open as St,realpath as Ot,stat as $t}from"node:fs/promises";import At from"node:path";import{fileURLToPath as Dt}from"node:url";var oe=16*Math.max(1,Math.min(ae-4,Math.floor((re-1024)/90)));async function Qe(e,t,n,o=[],r=[],i="model"){let a=e.path??"",s=n==="script"||i==="none",c=n==="script"?void 0:oe;try{if((e.views?.length??0)>0)throw new Error("Raw byte reads do not accept views. Omit views for bytes, or read the file without raw: to use text views.");let p=e.offset??0,m=e.limit;if(!Number.isSafeInteger(p)||m!==void 0&&(!Number.isSafeInteger(m)||m<0))throw new Error("Use an integer byte offset and a non-negative integer byte limit");let g=a.slice(4);if(g.length===0)throw new Error("Supply a file or byte resource after raw:");if(!g.startsWith("file://")&&(Xe(g)||Xe(t.cwd))){for(let u of r){t.signal?.throwIfAborted();let w=await u.tryResolve(g,{...t,audience:n});if(!z(w))throw new Error(`Resolver ${u.id} returned an invalid result`);if(w.kind==="not-handled")continue;if(w.kind==="failed")throw w.error;let P=w.resource,S=`raw:${P.source}`;if(!P.readBytes)throw new Error(`Resource ${P.source} does not support original byte reads`);let O=await Ye(e,S,t,n,o);if(O)return O;t.signal?.throwIfAborted();let T=s?m:Math.min(m??oe,oe),b=await P.readBytes(p,T,t);return t.signal?.throwIfAborted(),kt(b,p,T),Je(S,b,m,c)}throw new Error(`No byte resource resolver handled ${g}`)}let E=g.startsWith("file://")?Dt(g):At.resolve(t.cwd,g),x=await Ot(E),d=`raw:${x}`,f=await Ye(e,d,t,n,o);if(f)return f;if(t.signal?.throwIfAborted(),!(await $t(x)).isFile())throw new Error("Raw reads require a regular file");let v=await St(x,"r");try{let u=await v.stat();if(!u.isFile())throw new Error("Raw reads require a regular file");let w=Math.min(u.size,Math.max(0,p<0?u.size+p:p)),P=Math.min(m??u.size,u.size-w),S=s?P:Math.min(P,oe),O=Buffer.alloc(S),T=0;for(;T<S;){t.signal?.throwIfAborted();let b=await v.read(O,T,S-T,w+T);if(b.bytesRead===0)break;T+=b.bytesRead}return t.signal?.throwIfAborted(),Je(d,{bytes:O.subarray(0,T),byteOffset:w,totalBytes:u.size},m,c)}finally{await v.close()}}catch(p){if(t.signal?.aborted)throw p;return L({code:"READ_FAILED",source:a,message:p instanceof Error?p.message:String(p),cause:p})}}l(Qe,"readRaw");function Xe(e){return/^[a-z][a-z0-9+.-]*:\/\//iu.test(e)&&!/^[a-z]:[\\/]/iu.test(e)}l(Xe,"isProtocolSource");async function Ye(e,t,n,o,r){for(let{registration:i}of r)try{let a=await i.guard({requestedSource:e.path??"",resourceSource:t,resolvedBy:"raw",cwd:n.cwd,request:e,audience:o,...n.signal!==void 0&&{signal:n.signal}});if(a.kind==="rejected")return L({code:"READ_FAILED",source:t,resolverId:"raw",message:`Read blocked by hook ${i.id}: ${a.reason}`})}catch(a){return L({code:"READ_FAILED",source:t,resolverId:"raw",message:`Read blocked because hook ${i.id} failed: ${a instanceof Error?a.message:String(a)}`,cause:a})}}l(Ye,"checkGuards");function kt(e,t,n){if(!(e.bytes instanceof Uint8Array)||!Number.isSafeInteger(e.totalBytes)||e.totalBytes<0||!Number.isSafeInteger(e.byteOffset)||e.byteOffset!==Math.min(e.totalBytes,Math.max(0,t<0?e.totalBytes+t:t))||e.bytes.length>Math.min(n??e.totalBytes,e.totalBytes-e.byteOffset))throw new Error("Byte resource returned an invalid range")}l(kt,"validateByteRange");function Je(e,t,n,o){let{bytes:r,byteOffset:i,totalBytes:a}=t,s=r.length,c=o===void 0?r:r.subarray(0,o),p=i+c.length,m=Math.min(n??a,a-i),g=`${e}
|
|
9
|
+
Bytes ${i}..${p} (end exclusive), ${a} bytes total`,E=_t(c,i),x=p>=a?"":c.length<m?`
|
|
10
|
+
[Output limited. Read ${JSON.stringify(e)} with offset=${p} to continue.]`:`
|
|
11
|
+
Use offset=${p} to continue in bytes.`;return{content:[{type:"text",text:`${g}
|
|
12
|
+
${E}${x}`}],details:{source:e,resolvedBy:"raw",byteOffset:i,byteLength:s,totalBytes:a},script:{kind:"bytes",source:e,byteOffset:i,byteLength:s,totalBytes:a,bytes:Array.from(r),truncated:s<m}}}l(Je,"rawResult");function _t(e,t){let n=[];for(let o=0;o<e.length;o+=16){let r=e.subarray(o,o+16),i=Array.from(r,s=>s.toString(16).padStart(2,"0")).join(" "),a=Array.from(r,s=>s>=32&&s<=126?String.fromCharCode(s):".").join("");n.push(`${(t+o).toString(16).padStart(8,"0")} ${i.padEnd(47)} |${a}|`)}return n.join(`
|
|
13
|
+
`)}l(_t,"formatRawBytes");function Ze(e,t){let n=t.map(({structuredContent:a})=>Ct(a)),o=n.flatMap((a,s)=>{let[c]=a.errors;if(a.status==="success"||c===void 0)return[];let p=(t[s]?.content??[]).flatMap(m=>m.type==="text"?[m.text]:[]).join(`
|
|
14
|
+
`);return[{...c,message:p||c.message,source:c.source??e[s]??""}]}),r=n.filter(a=>a.status!=="success").length,i=t.flatMap((a,s)=>[{type:"text",text:`--- ${e[s]??""} ---`},...a.content]);return we({content:i,details:{}},Be,{status:r===0?"success":r===n.length?"error":"partial",data:{kind:"list",items:n},errors:o},{maxBytes:1/0})}l(Ze,"listReadResult");function Ct(e){if(e!==null&&typeof e=="object"&&"status"in e&&(e.status==="success"||e.status==="error"||e.status==="partial")&&"errors"in e&&Array.isArray(e.errors)){let t=e.errors;return{status:e.status,..."data"in e&&{data:e.data},errors:t.filter(n=>n!==null&&typeof n=="object"&&"code"in n&&typeof n.code=="string"&&"message"in n&&typeof n.message=="string")}}return{status:"error",errors:[{code:"STRUCTURED_ADAPTER_REQUIRED",message:"Read returned no structured result"}]}}l(Ct,"outcomeOf");var It=He({kind:"source"});function it(e,t="compact",n,o){let r=new ye,i,a,s=[{resolver:r.resolver,preserveTruncatedOutput:!1,priority:Number.MIN_SAFE_INTEGER,order:0}],c=[],p=[],m=[],g=[],E=[],x="read";return{saveTemporary:l(d=>r.save(d),"saveTemporary"),setOutputSaver(d){i=d},setReadObserver(d){a=d},tool:{name:x,exposure:"direct",namespace:{name:"ide_read",description:"Read resources and compare sources."},annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},label:x,promptSnippet:"Read supported sources as text or bytes, with optional views",description:"Use read to inspect files and other supported resources.",get promptGuidelines(){return[...e?.()??[]]},get parameters(){return Ve(n?.()??{})},outputSchema:Me,renderCall(d,f,v){let u=typeof d.path=="string"?d.path:void 0,w=u===void 0?void 0:s.find(({matchesCall:S})=>S?.(u)===!0)?.renderCall,P=v.expanded?"full":typeof t=="function"?t():t;return P==="disabled"?new et(f.fg("toolTitle","read"),0,0):(w??Ge)(d,f,{...v,expanded:P==="full"})},renderResult(d,f,v,u){let w=d.details.resolvedBy,P=w===void 0?void 0:s.find(({resolver:O})=>O.id===w)?.renderResult,S=f.expanded?"full":typeof t=="function"?t():t;return S==="disabled"&&!u.isError&&!f.isPartial?new et(v.fg("success","\u2713 read"),0,0):(P??It)(d,{...f,expanded:S==="full"},v,u)},async execute(d,f,v,u,w){let P={cwd:w.cwd,...v!==void 0&&{signal:v}},S=o?.(d)===!0,O=l(async b=>{try{let y=await ue(b,P,s,p,m,r,g,E,c,"agent",i,S?"none":"model"),D=X(y,b.path,v),R=se(D,{complete:S});return R.isError||await a?.(D,w.cwd,S),Bt(R)}catch(y){if(v?.aborted)throw y;return se(L({code:"READ_FAILED",source:b.path,message:y instanceof Error?y.message:String(y)}))}},"readOne"),T=Fe(f);return Array.isArray(f.path)?Ze(T.map(b=>b.path??""),await Promise.all(T.map(O))):O(T[0]??{})}},async execute(d,f,v="agent"){let u=await ue(d,f,s,p,m,r,g,E,c,v,i);return X(u,d.path,f.signal)},async executeWith(d,f,v,u="agent"){let w=await ue(f,v,[{resolver:d,preserveTruncatedOutput:!1,priority:0,order:0}],p,m,r,g,E,c,u,i);return X(w,f.path,v.signal)},registerContributions(d,f){let v=[...f.resourceGuards??[]],u=[...f.resolvers??[]],w=[...f.targetResolvers??[]],P=[...f.handlers??[]],S=[...f.views??[]],O=[...f.fragments??[]],T=new Set(c.map(({registration:R})=>R.id));for(let R of v){if(R.id.trim().length===0||typeof R.guard!="function")throw new TypeError(`Plugin ${d} provided an invalid Resource guard`);if(T.has(R.id))throw new Error(`Resource guard ${R.id} is already registered`);T.add(R.id)}Jt(d,u,P,s,p),Qt(d,O,g);let b=new Set(E.map(({resolver:R})=>R.id));for(let R of w){if(!Y(R))throw new TypeError(`Plugin ${d} provided an invalid text target resolver`);if(b.has(R.resolver.id))throw new Error(`Text target resolver ${R.resolver.id} is already registered`);b.add(R.resolver.id)}let y=new Set(m.map(({registration:R})=>R.view)),D=new Set(m.map(({registration:R})=>`${R.view}/${R.presenter.id}`));for(let R of S){if(!Z(R))throw new TypeError(`Plugin ${d} provided an invalid view registration`);let A=`${R.view}/${R.presenter.id}`;if(D.has(A))throw new Error(`View ${R.view} already has a presenter ${R.presenter.id}`);y.add(R.view),D.add(A)}for(let R of v)c.push({pluginId:d,registration:R});for(let R of u)s.push({resolver:R.resolver,...R.matchesCall!==void 0&&{matchesCall:R.matchesCall,renderCall:R.renderCall},...R.renderResult!==void 0&&{renderResult:R.renderResult},priority:R.priority??0,preserveTruncatedOutput:R.preserveTruncatedOutput??!1,...R.recoverFailure===void 0?{}:{recoverFailure:R.recoverFailure},order:s.length});for(let R of w)E.push({resolver:R.resolver,priority:R.priority??0,order:E.length});for(let R of P)p.push({pluginId:d,registration:R});for(let R of S)m.push({pluginId:d,registration:R,order:m.length});for(let R of O)g.push({registration:R,priority:R.priority??0,order:g.length})},dispose(){return r.dispose()}}}l(it,"createReadTool");async function ue(e,t,n,o,r,i,a,s,c,p="agent",m,g="model"){if(e.path?.startsWith("raw:"))return Qe(e,t,p,c,[...n].sort((h,$)=>h.priority-$.priority||h.order-$.order).map(({resolver:h})=>h),g);t={...t,audience:p};let E=st(p,g,m),x=[...n].sort((h,$)=>h.priority-$.priority||h.order-$.order),d=[...o],f=[...r].sort((h,$)=>(h.registration.priority??0)-($.registration.priority??0)||h.order-$.order),v=[...a].sort((h,$)=>h.priority-$.priority||h.order-$.order),u=[...s].sort((h,$)=>h.priority-$.priority||h.order-$.order),w=e.views??[],P=new Set(w.map(W)),S=new Set([...f.map(({registration:h})=>h.view)]),O=[...new Set(e.views??[])],T=new Set(f.filter(({registration:h})=>h.contentKind==="any").map(({registration:h})=>h.view)),b={ignored:O.filter(h=>!S.has(W(h))),textOnly:O.filter(h=>S.has(W(h))&&!T.has(W(h)))};if(e.path!==void 0&&u.length>0){let h=await Vt(e,t,u,x,d,f,P,b,p,c,m,g);if(h!==void 0)return h}let y={inputScope:"source",request:{...e},resolverContext:t,audience:p,outputLimit:g};if(!y.request.path?.startsWith("temp:")){let h=await at(y,d);if(h.kind==="return")return _(await E(h.result,y.request),b);y=h.context}let D=y.request.path;if(D===void 0||D.length===0)return L({code:"INVALID_REQUEST",message:"No source was provided"});let R=await le(y,x,c,e.path??D),A;if(R.kind==="return"&&R.result.isError===!0&&Ft(R.result)&&!D.startsWith("temp:")){let h=Mt(D);if(h!==void 0){let $={result:R,pipeline:y},V={...y,inputScope:"selection",request:{...y.request,path:h.source}},N=await le(V,x,c,e.path??D);N.kind==="continue"?(R=N,y=V,A=h.fragment):R=$.result}}if(R.kind==="return")return E(R.result,y.request);y=R.context;let C;if(A!==void 0){let h=await Ut(y,v,A);if(typeof h!="number")return h;C=h}if(y.state?.textMode==="final")return _(await E(K(y.state,y.request,{originLine:C,audience:p}),y.request,void 0,{originLine:C}),b);let B=await dt(y,d);if(B.kind==="return")return _(await E(B.result,y.request,void 0,{originLine:C}),b);y=B.context,y=await ut(y,f,P,C);let j=K(k(y.state),y.request,{audience:p,originLine:C});y={...y,result:j};let I=await lt(y,d),F=I.kind==="return"?I.result:k(I.context.result),M=y.request.limit===void 0&&y.state?.preserveTruncatedOutput===!0?h=>i.save(h):void 0;return _(await E(F,y.request,M,{originLine:C}),b)}l(ue,"executeRead");var Nt=new Set(["INVALID_RESOLVER_RESULT","NO_RESOLVER","READ_FAILED","RESOLVE_FAILED"]);function Ft(e){let t=e.details.failure;return t!==void 0&&!(t.cause instanceof he)&&Nt.has(t.code)}l(Ft,"isRetryableFailure");async function Vt(e,t,n,o,r,i,a,s,c,p,m,g="model"){let E=st(c,g,m);for(let{resolver:x}of n){let d;try{d=await x.tryResolve(e.path??"",t)}catch(T){return L({code:"RESOLVE_FAILED",source:e.path,message:U(`Text target resolver ${x.id} failed`,T),cause:T})}if(!Se(d))return L({code:"INVALID_RESOLVER_RESULT",source:e.path,message:`Text target resolver ${x.id} returned an invalid result`,cause:d});let f=d;if(f.kind==="not-handled")continue;if(f.kind==="rejected")return L({code:"RESOLVE_FAILED",source:e.path,message:f.rejection.reason});if(f.kind==="failed")return L({code:"RESOLVE_FAILED",source:e.path,message:f.error instanceof Error?f.error.message:String(f.error)});if(f.targets.length===0)return L({code:"RESOLVE_FAILED",source:e.path,message:"Text target resolver returned no targets"});let v=[],u=[],w,P=f.targets.flatMap(T=>(T.ranges??[{start:{lineNumber:1,column:0},end:{lineNumber:1,column:1}}]).map(async y=>{let D=e.path?.startsWith("RESULT#")?e.path:void 0,R={inputScope:"selection",sourceTarget:D,request:{...e,path:T.source,limit:e.limit??rt(y,D)},resolverContext:t,audience:c,outputLimit:g};if(!T.source.startsWith("temp:")){let N=await at(R,r);if(N.kind==="return")return N.result.isError===!0?_(N.result,s):N.result;R=N.context}let A=await le(R,o,p,e.path??T.source);if(A.kind==="return")return _(A.result,s);let C=jt(A.context),B=T.expectedContent,j=B===void 0||C===void 0?void 0:xe(B,C),I=j===void 0?y:j.move(y);if(I===void 0)return _(L({code:"RESOLVE_FAILED",source:T.source,message:`${T.source} changed after the selection was resolved: ${k(j).describe(y)}. Repeat the call that returned the reference for current references.`}),s);let F=await dt({...A.context,request:{...A.context.request,limit:e.limit??rt(I,D)}},r);if(F.kind==="return")return F.result.isError===!0?_(F.result,s):F.result;let M=await ut(F.context,i,a),h=K(k(M.state),M.request,{audience:c,originLine:I.start.lineNumber}),$=await lt({...M,result:h},r);if(h.isError===!0)return _(h,s);let V=$.kind==="return"?$.result:k($.context.result);return V.isError===!0?_(V,s):c==="script"?V:ne(V,{...M.request,limit:e.limit},{originLine:I.start.lineNumber})})),S=await Promise.allSettled(P);for(let T of S){if(T.status==="rejected")throw T.reason;let b=T.value;if(b.isError===!0)return _(b,s);for(let y of b.content)y.type==="text"&&v.push(y.text);u.push(b),w??=b.details}let O={script:u.length===1&&u[0]?.script!==void 0?u[0].script:{kind:"resources",source:e.path,resources:u.map(T=>k(T.script))},content:[{type:"text",text:v.join(`
|
|
15
|
+
`)}],details:c==="script"?{source:e.path,resources:u}:w??{source:e.path}};return _(await E(O,{path:e.path,views:e.views}),s)}}l(Vt,"resolveTextTargets");function st(e,t,n){return e==="script"?async o=>o:t==="none"?async(o,r,i,a)=>ne(o,r,a):(o,r,i,a)=>ze(o,r,n??i,a)}l(st,"readOutputLimiter");function Bt(e){let{script:t,...n}=e;return n}l(Bt,"withoutScriptData");var tt="#";function Mt(e){let t=e.indexOf(tt);if(!(t<=0||t===e.length-1))return{source:e.slice(0,t),fragment:e.slice(t+tt.length)}}l(Mt,"splitAnchoredSource");async function Ut(e,t,n){let o=k(e.state);if(o.contentKind!=="text")return L({code:"UNSUPPORTED_RANGE",source:o.source,resolverId:o.resolvedBy,message:"Anchored reads require textual content. Read this source without an anchor."});if(t.length===0)return L({code:"NO_FRAGMENT_RESOLVER",source:o.source,message:`No fragment resolver is registered for anchor "${n}"`});for(let{registration:r}of t){let i;try{i=await r.resolve({source:o.source,fragment:n,text:o.text,cwd:e.resolverContext.cwd,...e.resolverContext.signal!==void 0&&{signal:e.resolverContext.signal}})}catch(a){return L({code:"FRAGMENT_FAILED",source:o.source,resolverId:r.id,message:U(`Fragment resolver ${r.id} failed`,a),cause:a})}if(!Ue(i))return L({code:"INVALID_RESOLVER_RESULT",source:o.source,resolverId:r.id,message:`Fragment resolver ${r.id} returned an invalid result`,cause:i});if(i.kind!=="not-handled")return i.kind==="failed"?L({code:"FRAGMENT_FAILED",source:o.source,resolverId:r.id,message:i.message,...i.retryPath!==void 0&&{retry:{path:i.retryPath,views:["anchors"]}}}):!Number.isInteger(i.originLine)||i.originLine<1||i.originLine>o.text.lines.length?L({code:"INVALID_RESOLVER_RESULT",source:o.source,resolverId:r.id,message:"The fragment resolved outside the source.",retry:{path:o.source}}):i.originLine}return L({code:"NO_FRAGMENT_RESOLVER",source:o.source,message:`No fragment resolver handled anchor "${n}"`})}l(Ut,"resolveAnchoredOrigin");function rt(e,t){return Math.max(1,e.end.lineNumber-e.start.lineNumber+(t!==void 0&&e.end.column>0?1:0))}l(rt,"selectionLimit");function jt(e){return e.sourceText!==void 0?e.sourceText:e.state?.contentKind==="text"?e.state.text.content:void 0}l(jt,"acquiredText");async function le(e,t,n,o){let r=k(e.request.path),i=e.resolverContext;for(let s of t){let{resolver:c}=s,p=l(async d=>{try{let f=await s.recoverFailure?.(d,i);return L({...d,...f?.length?{candidates:f}:{}})}catch{return L(d)}},"recoveredFailure"),m;try{m=await c.tryResolve(r,i)}catch(d){return{kind:"return",result:await p({code:"RESOLVE_FAILED",source:r,resolverId:c.id,message:U(`Resolver ${c.id} failed`,d),cause:d})}}if(!z(m))return{kind:"return",result:L({code:"INVALID_RESOLVER_RESULT",source:r,resolverId:c.id,message:`Resolver ${c.id} returned an invalid result`,cause:m})};if(m.kind==="not-handled")continue;if(m.kind==="failed")return{kind:"return",result:await p({code:"RESOLVE_FAILED",source:r,resolverId:c.id,message:U(`Resolver ${c.id} failed`,m.error),cause:m.error})};let g=m.resource;if(g.read===void 0)return{kind:"return",result:L({code:"UNSUPPORTED_CAPABILITY",source:g.source,resolverId:c.id,message:`Resource ${g.source} does not support reading`})};for(let{registration:d}of n)try{let f=await d.guard({requestedSource:o,resourceSource:g.source,resolvedBy:c.id,cwd:i.cwd,request:e.request,audience:e.audience??"agent",...i.signal!==void 0&&{signal:i.signal}});if(f.kind==="rejected")return{kind:"return",result:q(L({code:"READ_FAILED",source:g.source,resolverId:c.id,message:`Read blocked by hook ${d.id}: ${f.reason}`}),f.reason)}}catch(f){return{kind:"return",result:q(L({code:"READ_FAILED",source:g.source,resolverId:c.id,message:U(`Read blocked because hook ${d.id} failed`,f),cause:f}),`Hook ${d.id} failed`)}}let E;try{E=await fe.run(Re(g.source,i.cwd,"read"),()=>k(g.read)({...i.signal!==void 0&&{signal:i.signal}}),i.signal)}catch(d){return{kind:"return",result:await p({code:"READ_FAILED",source:g.source,resolverId:c.id,message:U(`Unable to read ${g.source}`,d),cause:d})}}if(!Te(E))return{kind:"return",result:L({code:"INVALID_RESOURCE_CONTENT",source:g.source,resolverId:c.id,message:`Resource ${g.source} returned invalid content`,cause:E})};let x;if(g.sourceBytes!==void 0)try{x=new TextDecoder("utf8",{fatal:!0,ignoreBOM:!0}).decode(g.sourceBytes)}catch{}return{kind:"continue",context:{...e,...x===void 0?{}:{sourceText:x},state:_e(E,g.source,c.id,{preserveTruncatedOutput:s.preserveTruncatedOutput,textMode:c.id==="temp"?"final":"normal",...g.entries===void 0?{}:{entries:g.entries}})}}}let a=`No resolver handled ${r}`;return{kind:"return",result:q(L({code:"NO_RESOLVER",source:r,message:a}),a)}}l(le,"resolveSource");async function at(e,t){let n=e;for(let o of t){if(o.registration.stage!=="pre-read")continue;let r=await ce(o.registration.handler,n,o.pluginId,"pre-read");if(r.kind==="return")return r;n=r.context}return{kind:"continue",context:n}}l(at,"runPreReadHandlers");async function dt(e,t){let n=e.state,o=n===void 0?[]:t.filter(i=>i.registration.stage==="read"&&Yt(i.registration,n)),r=e;for(let i of o){let a=i.registration;if(a.stage!=="read")continue;let s=await ce(a.handler,r,i.pluginId,"read");if(s.kind==="return")return s;r=s.context}return{kind:"continue",context:r}}l(dt,"runReadHandlers");async function ut(e,t,n,o){let r=e.state;if(r?.contentKind!=="text"||n.size===0)return e;let i=r.text,a=t.filter(({registration:d})=>n.has(d.view)),s=new Set(a.flatMap(({registration:d})=>d.includes??[])),c=a.filter(({registration:d})=>!s.has(d.view)),m=(e.request.offset!==void 0||e.request.limit!==void 0)&&!c.some(({registration:d})=>d.showsLinesOutsideRange===!0)?Ce(e.request,i.lines.length,o):void 0,g={purpose:"read",...e.sourceText===void 0?{}:{sourceText:e.sourceText},audience:e.resolverContext.audience,requestedViews:e.request.views,source:r.source,cwd:e.resolverContext.cwd,resolvedBy:r.resolvedBy,...m!==void 0&&{lineNumbers:new Set(i.lines.slice(m.startIndex,m.endIndex).map(d=>d.lineNumber))},...e.resolverContext.signal!==void 0&&{signal:e.resolverContext.signal}},E=await Promise.all(c.map(async({registration:d})=>({presenterId:d.presenter.id,document:await d.presenter.present(i,g)}))),x=Gt(i,E);return{...e,state:{...r,text:x}}}l(ut,"runTextPresenters");function W(e){let t=e.indexOf(":");return t<0?e:e.slice(0,t)}l(W,"viewName");function _(e,t){let n=[];if(t.ignored.length>0&&n.push(t.ignored.length===1?`Unknown view ignored: ${t.ignored[0]}. Remove it or choose a supported view from the views parameter.`:`Unknown views ignored: ${t.ignored.join(", ")}. Remove these entries or choose supported views from the views parameter.`),e.isError!==!0&&e.content.some(a=>a.type!=="text"))for(let a of t.textOnly)n.push(`View not applied: ${a} requires text. Read a text source to use ${W(a)}.`);if(n.length===0||e.details.viewWarnings!==void 0)return e;let o=n.join(`
|
|
16
|
+
`),r=e.content[0],i=e.content.length===1&&r?.type==="text"?[{...r,text:`${o}
|
|
17
|
+
${r.text}`}]:[{type:"text",text:o},...e.content];return{...e,content:i,details:{...e.details,...t.ignored.length===0?{}:{ignoredViews:t.ignored},viewWarnings:n}}}l(_,"withViewWarnings");function Gt(e,t){let n=e.lines;for(let r of t)Ht(e,r),n=n.map((i,a)=>Wt(k(e.lines[a]),i,k(r.document.lines[a])));let o=[...new Map([e,...t.map(r=>r.document)].flatMap(r=>r.references??[]).map(r=>[r.value,r])).values()];return{...e,lines:n,...o.length===0?{}:{references:o}}}l(Gt,"mergeViewContributions");function Ht(e,t){let n=t.document;if(n.source!==e.source||n.content!==e.content||n.lines.length!==e.lines.length)throw new Error(`Text presenter ${t.presenterId} changed canonical text`);for(let[o,r]of n.lines.entries()){let i=k(e.lines[o]);if(r.lineNumber!==i.lineNumber||r.content!==i.content||r.lineEnding!==i.lineEnding)throw new Error(`Text presenter ${t.presenterId} changed canonical text`)}}l(Ht,"assertPresentationOnly");function Wt(e,t,n){let o=zt(e.presentation,t.presentation,n.presentation),r=Xt(e.metadata,t.metadata,n.metadata),i=n.anchors===void 0?t.anchors:[...new Set([...t.anchors??[],...n.anchors])];return o===t.presentation&&r===t.metadata&&i===t.anchors?t:{...t,...o!==void 0&&{presentation:o},...r!==void 0&&{metadata:r},...i!==void 0&&{anchors:i}}}l(Wt,"mergePresentedLine");function zt(e,t,n){if(n===e)return t;let o=nt(e?.prefix,t?.prefix,n?.prefix),r=nt(e?.suffix,t?.suffix,n?.suffix),i=ot(e?.before,t?.before,n?.before),a=ot(e?.after,t?.after,n?.after),s=n?.marker===e?.marker?t?.marker:n?.marker;return o===t?.prefix&&r===t?.suffix&&i===t?.before&&a===t?.after&&s===t?.marker?t:{...t,...o!==void 0&&{prefix:o},...r!==void 0&&{suffix:r},...i!==void 0&&{before:i},...a!==void 0&&{after:a},...s!==void 0&&{marker:s}}}l(zt,"mergeLinePresentation");function nt(e,t,n){if(n===e)return t;let o=e??"",r=t??"",i=n??"";return o.length>0&&i.startsWith(o)?`${r}${i.slice(o.length)}`:o.length>0&&i.endsWith(o)?`${i.slice(0,-o.length)}${r}`:`${r}${i}`}l(nt,"mergePresentedText");function ot(e,t,n){if(n===e)return t;let o=e??[],r=t??[],i=n??[];return qt(i,o)?[...r,...i.slice(o.length)]:Kt(i,o)?[...i.slice(0,i.length-o.length),...r]:[...r,...i]}l(ot,"mergePresentedRows");function qt(e,t){return t.length>0&&t.length<=e.length&&t.every((n,o)=>e[o]===n)}l(qt,"startsWithRows");function Kt(e,t){let n=e.length-t.length;return t.length>0&&n>=0&&t.every((o,r)=>e[n+r]===o)}l(Kt,"endsWithRows");function Xt(e,t,n){if(n===e||n===void 0)return t;let o=Object.fromEntries(Object.entries(n).filter(([r,i])=>e?.[r]!==i));return Object.keys(o).length===0?t:{...t,...o}}l(Xt,"mergeLineMetadata");async function lt(e,t){let n=t.filter(({registration:i})=>i.stage==="post-read"),o=await Promise.all(n.map(i=>ce(i.registration.handler,e,i.pluginId,"post-read")));for(let i of o)if(i.kind==="return")return i;let r=e.result;for(let i of o)if(!(i.kind==="return"||i.transform===void 0)){if(r===void 0)throw new Error("Post-read transform requires a read result");r=i.transform(r)}return{kind:"continue",context:r===void 0?e:{...e,result:r}}}l(lt,"runPostReadHandlers");async function ce(e,t,n,o){try{return await e(t)}catch(r){return{kind:"return",result:L({code:"PIPELINE_FAILED",...t.state?.source===void 0?t.result?.details.source===void 0?{}:{source:t.result.details.source}:{source:t.state.source},pluginId:n,stage:o,message:`Plugin ${n} failed during ${o}`,cause:r})}}}l(ce,"invokeHandler");function Yt(e,t){return(e.when.resolvedBy==="any"||e.when.resolvedBy===t.resolvedBy)&&(e.when.contentKind==="any"||e.when.contentKind===t.contentKind)}l(Yt,"matchesReadState");function Jt(e,t,n,o,r){let i=new Set(o.map(({resolver:s})=>s.id));for(let s of t){if(!J(s))throw new TypeError(`Plugin ${e} provided an invalid resource resolver`);if(i.has(s.resolver.id))throw new Error(`Resource resolver ${s.resolver.id} is already registered`);i.add(s.resolver.id)}let a=new Set(r.filter(s=>s.pluginId===e).map(s=>s.registration.stage));for(let s of n){if(!Q(s))throw new TypeError(`Plugin ${e} provided an invalid read handler`);if(a.has(s.stage))throw new Error(`Plugin ${e} already handles ${s.stage}`);a.add(s.stage)}}l(Jt,"validateContributions");function Qt(e,t,n){let o=new Set(n.map(({registration:r})=>r.id));for(let r of t){if(!ee(r))throw new TypeError(`Plugin ${e} provided an invalid fragment resolver`);if(o.has(r.id))throw new Error(`Fragment resolver ${r.id} is already registered`);o.add(r.id)}}l(Qt,"validateFragmentRegistrations");function U(e,t){return!(t instanceof Error)||t.message.length===0?e:`${e}: ${t.message}`}l(U,"appendErrorMessage");function ct(e="compact",t){let n=[],o=new Set,r=new Map,i=it(()=>tr(r),e,()=>rr(r),t),a=Promise.resolve();return{read:i,registerPlugin(s){let c=Zt(s);if(c!==void 0)return Promise.reject(c);let p=r.get(s.id);if(p?.plugin===s)return p.ready;if(p!==void 0)return Promise.reject(new Error(`Plugin ${s.id} is already registered`));let m={status:"pending"},g=[],E=[],x=er(s.id,i,E,g,n),d=a.then(async()=>{try{await s.setup(x.api),x.commit(),m.status="active";return}catch(v){throw x.close(),v}}),f={lifecycle:m,plugin:s,promptGuidelines:E,parameterDescriptions:g,ready:d};return r.set(s.id,f),o.add(d),a=d.catch(()=>{}),d.then(()=>{o.delete(d)},()=>{o.delete(d),r.get(s.id)===f&&r.delete(s.id)}),d},async waitForPendingPlugins(){await Promise.all(o)}}}l(ct,"createReadCore");function Zt(e){if(e.protocol!==G)return new Error(`Plugin ${e.id} uses an unsupported protocol`);if(e.apiVersion!==H)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")}l(Zt,"getPluginValidationError");function er(e,t,n,o,r){let i=[],a=[],s=[],c=[],p=[],m=[],g=[],E=[],x=[],d="setup",f=l(()=>{if(d==="closed")throw new Error(`Plugin ${e} API is closed`)},"assertAvailable");return{api:{addOutputReducer(u){if(f(),typeof u!="function")throw new TypeError("Expected an output reducer");(d==="setup"?i:r).push(u)},async reduceOutput(u,w,P){f();for(let S of r){w.signal?.throwIfAborted();let O=await S(u,w,P);if(O!==void 0)return O}},saveTemporary(u){return f(),t.saveTemporary(u)},setOutputSaver(u){f(),t.setOutputSaver(u)},read(u,w,P){return f(),t.execute(u,w,P)},readWith(u,w,P,S){return f(),t.executeWith(u,w,P,S)},addResourceGuard(u){f(),d==="setup"?c.push(u):t.registerContributions(e,{resourceGuards:[u]})},addResolver(u){if(f(),!J(u))throw new TypeError(`Plugin ${e} provided an invalid resource resolver`);if(d==="setup"){p.push(u);return}t.registerContributions(e,{resolvers:[u]})},addTargetResolver(u){if(f(),!Y(u))throw new TypeError(`Plugin ${e} provided an invalid text target resolver`);if(d==="setup"){m.push(u);return}t.registerContributions(e,{targetResolvers:[u]})},addHandler(u){if(f(),!Q(u))throw new TypeError(`Plugin ${e} provided an invalid read handler`);if(d==="setup"){g.push(u);return}t.registerContributions(e,{handlers:[u]})},addView(u){if(f(),!Z(u))throw new TypeError(`Plugin ${e} provided an invalid view registration`);if(d==="setup"){E.push(u);return}t.registerContributions(e,{views:[u]})},addFragmentResolver(u){if(f(),!ee(u))throw new TypeError(`Plugin ${e} provided an invalid fragment resolver`);if(d==="setup"){x.push(u);return}t.registerContributions(e,{fragments:[u]})},describe(u){if(f(),a.length>0||o.length>0)throw new Error(`Plugin ${e} provides more than one description`);let w=nr(u);if(d==="setup"){a.push(w);return}o.push(w)},addPromptGuideline(u){f();let w=ft(u);if(d==="setup"){s.push(w);return}n.push(w)}},close(){d="closed"},commit(){if(d!=="setup")throw new Error(`Plugin ${e} setup contributions cannot be committed`);t.registerContributions(e,{resourceGuards:c,resolvers:p,targetResolvers:m,handlers:g,views:E,fragments:x}),o.push(...a),r.push(...i),n.push(...s),d="active"}}}l(er,"createPluginContributionController");function tr(e){let t=[];for(let n of e.values())if(n.lifecycle.status==="active")for(let o of n.promptGuidelines){let r=Rt(o);r!==void 0&&t.push(r)}return t}l(tr,"renderPromptGuidelines");function rr(e){let t={};for(let n of e.values())if(n.lifecycle.status==="active")for(let o of n.parameterDescriptions)for(let r of Object.keys(o)){let i=o[r];if(i===void 0)continue;let a=Rt(i);a!==void 0&&(t[r]??=[]).push(a)}return Object.fromEntries(Object.entries(t).map(([n,o])=>[n,[...new Set(o.flatMap(r=>r.split(`
|
|
18
|
+
`)))].join(`
|
|
19
|
+
`)]))}l(rr,"renderParameterDescriptions");function nr(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("Read plugin parameter descriptions must be an object");let t=Object.entries(e);if(t.length===0)throw new Error("Read plugin parameter descriptions are empty");let n={};for(let[o,r]of t){if(!Object.hasOwn(Ne.properties,o))throw new Error(`Read plugin description names an unknown parameter: ${o}`);n[o]=ft(r)}return n}l(nr,"normalizeParameterDescriptions");function ft(e){if(typeof e=="string")return pt(e);if(typeof e=="function")return e;throw new TypeError("Read plugin prompt description must be a string or callback")}l(ft,"normalizeDescriptionSource");function Rt(e){if(typeof e=="string")return e;let t=e();return t===void 0?void 0:pt(t)}l(Rt,"renderDescriptionSource");function pt(e){if(typeof e!="string")throw new TypeError("Read plugin prompt description must be a string");let t=e.replaceAll(`\r
|
|
20
|
+
`,`
|
|
21
|
+
`).replaceAll("\r",`
|
|
22
|
+
`).split(`
|
|
23
|
+
`).map(o=>o.trimEnd());for(;t[0]?.trim().length===0;)t.shift();for(;t.at(-1)?.trim().length===0;)t.pop();let n=t.join(`
|
|
24
|
+
`);if(n.trim().length===0)throw new Error("Read plugin prompt description is empty");return n}l(pt,"normalizeDescription");function or(e){return typeof e=="object"&&e!==null}l(or,"isRecord");function ir(e){return e==="full"||e==="disabled"?e:"compact"}l(ir,"parsePresentation");async function sr(e,t){let n=ct(()=>ir(t?.preferences["ui.read"]),ve(e,"read")),o=Ee(e);n.read.setReadObserver(async({script:s,details:c,content:p},m,g)=>{if(s===void 0)return;let E=[],x=c.truncation?.truncated===!0?c.truncation:void 0,d=s.kind==="resources"?x===void 0?s.resources:[]:[s];for(let v of d){if(v.kind!=="text"||v.fileDigest===void 0)continue;let{source:u,fileDigest:w}=v,P=await me(u,m);if(P.length===0)continue;let O=(v.target===void 0?void 0:(()=>{try{return o.resolve(v.target,m)}catch{return}})())?.targets.find(A=>A.source===u&&ie(A.expectedContent)===w),T=O?.ranges??[],b=v.lines[0],y=x===void 0?void 0:We(v,x),D=x===void 0?T:b===void 0||y===void 0?[]:T.filter(A=>A.adjusted!==!0).flatMap(A=>ke(A,{start:{lineNumber:b.lineNumber,column:0},end:{lineNumber:y.lineNumber,column:y.content.length}})),R=O===void 0?void 0:{content:O.expectedContent,ranges:D};e.events.emit(pe,{keys:P,digest:w,...g&&R!==void 0&&{visible:R},complete:x===void 0&&ie(v.content)===w}),!g&&R!==void 0&&E.push({source:u,...R})}let f=p.length===1?p[0]:void 0;f?.type==="text"&&ge(f,E)}),await n.registerPlugin({protocol:G,apiVersion:H,id:"result-targets",setup(s){s.addHandler({stage:"post-read",handler:De(o,n.read.execute)})}});let r=e.events.on(be,s=>{if(!Le(s))throw new Error("Invalid pi-agent-read plugin registration request");s.accept(n.registerPlugin(s.plugin))});e.on("session_shutdown",async()=>{r(),await n.read.dispose()});let i=new $e,a=Ae(n.read.tool,i);e.registerTool(a),e.on("before_agent_start",async()=>{await n.waitForPendingPlugins(),e.getActiveTools().includes("read")&&e.registerTool(a)}),e.on("tool_result",s=>{if(!(s.toolName!=="read"||!or(s.details)))return{details:je(s.details,s.content.flatMap(c=>c.type==="text"?[c.text]:[]).join(`
|
|
25
|
+
`)),...s.details.failure!==void 0&&{isError:!0}}}),e.events.emit(Pe,{protocol:G,apiVersion:H}),await n.waitForPendingPlugins()}l(sr,"registerReadCore");export{sr as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as d}from"./chunk-
|
|
1
|
+
import{a as d}from"./chunk-JY63UUC2.js";import{d as s,e as l,f as c}from"./chunk-XEPCURYZ.js";import{a as i}from"./chunk-IRLWXPL4.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{a}from"./chunk-W25HNEMR.js";import"./chunk-3JBQYLJ4.js";import"./chunk-47SPPIXK.js";import"./chunk-VAXLSPPU.js";import"./chunk-XKVU6AAS.js";import"./chunk-MPT3R4BL.js";import"./chunk-KN6VPARZ.js";import"./chunk-I3G6K7QU.js";import"./chunk-HSAGZWPO.js";import"./chunk-PS2B6THP.js";import"./chunk-OEEE5BLN.js";import"./chunk-2QCE7GOV.js";import"./chunk-EI7MMDWY.js";export{a as default};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{B as ce,j as ae}from"./chunk-OEEE5BLN.js";import{a as i}from"./chunk-EI7MMDWY.js";import D from"node:path";function cn(r){if(/^\/[A-Z]:\/?$/u.test(r))return;let e=D.posix.dirname(r);return e===r?void 0:e}i(cn,"remoteParent");function S(r,e,t="linux"){if(!/^[a-z0-9][a-z0-9_-]*$/u.test(r))throw new TypeError("SSH target IDs must contain lowercase letters, digits, underscores or hyphens");if(e.includes("\0"))throw new TypeError("Remote paths must contain no NUL characters");let n=t==="windows"?Ue(e):Fe(e),s=n.split("/").map(o=>encodeURIComponent(o).replaceAll("%3A",":")).join("/");return{target:r,path:n,source:`ssh://${r}${s}`}}i(S,"remoteLocation");function Fe(r){if(!r.startsWith("/"))throw new TypeError("Remote paths must be absolute");return D.posix.normalize(r)}i(Fe,"posixPath");function Ue(r){let e=r.replaceAll("\\","/"),t=/^\/?(?<drive>[A-Za-z]):(?<rest>\/.*)?$/u.exec(e);if(!t?.groups?.drive)throw new TypeError("Windows remote paths must start with a drive, such as C:/Users; UNC and drive-relative paths are not supported");return`/${t.groups.drive.toUpperCase()}:${D.posix.normalize(t.groups.rest??"/")}`}i(Ue,"windowsPath");function J(r,e,t=()=>{}){if(r.startsWith("ssh:")){let o=new URL(r);if(!r.startsWith("ssh://")||!o.hostname||o.username||o.password||o.port||o.search||o.hash||r.includes("?")||r.includes("#"))throw new TypeError("SSH references require a configured target and an absolute path, without credentials or selectors");return S(o.hostname,decodeURIComponent(o.pathname),t(o.hostname))}if(!e?.startsWith("ssh:"))return;let n=J(e,void 0,t);if(!n)throw new TypeError("Invalid remote workspace");let s=t(n.target);if(s==="windows"&&/^[A-Za-z]:/u.test(r))return S(n.target,r,"windows");if(!/^[A-Za-z][A-Za-z\d+.-]*:/u.test(r))return s==="windows"?We(n,r):S(n.target,D.posix.resolve(n.path,r))}i(J,"resolveRemoteLocation");function We(r,e){let t=e.replaceAll("\\","/");if(t.startsWith("//"))throw new TypeError("UNC paths are not supported on Windows SSH targets");let s=`${r.path.slice(0,3)}${D.posix.resolve(r.path.slice(3)||"/",t)}`;return S(r.target,s,"windows")}i(We,"resolveWindowsPath");import{readFile as He}from"node:fs/promises";function de(r){let e=He(r,"utf8");return e.catch(()=>{}),e}i(de,"packagedSource");function b(r){return r.os??"linux"}i(b,"targetOs");function U(r){return b(r)==="windows"?`${r.workspace.slice(0,3)}/`:"/"}i(U,"neutralDirectory");function W(r){if(S(r.id,r.workspace,b(r)),!/^(?:[A-Za-z0-9_][A-Za-z0-9_.-]*@)?[A-Za-z0-9_][A-Za-z0-9_.-]*$/u.test(r.host))throw new TypeError("SSH host must be an OpenSSH host alias, not a command or URI")}i(W,"validateSshTarget");function H(r){return{python:r}}i(H,"remotePython");var qe=["ssh-channel-worker.py","ssh_channel_common.py","ssh_channel_posix.py","ssh_channel_windows.py","ssh-worker.py","ssh_worker_common.py","ssh_worker_posix.py","ssh_worker_windows.py","ssh_paths.py","ssh_windows_files.py","ssh-transfer-worker.py","ssh-transfer-worker-windows.py"],ze=new Map(qe.map(r=>[r,de(new URL(`./${r}`,new URL("../src/backend/ssh-transport.ts",import.meta.url).href))]));function x(r){let e=ze.get(r);if(e===void 0)throw new Error(`Unknown SSH worker source: ${r}`);return e}i(x,"workerSource");function he(r,e){return["import importlib.abc as _pi_abc, importlib.util as _pi_util, sys as _pi_sys",`_pi_modules = {${Object.entries(e).map(([n,s])=>`${JSON.stringify(n)}:${JSON.stringify(s)}`).join(",")}}`,"class _PiLoader(_pi_abc.Loader):"," def __init__(self, source): self.source = source"," def create_module(self, spec): return None"," def exec_module(self, module):"," exec(compile(self.source, '<pi-agent-ide/' + module.__name__ + '>', 'exec'), module.__dict__)","class _PiFinder(_pi_abc.MetaPathFinder):"," def find_spec(self, name, path=None, target=None):"," source = _pi_modules.get(name)"," return None if source is None else _pi_util.spec_from_loader(name, _PiLoader(source))","_pi_sys.meta_path.insert(0, _PiFinder())",r].join(`
|
|
2
|
+
`)}i(he,"bundlePython");var Ve={channel:{entry:"ssh-channel-worker.py",common:"ssh_channel_common",platform:"ssh_channel"},file:{entry:"ssh-worker.py",common:"ssh_worker_common",platform:"ssh_worker"}},j="ssh_windows_files",F=new Map;function A(r,e){let t=`${r}:${e}`,n=F.get(t);if(!n){let s=Ve[e],o=`${s.platform}_${r==="windows"?"windows":"posix"}.py`,c=r==="windows"&&e==="file"?x(`${j}.py`):void 0;n=Promise.all([x(s.entry),x(`${s.common}.py`),x("ssh_paths.py"),x(o),c]).then(([h,d,l,m,p])=>he(h,{[s.common]:d,ssh_paths:l,[`${s.platform}_platform`]:m,...p===void 0?{}:{[j]:p}})),F.set(t,n)}return n}i(A,"sshWorkerBundle");function gn(r){let e=`${r}:transfer`,t=F.get(e);return t||(t=r==="windows"?Promise.all([x("ssh-transfer-worker-windows.py"),x("ssh_worker_common.py"),x("ssh_paths.py"),x(`${j}.py`)]).then(([n,s,o,c])=>he(n,{ssh_worker_common:s,ssh_paths:o,[j]:c})):x("ssh-transfer-worker.py"),F.set(e,t)),t}i(gn,"sshTransferProgram");function ue(r){return r==="windows"?["py -3","python"]:["python3"]}i(ue,"interpreterCandidates");var Ye="import sys;exec(sys.stdin.buffer.raw.readline())";function le(r){return`${r} -c "${Ye}"`}i(le,"sshBootstrapCommand");var Z="pi-agent-ide-worker:";function pe(r,e){let n=["import json,os,sys","def _pi_read(n):"," b=bytearray()"," while len(b)<n:"," c=os.read(0,n-len(b))"," if not c:raise SystemExit(70)"," b+=c"," return bytes(b)",`_pi_ok=${r==="windows"?'sys.platform=="win32"':'sys.platform.startswith("linux")'}`,`os.write(1,b"\\n${Z}"+json.dumps({"platform":sys.platform,"accepted":_pi_ok}).encode()+b"\\n")`,"if not _pi_ok:raise SystemExit(0)","exec(compile(_pi_read(int(_pi_read(10))),'<pi-agent-ide>','exec'))"].join(`
|
|
3
|
+
`),s=Buffer.from(e,"utf8");return Buffer.concat([Buffer.from(`exec(${JSON.stringify(n)})
|
|
4
|
+
`,"utf8"),Buffer.from(String(s.length).padStart(10,"0"),"ascii"),s])}i(pe,"sshBootstrapInput");function q(r){let e=["-o","BatchMode=yes","-o","StrictHostKeyChecking=yes","-o","ForwardAgent=no","-o","PermitLocalCommand=no","-o","ClearAllForwardings=yes"];return r.configFile!==void 0&&e.push("-F",r.configFile),e}i(q,"sshSecurityOptions");function fe(r,e,t=[]){return["-T","-o","LogLevel=VERBOSE",...q(r),...t,"--",r.host,e]}i(fe,"systemSshArguments");function me(r,e,t="python3"){if(/Host key verification failed|REMOTE HOST IDENTIFICATION HAS CHANGED|No .* host key is known/u.test(e))return"HOST_KEY_FAILED";if(/Permission denied \([^)]*\)/u.test(e))return"AUTH_FAILED";if(r===255)return"TRANSPORT_FAILED";let[n=""]=t.split(" "),s=n.replaceAll(/[^A-Za-z0-9_-]/gu,"");return new RegExp([`\\b${s}:\\s*(?:command\\s+)?not found`,`Unknown command:?\\s*'?${s}\\b`,`'${s}' is not recognized`,"Python was not found"].join("|"),"u").test(e)?"DEPENDENCY_UNAVAILABLE":"TRANSPORT_FAILED"}i(me,"sshFailureCode");import{createHash as Yt}from"node:crypto";import{Type as a}from"typebox";import{Value as De}from"typebox/value";import{spawn as $t}from"node:child_process";import{PassThrough as Ce}from"node:stream";import{setTimeout as jt}from"node:timers/promises";import{Type as g}from"typebox";import{Value as _e}from"typebox/value";var Je=/^Authenticated to /mu;function K(r){return Je.test(r)}i(K,"sshAuthenticated");var Ze=[["keepalive-timeout",/Timeout, server .* not responding/u],["reset",/Connection reset/u],["closed-by-target",/Connection closed by|closed by remote host/u],["broken-pipe",/Broken pipe/u],["timed-out",/(?:Connection|Operation) timed out/u],["refused",/Connection refused/u],["unreachable",/No route to host|Network is unreachable|Host is down/u],["unresolved",/Could not resolve hostname/u]];function G(r,e){let t=e.split(/\r?\n/u);for(let n=t.length-1;n>=0;n--){let s=t[n]??"";for(let[o,c]of Ze)if(c.test(s))return o}return r===null?"signal":"unexplained"}i(G,"sshConnectionLossReason");var Ke=/^Transferred: /mu;function ye(r){let e=G(0,r);return e==="unexplained"&&Ke.test(r)?"closed-by-target":e}i(ye,"sshMasterConnectionLossReason");var Ge=new Set(["keepalive-timeout","reset","closed-by-target","broken-pipe","timed-out","unreachable"]);function we(r){return Ge.has(r)}i(we,"sshConnectionLossTransient");var Xe={"keepalive-timeout":"the target stopped answering keepalive probes, so this side closed the connection",reset:"the connection was reset (by the target or the network)","closed-by-target":"the target closed the connection","broken-pipe":"the connection broke as this side sent data to the target","timed-out":"the network stopped delivering data (TCP timed out)",refused:"the target refused the connection",unreachable:"the network has no route to the target",unresolved:"the host name did not resolve","stop-unconfirmed":"the target did not confirm a stop in time, so this side closed the connection",signal:"the local SSH client was killed by a signal",unexplained:"the SSH connection ended without the command's exit status"},Qe={connecting:"while connecting",starting:"while the command was starting",running:"while the command was running"};function ge(r){let e=r/1e3;return`${e<10?e.toFixed(1):Math.round(e)} s`}i(ge,"seconds");function Se(r){let e=r.silentMs!==void 0&&r.silentMs>=1e3?`; nothing had arrived from the target for ${ge(r.silentMs)} before that`:"",t=r.phase==="connecting"?"; nothing ran on the target":"";return`${Xe[r.reason]} ${Qe[r.phase]}, ${ge(r.afterMs)} after the connection attempt began${e}${t}`}i(Se,"describeSshConnectionLoss");import{execFile as et,spawn as tt,spawnSync as nt}from"node:child_process";import{createHash as rt,randomUUID as st}from"node:crypto";import{closeSync as ot,existsSync as it,fstatSync as at,openSync as ct,readSync as dt,rmSync as be}from"node:fs";import{lstat as ht,mkdir as ut,readdir as lt,unlink as $}from"node:fs/promises";import pt from"node:net";import Ee from"node:path";var ft=8,mt=4,gt=60,yt=3e4,wt=2e3,St=3e4,I={options:[],release(){},masterDiagnostics:i(()=>"","masterDiagnostics")},z=".log",bt=4096,kt=15,Et=3,X=new Map,Tt=st(),ke=Symbol.for("pi-agent-ide.ssh-master.own-sockets"),Pt;async function Te(r,e,t){if(process.platform==="win32")return I;let n=Date.now()+e,s=`${r.host}\0${r.configFile??""}`,o=X.get(s);o===void 0&&(o=vt(s,r),X.set(s,o));let c=await o;if(c===void 0)return I;for(;;){if(t?.aborted)return I;let h=c.members.find(p=>p.started&&p.sessions<ft);if(h!==void 0){let p=_t(c,h);if(await ee(h.socket))return p;p.release(),Pe(c,h);continue}let d=c.members.find(p=>!p.started);if(d!==void 0){if(!await ve(d.ready,n-Date.now(),t))return I;continue}let l=c.failedAt!==void 0&&Date.now()-c.failedAt<yt;if(c.members.length<mt&&!l){Ct(c);continue}let m=Math.min(wt,n-Date.now());if(c.members.length===0||m<=0||!await Ot(c,m,t))return I}}i(Te,"sshRoute");function xt(){let r=Q();for(let[e,t]of r)be(`${e}${z}`,{force:!0}),it(e)&&(nt("ssh",[...q(t),"-o",`ControlPath=${e}`,"-O","exit","--",t.host],{stdio:"ignore",timeout:2e3}),be(e,{force:!0}));r.clear(),X.clear()}i(xt,"stopSshMasters");async function vt(r,e){let t=await It(e);if(t===void 0||At(t))return;let n=await(Pt??=Rt());if(n===void 0)return;let s=Ee.join(n,`${process.pid}-${rt("sha256").update(`${Tt}\0${r}`).digest("hex").slice(0,16)}`),o=Nt(t);return{target:e,name:s,keepalive:o,members:[],waiters:[],launched:0}}i(vt,"createPool");function Ct(r){let e=`${r.name}-${r.launched++}`;Q().set(e,r.target);let t={socket:e,sessions:0,started:!1,ready:Lt(r.target,e,r.keepalive)};t.ready.then(n=>{n?t.started=!0:(r.failedAt=Date.now(),Pe(r,t))}),r.members.push(t)}i(Ct,"launchMember");function _t(r,e){e.sessions++;let t=!1;return{options:["-o","ControlMaster=no","-o",`ControlPath=${e.socket}`],masterDiagnostics:i(()=>Mt(`${e.socket}${z}`,bt),"masterDiagnostics"),release(){t||(t=!0,e.sessions--,r.waiters.shift()?.())}}}i(_t,"take");function Pe(r,e){let t=r.members.indexOf(e);t>=0&&r.members.splice(t,1),Q().delete(e.socket),$(e.socket).catch(()=>{}),$(`${e.socket}${z}`).catch(()=>{})}i(Pe,"remove");function Q(){let r=globalThis,e=r[ke];return e===void 0&&(e=new Map,r[ke]=e,process.once("exit",xt)),e}i(Q,"ownSockets");function Ot(r,e,t){let n,s=new Promise(o=>{n=i(()=>o(!0),"wake"),r.waiters.push(n)});return ve(s,e,t).finally(()=>{let o=n===void 0?-1:r.waiters.indexOf(n);o>=0&&r.waiters.splice(o,1)})}i(Ot,"slot");async function Lt(r,e,t){let n=`${e}${z}`;await Promise.all([$(e).catch(()=>{}),$(n).catch(()=>{})]);let s=tt("ssh",[...q(r),"-o","ControlMaster=yes","-o",`ControlPath=${e}`,"-o",`ControlPersist=${gt}`,...t,"-o","LogLevel=VERBOSE","-E",n,"-f","-N","--",r.host],{stdio:"ignore"});return await new Promise(c=>{let h=setTimeout(()=>{s.kill("SIGKILL"),c(null)},St);s.once("error",()=>{clearTimeout(h),c(null)}),s.once("exit",d=>{clearTimeout(h),c(d)})})===0&&await ee(e)}i(Lt,"launch");async function It(r){return await new Promise(e=>{et("ssh",[...r.configFile===void 0?[]:["-F",r.configFile],"-G","--",r.host],{timeout:1e4,maxBuffer:1024*1024},(t,n)=>e(t?void 0:n))})}i(It,"userConfiguration");function xe(r){return new Map(r.split(`
|
|
5
|
+
`).map(e=>{let[t="",...n]=e.trim().split(" ");return[t.toLowerCase(),n.join(" ")]}))}i(xe,"configurationOptions");function At(r){let e=xe(r),t=e.get("controlpath");return(e.get("controlmaster")??"false")!=="false"||t!==void 0&&t!=="none"}i(At,"multiplexingConfigured");function Nt(r){let e=xe(r),t=Number(e.get("serveraliveinterval")),n=Number(e.get("serveralivecountmax")),s=Number.isSafeInteger(t)&&t>0;return["-o",`ServerAliveInterval=${s?t:kt}`,"-o",`ServerAliveCountMax=${s&&Number.isSafeInteger(n)&&n>0?n:Et}`]}i(Nt,"masterKeepaliveOptions");async function Rt(){let r=process.getuid?.();if(r===void 0)return;let e=`/tmp/pi-ssh-${r}`;try{await ut(e,{mode:448}).catch(n=>{if(n.code!=="EEXIST")throw n});let t=await ht(e);if(!t.isDirectory()||t.uid!==r||(t.mode&63)!==0)return}catch{return}return await Bt(e),e}i(Rt,"privateSocketDirectory");async function Bt(r){let e=await lt(r).catch(()=>[]);await Promise.all(e.map(async t=>{let n=Number(/^(\d+)-[0-9a-f]{16}-\d+(?:\.log)?$/u.exec(t)?.[1]);if(!Number.isSafeInteger(n)||n===process.pid||Dt(n))return;let s=Ee.join(r,t);await ee(s)||await $(s).catch(()=>{})}))}i(Bt,"removeStaleSockets");function Mt(r,e){let t;try{t=ct(r,"r");let n=at(t).size,s=Buffer.alloc(Math.min(n,e));return dt(t,s,0,s.length,n-s.length),s.toString("utf8")}catch{return""}finally{t!==void 0&&ot(t)}}i(Mt,"fileTail");function Dt(r){try{return process.kill(r,0),!0}catch(e){return e.code==="EPERM"}}i(Dt,"running");function ee(r){return new Promise(e=>{let t=pt.connect(r),n=i(o=>{clearTimeout(s),t.destroy(),e(o)},"finish"),s=setTimeout(()=>n(!1),1e3);t.once("connect",()=>n(!0)),t.once("error",()=>n(!1))})}i(ee,"listening");async function ve(r,e,t){if(t?.aborted)return!1;let n,s;try{return await Promise.race([r,new Promise(o=>{n=setTimeout(()=>o(!1),e),s=i(()=>o(!1),"abort"),t?.addEventListener("abort",s,{once:!0})})])}finally{clearTimeout(n),s&&t?.removeEventListener("abort",s)}}i(ve,"settled");var Oe=Buffer.from(Z,"ascii"),Ft=g.Object({platform:g.String(),accepted:g.Boolean()}),Ut=g.Union([g.Object({kind:g.Literal("ready"),pid:g.Integer({minimum:1}),identity:g.Optional(g.String({pattern:"^[a-f0-9-]+:[0-9]+$"}))}),g.Object({kind:g.Literal("ack"),id:g.Integer({minimum:1})}),g.Object({kind:g.Union([g.Literal("stdout"),g.Literal("stderr")]),bytes:g.String({maxLength:32768})}),g.Object({kind:g.Literal("exit"),exitCode:g.Integer()}),g.Object({kind:g.Literal("error"),code:g.String({pattern:"^[A-Z][A-Z0-9_]*$"}),effect:g.Union([g.Literal("not-applied"),g.Literal("unknown")])})]),te=16384,Ae=128,Wt=Ae*te,Le=new Map;async function N(r,e,t,n,s={}){W(r),s.pty&&Ne(s.pty.cols,s.pty.rows);let o=b(r),c=S(r.id,n,o).source,h=s.timeoutMs??3e4;if(!Number.isFinite(h)||h<=0)throw new TypeError("SSH startup deadline must be positive");s.signal?.throwIfAborted();let d=pe(o,await A(o,"channel"));s.signal?.throwIfAborted();let l=JSON.stringify({...typeof e=="string"?{command:e}:{python:e.python},args:t,cwd:n,...s.pty?{pty:s.pty}:{},...s.gracefulStop===!0?{gracefulStop:!0}:{}});if(Buffer.byteLength(l)>48*1024*1024)throw new f("FRAME_LIMIT",c,"not-applied");let m=`${r.host}\0${r.configFile??""}`,p=Le.get(m),y=[...p===void 0?[]:[p],...ue(o).filter(u=>u!==p)],C=performance.now()+h,_=!0,w=0;for(let u=0;u<y.length;){let v=y[u]??"",T=_?await Te(r,Math.max(1,C-performance.now()),s.signal):I;s.signal?.aborted&&(T.release(),s.signal.throwIfAborted());let M=$t("ssh",fe(r,le(v),T.options),{stdio:"overlapped"});M.once("close",()=>T.release()),M.once("error",()=>T.release());let P=new ne(M,c,s.pty!==void 0,v,s.signal,T.masterDiagnostics),O=setTimeout(()=>P.cancel("TIMEOUT"),Math.max(1,C-performance.now()));try{let L=P.sendInitial(d,l);return L.catch(()=>{}),await P.ready,await L,Le.set(m,v),P}catch(L){if(T.options.length>0&&P.transportLost&&!s.signal?.aborted){_=!1;continue}if(P.reconnectable&&w<Ie.length){let ie=Ie[w++]??0;if(C-performance.now()>ie){if(!await jt(ie,!0,{signal:s.signal}).catch(()=>!1))throw new f("CANCELLED",c,"not-applied");continue}}if(!P.interpreterMissing||u===y.length-1)throw L;u++}finally{clearTimeout(O)}}throw new f("DEPENDENCY_UNAVAILABLE",c,"not-applied")}i(N,"startSshProcess");var Ie=[1e3,2e3];function Ne(r,e){if(![r,e].every(t=>Number.isSafeInteger(t)&&t>0&&t<=1e3))throw new TypeError("PTY dimensions must be integers between 1 and 1000")}i(Ne,"validateDimensions");var ne=class{constructor(e,t,n,s,o,c=()=>""){this.child=e;this.source=t;this.pty=n;this.interpreter=s;this.masterDiagnostics=c;this.ready=new Promise((d,l)=>{this.#o=d,this.#d=l}),this.completion=new Promise((d,l)=>{this.#h=d,this.#i=l}),this.ready.catch(()=>{}),this.completion.catch(()=>{}),e.stdout.on("data",d=>{this.#f=performance.now(),this.#t=Buffer.concat([this.#t,d]),this.parse()}),e.stderr.on("data",d=>{let l=d.toString();this.#l.length<16384&&(this.#l+=l),this.#p=(this.#p+l).slice(-4096)}),e.stdin.on("error",()=>{}),e.once("error",()=>{this.#s="DEPENDENCY_UNAVAILABLE"});let h=i(()=>{if(this.#r)return;this.#s??="CANCELLED";let d=this.stop();ae(d)},"abort");o?.addEventListener("abort",h,{once:!0}),e.once("close",d=>{this.#r=!0,this.#_=d,clearTimeout(this.#L),o?.removeEventListener("abort",h);let l=d!==0?me(d,this.#l,this.interpreter):void 0,m=this.#s??(l==="DEPENDENCY_UNAVAILABLE"&&this.#a?"TRANSPORT_FAILED":l??(this.#c===void 0?"TRANSPORT_FAILED":void 0));this.#g=l,m==="TRANSPORT_FAILED"&&(this.#u=this.connectionLoss(d)),this.stdout.end(),this.stderr.end();let p=this.error(m??"INPUT_CLOSED");for(let y of this.#e.values())y.reject(p);this.#e.clear();for(let y of this.#k.splice(0))y();if(m){let y=this.error(m);this.#d(y),this.#i(y)}else this.#c!==void 0&&this.#h({exitCode:this.#c})});for(let d of[this.stdout,this.stderr]){let l=i(()=>{this.#n.delete(d),this.parse(),this.#n.size===0&&e.stdout.resume()},"resume");d.on("drain",l),d.on("close",l)}o?.aborted&&h()}static{i(this,"ProcessChannel")}stdout=new Ce({highWaterMark:65536});stderr=new Ce({highWaterMark:65536});completion;ready;#e=new Map;#n=new Set;#o;#d;#h;#i;#t=Buffer.alloc(0);#l="";#p="";#I=performance.now();#f;#E=!1;#u;#s;#T;#P=!1;#a=!1;#g;#y=!1;#x=0;#v;#r=!1;#C=!1;#m=!1;#c;#_;#A=0;#w=0;#O=Promise.resolve();#S=Promise.resolve();#b=0;#k=[];#L;get pid(){return this.#x}get identity(){return this.#v}get transportLost(){return this.#r&&!this.#a&&this.#s===void 0&&this.#g==="TRANSPORT_FAILED"}get reconnectable(){return this.#r&&this.#u?.phase==="connecting"&&we(this.#u.reason)}get interpreterMissing(){return this.#r&&!this.#a&&this.#g==="DEPENDENCY_UNAVAILABLE"}async sendInitial(e,t){this.#P=!0,await this.sendBytes(e),await this.sendLine(t)}async write(e){if(this.#r||this.#C||this.#m)throw this.error("INPUT_CLOSED");if(this.#w+e.length>Wt)throw this.error("INPUT_LIMIT");let t=Buffer.from(e);this.#w+=t.length;let n=this.#O.then(async()=>{let o=[];for(let c=0;c<t.length;c+=te){if(await this.openInputWindow(),this.#m||this.#r){let d=Promise.reject(this.error("INPUT_CLOSED"));d.catch(()=>{}),o.push(d);break}this.#b++;let h=this.sendAcknowledged({kind:"input",bytes:t.subarray(c,c+te).toString("base64")}).finally(()=>{this.#b--,this.#k.shift()?.()});h.catch(()=>{}),o.push(h)}return o});this.#O=n.then(()=>{});let s=n.then(o=>Promise.allSettled(o));this.#S=Promise.all([this.#S,s]).then(()=>{});try{await Promise.all(await n)}finally{await s,this.#w-=t.length}}async end(){if(this.pty)throw new f("PTY_INPUT_NOT_CLOSABLE",this.source,"not-applied");this.#C=!0,await this.#S,await this.send({kind:"end"})}async resize(e,t){if(!this.pty)throw new f("PTY_REQUIRED",this.source,"not-applied");Ne(e,t),await this.sendAcknowledged({kind:"resize",cols:e,rows:t})}stop(){return!this.#r&&!this.#m&&(this.#m=!0,this.send({kind:"stop"}).catch(()=>{}),this.#L=setTimeout(()=>{this.#s===void 0&&(this.#s="TRANSPORT_FAILED",this.#E=!0),this.child.kill("SIGKILL")},5e3),this.child.stdout.resume(),this.stdout.resume(),this.stderr.resume()),this.completion.catch(e=>{if(this.#s==="CANCELLED"&&this.#_===0&&this.#c!==void 0)return{exitCode:this.#c};throw e})}cancel(e){this.#r||(this.#s??=e,this.stop().catch(()=>{}))}error(e){let t=["HOST_KEY_FAILED","AUTH_FAILED","DEPENDENCY_UNAVAILABLE","TARGET_OS_MISMATCH"].includes(e),n=this.#T??(!this.#P||!this.#a||t?"not-applied":"unknown");return new f(e,this.source,n,e==="TRANSPORT_FAILED"&&this.#u?{connection:this.#u}:void 0)}connected(){return this.#f!==void 0||K(this.#l)||K(this.#p)}connectionLoss(e){let t=performance.now(),n=this.#E?"stop-unconfirmed":G(e,this.#p);return n==="unexplained"&&(n=ye(this.masterDiagnostics())),{reason:n,phase:this.#y?"running":this.connected()?"starting":"connecting",afterMs:Math.round(t-this.#I),...this.#f===void 0?{}:{silentMs:Math.round(t-this.#f)}}}async openInputWindow(){for(;this.#b>=Ae&&!this.#r;)await new Promise(e=>this.#k.push(e))}async sendAcknowledged(e){let t=++this.#A,n=new Promise((s,o)=>{this.#e.set(t,{resolve:s,reject:o})});n.catch(()=>{});try{await this.send({...e,id:t}),await n}finally{this.#e.delete(t)}}async send(e){await this.sendLine(JSON.stringify(e))}sendLine(e){return this.sendBytes(Buffer.from(`${e}
|
|
6
|
+
`,"utf8"))}sendBytes(e){return this.#r?Promise.reject(this.error("INPUT_CLOSED")):new Promise((t,n)=>{this.child.stdin.write(e,s=>{s?n(this.error("INPUT_CLOSED")):t()})})}handshake(){let e=this.#t.indexOf(Oe),t=e<0?-1:this.#t.indexOf(10,e);if(t<0)return this.#t.length>65536&&this.cancel("INVALID_RESPONSE"),!1;let n;try{n=JSON.parse(this.#t.subarray(e+Oe.length,t).toString("utf8"))}catch{return this.cancel("INVALID_RESPONSE"),!1}return this.#t=this.#t.subarray(t+1),_e.Check(Ft,n)?n.accepted?(this.#a=!0,!0):(this.cancel("TARGET_OS_MISMATCH"),!1):(this.cancel("INVALID_RESPONSE"),!1)}parse(){if(!(!this.#a&&!this.handshake())){for(;this.#n.size===0;){let e=this.#t.indexOf(10);if(e<0){this.#t.length>65536&&this.cancel("FRAME_LIMIT");return}if(e>65536){this.cancel("FRAME_LIMIT");return}let t=this.#t.subarray(0,e);this.#t=this.#t.subarray(e+1);let n;try{n=JSON.parse(t.toString("utf8"))}catch{this.cancel("INVALID_RESPONSE");return}if(!_e.Check(Ut,n)){this.cancel("INVALID_RESPONSE");return}this.receive(n)}this.child.stdout.pause()}}receive(e){if(e.kind==="ready"){if(this.#y){this.cancel("INVALID_RESPONSE");return}this.#y=!0,this.#x=e.pid,this.#v=e.identity,this.#o()}else if(e.kind==="ack"){let t=this.#e.get(e.id);if(!t){this.cancel("INVALID_RESPONSE");return}this.#e.delete(e.id),t.resolve()}else if(e.kind==="exit")this.#c=e.exitCode;else if(e.kind==="error")this.#s=e.code,this.#T=e.effect;else{let t=Buffer.from(e.bytes,"base64");if(t.toString("base64")!==e.bytes){this.cancel("INVALID_RESPONSE");return}let n=e.kind==="stdout"?this.stdout:this.stderr;!n.destroyed&&!n.write(t)&&this.#n.add(n)}}};async function re(r,e,t,n,s){if(!Number.isFinite(s.timeoutMs)||s.timeoutMs<=0||!Number.isSafeInteger(s.maxBytes)||s.maxBytes<=0)throw new TypeError("Owned command deadlines and byte limits must be positive");s.signal?.throwIfAborted();let o=new AbortController,c=s.signal?AbortSignal.any([s.signal,o.signal]):o.signal,h=setTimeout(()=>o.abort(new f("TIMEOUT",n,s.effect)),s.timeoutMs),d,l,m;try{d=await N(r,e,t,r.workspace,{signal:c,timeoutMs:s.timeoutMs});let p=[],y=[],C=0,_=i((u,v)=>{C+=u.length,C>s.maxBytes?o.abort(new f(s.limitCode??"BYTE_LIMIT",n,s.effect)):v.push(u)},"consume");if(d.stdout.on("data",u=>_(u,p)),d.stderr.on("data",u=>_(u,y)),s.input!==void 0)for(let u=0;u<s.input.length;u+=65536)await d.write(s.input.subarray(u,u+65536));if(s.closeInput||s.input!==void 0)try{await d.end()}catch(u){if(!(u instanceof f)||u.code!=="INPUT_CLOSED")throw u}let{exitCode:w}=await d.completion;m={stdout:Buffer.concat(p),stderr:Buffer.concat(y),exitCode:w}}catch(p){let y=o.signal.aborted?o.signal.reason:p;l=y instanceof f&&(y.source!==n||y.effect==="unknown"&&s.effect==="not-applied")?new f(y.code,n,y.effect==="not-applied"?"not-applied":s.effect,{cause:y}):y}finally{clearTimeout(h)}try{await d?.stop()}catch(p){throw m===void 0?new AggregateError([l,p],"Target command and cleanup failed",{cause:p}):p}if(m===void 0)throw l;return m}i(re,"runOwnedSshCommand");import{Type as k}from"typebox";import{Value as V}from"typebox/value";var Ht=1024*1024,qt=64*1024,Me="^[a-f0-9]{64}$",zt=k.Object({size:k.Integer({minimum:0}),revision:k.String({pattern:Me}),offset:k.Integer({minimum:0}),length:k.Integer({minimum:0})}),Re=k.Object({ok:k.Literal(!1),code:k.String({pattern:"^[A-Z][A-Z0-9_]*$"})}),Vt=k.Object({ok:k.Literal(!0),data:k.Object({sha256:k.String({pattern:Me})})}),se=class{static{i(this,"ByteReader")}#e;#n=[];#o=0;constructor(e){this.#e=e[Symbol.asyncIterator]()}async exactly(e){for(;this.#o<e;)if(!await this.#d())return;let t=this.#h();return this.#i(t.subarray(e)),t.subarray(0,e)}async line(){for(;;){let e=this.#h(),t=e.indexOf(10);if(t>=0)return this.#i(e.subarray(t+1)),e.subarray(0,t).toString("utf8");if(this.#i(e),e.length>qt||!await this.#d())return}}async#d(){let e=await this.#e.next();return e.done===!0?!1:(this.#n.push(e.value),this.#o+=e.value.length,!0)}#h(){let[e]=this.#n,t=this.#n.length===1&&e!==void 0?e:Buffer.concat(this.#n);return this.#n=[],this.#o=0,t}#i(e){e.length!==0&&(this.#n.push(e),this.#o+=e.length)}};function Be(r){if(r!==void 0)try{return JSON.parse(r)}catch{return}}i(Be,"parsed");async function oe(r,e,t,n,s={}){let o=S(r.id,e,b(r)).source,c=await A(b(r),"file"),h=await N(r,H(c),[],U(r),s);h.completion.catch(()=>{}),h.stderr.resume();let d={stalled:!1},l=i(w=>{clearTimeout(d.timer),!(!w||t.idleMs===void 0)&&(d.timer=setTimeout(()=>{d.stalled=!0,h.stdout.destroy()},t.idleMs))},"watch"),m=i(()=>new f("TIMEOUT",o,"not-applied"),"timedOut"),p=i(async()=>{if(d.stalled)throw m();let w;h.stdout.destroy();try{await h.stop()}catch(u){w=u}throw w instanceof f?new f(w.code,o,"not-applied",{cause:w}):new f("INVALID_RESPONSE",o,"not-applied")},"broken"),{revision:y,offset:C,limit:_}=t;try{l(!0),await h.write(Buffer.from(JSON.stringify({operation:"stream",path:e,revision:y,offset:C,limit:_}))),await h.end();let w=new se(h.stdout),u=Be(await w.line());if(V.Check(Re,u))throw new f(u.code,o,"not-applied");if(!V.Check(zt,u)||u.offset+u.length>u.size)return await p();if(y!==void 0&&u.revision!==y)throw new f("CONFLICT",o,"not-applied");let v=0;for(;;){let P=await w.exactly(4);if(P===void 0)return await p();let O=P.readUInt32BE(0);if(O===0)break;if(O>Ht||v+O>u.length)return await p();let L=await w.exactly(O);if(L===void 0)return await p();v+=O,l(!1),await n(L),l(!0)}let T=Be(await w.line());if(V.Check(Re,T))throw new f(T.code,o,"not-applied");if(!V.Check(Vt,T)||v!==u.length)return await p();let{exitCode:M}=await h.completion;if(M!==0)throw new f("REMOTE_OPERATION_FAILED",o,"not-applied");return{size:u.size,revision:u.revision,offset:u.offset,length:u.length,sha256:T.data.sha256}}catch(w){throw d.stalled?m():w}finally{l(!1),h.stdout.destroy(),await h.stop().catch(()=>{})}}i(oe,"readSshFileStream");var f=class extends ce{static{i(this,"SshBackendError")}connection;constructor(e,t,n,s){super(e,t,n,s?.cause?{cause:s.cause}:void 0),this.name=e==="CANCELLED"?"AbortError":"SshBackendError",s?.connection&&(this.connection=s.connection,this.message=`${this.message}: ${Se(s.connection)}`)}},Jt=a.Object({bytes:a.String(),version:a.String({pattern:"^[a-f0-9]{64}$"})}),Zt=a.Object({directory:a.String(),path:a.String(),revision:a.String({pattern:"^[a-f0-9]{64}$"}),sourceRevision:a.String({pattern:"^[a-f0-9]{64}$"}),sha256:a.String({pattern:"^[a-f0-9]{64}$"})}),Kt=a.Array(a.Object({name:a.String(),kind:a.Union([a.Literal("file"),a.Literal("directory"),a.Literal("symlink"),a.Literal("other")])})),Gt=a.Object({kind:a.Union([a.Literal("file"),a.Literal("directory"),a.Literal("other")]),size:a.Integer({minimum:0}),mode:a.Integer({minimum:0})}),Y=a.Object({kind:a.Union([a.Literal("file"),a.Literal("directory"),a.Literal("symlink"),a.Literal("other")]),size:a.Integer({minimum:0}),mode:a.Integer({minimum:0}),links:a.Integer({minimum:0}),identity:a.Object({device:a.String({pattern:"^[0-9]+$"}),inode:a.String({pattern:"^[0-9]+$"})}),revision:a.String({pattern:"^[a-f0-9]{64}$"})}),Xt=a.Object({path:a.String({minLength:1}),entries:a.Array(a.Object({relativePath:a.String(),kind:Y.properties.kind,revision:Y.properties.revision,identity:Y.properties.identity,mode:a.Integer({minimum:0}),link:a.Optional(a.String())}))}),Qt=a.Union([a.Object({ok:a.Literal(!0),data:a.Unknown()}),a.Object({ok:a.Literal(!1),code:a.String({pattern:"^[A-Z][A-Z0-9_]*$"}),effect:a.Union([a.Literal("not-applied"),a.Literal("applied"),a.Literal("unknown")])})]),R=class{static{i(this,"SshBackend")}target;constructor(e){W(e);let t=S(e.id,e.workspace,b(e)).path;this.target={...e,workspace:t}}async stat(e,t={}){let n=await this.request({operation:"stat",path:e},!1,t);return this.checked(Gt,n,e,!1),n}async lstat(e,t={}){let n=await this.request({operation:"lstat",path:e},!1,t);return this.checked(Y,n,e,!1),n}async temporaryEnvironment(e={}){let t=await this.request({operation:"temporary-environment",path:this.target.workspace},!1,e);return this.checked(a.Object({home:a.String({minLength:1,pattern:"^/"}),temporary:a.String({minLength:1,pattern:"^/"}),agentDirectory:a.Optional(a.String({minLength:1,pattern:"^/"}))}),t,this.target.workspace,!1),t}async objectSnapshot(e,t={}){let n=await this.request({operation:"object-snapshot",path:e},!1,t);return this.checked(Xt,n,e,!1),n}async ensureObjectDirectory(e,t,n,s={}){let o=await this.request({operation:"mkdir-object",path:e,mode:t,revision:n},!0,s);return this.checked(a.Object({device:a.String(),inode:a.String()}),o,e,!0),o}async createObjectLink(e,t,n={}){let s=await this.request({operation:"symlink-object",path:e,link:t,revision:null},!0,n);this.checked(a.Null(),s,e,!0)}async setObjectMode(e,t,n,s={}){let o=await this.request({operation:"chmod-object",path:e,mode:t,revision:n},!0,s);this.checked(a.Null(),o,e,!0)}async moveObject(e,t,n={}){let s=await this.request({operation:"move-object",path:e.path,destination:t.path,sourceSnapshot:e,targetSnapshot:t},!0,n);return this.checked(a.Boolean(),s,e.path,!0),s}async captureJournal(e,t={}){let n=await this.request({operation:"journal",path:e},!1,t);return this.checked(Zt,n,e,!1),n}async releaseJournal(e,t={}){let n=await this.request({operation:"journal-release",path:e},!1,t);this.checked(a.Null(),n,e,!1)}async read(e,t={}){let n=await this.request({operation:"read",path:e},!1,t);return this.checked(Jt,n,e,!1),{bytes:Buffer.from(n.bytes,"base64"),version:n.version}}async readRange(e,t,n,s={}){if(!Number.isSafeInteger(t)||n!==void 0&&!(Number.isSafeInteger(n)&&n>=0))throw new TypeError("Byte offset and limit must be safe integers; limit must be nonnegative");let o=[],c=await oe(this.target,e,{offset:t,limit:n,idleMs:s.timeoutMs??3e4},async h=>{o.push(h)},s);return{bytes:Buffer.concat(o,c.length),offset:c.offset,totalBytes:c.size,revision:c.revision}}async readStream(e,t,n,s={}){let o=await oe(this.target,e,{revision:t},n,s);return{totalBytes:o.length,sha256:o.sha256}}async list(e,t={}){let n=await this.request({operation:"list",path:e},!1,t);return this.checked(Kt,n,e,!1),n}async write(e,t,n,s={}){let o=await this.request({operation:"write",path:e,bytes:Buffer.from(t).toString("base64"),expected:n},!0,s);return this.checked(a.String({pattern:"^[a-f0-9]{64}$"}),o,e,!0),o}async copy(e,t,n,s,o={}){return this.copyEntry("copy",e,t,n,s,o)}async restoreJournal(e,t,n,s,o={}){return this.copyEntry("restore",e,t,n,s,o)}async copyEntry(e,t,n,s,o,c){let h=await this.request({operation:e,path:t,destination:n,sourceRevision:s,targetRevision:o},!0,c);this.checked(a.Null(),h,t,!0)}async move(e,t,n,s,o={}){let c=await this.request({operation:"move",path:e,destination:t,sourceRevision:n,targetRevision:s},!0,o);this.checked(a.Null(),c,e,!0)}async realpath(e,t={}){let n=await this.request({operation:"realpath",path:e},!1,t);if(this.checked(a.String({minLength:1}),n,e,!1),!n.startsWith("/"))throw new f("INVALID_RESPONSE",e,"not-applied");return n}async queryGit(e,t,n={}){let s=await this.request({operation:"git-query",path:e,args:t},!1,{...n,timeoutMs:5e3});return this.checked(a.String(),s,e,!1),s}async removeObject(e,t,n={}){let s=await this.request({operation:"delete-object",path:e,revision:t},!0,n);this.checked(a.Null(),s,e,!0)}async removeEntry(e,t,n={}){let s=await this.request({operation:"unlink",path:e,revision:t},!0,n);this.checked(a.Null(),s,e,!0)}async remove(e,t,n={}){let s=await this.request({operation:"remove",path:e,expected:t},!0,n);this.checked(a.Null(),s,e,!0)}async writeGitIndex(e,t,n={}){let s=Buffer.from(t.text,"utf8");if(s.length>32*1024*1024)throw new f("CONTENT_LIMIT",S(this.target.id,e).source,"not-applied");let{text:o,expectedIndexText:c,expectedWorktreeText:h,...d}=t,l=i(p=>Yt("sha256").update(p,"utf8").digest("hex"),"digest"),m=await this.request({operation:"gitIndex",path:e,...d,bytes:s.toString("base64"),expectedIndexHash:l(c),...h!==void 0&&{expectedWorktreeHash:l(h)}},!0,n);this.checked(a.Null(),m,e,!0)}async execute(e,t,n,s={}){return re({...this.target,workspace:n},e,t,S(this.target.id,n).source,{signal:s.signal,timeoutMs:s.timeoutMs??3e4,maxBytes:32*1024*1024,limitCode:"CONTENT_LIMIT",closeInput:!0,effect:"unknown"})}async startProcess(e,t,n,s={}){return N(this.target,e,t,n,s)}checked(e,t,n,s){if(!De.Check(e,t))throw new f("INVALID_RESPONSE",S(this.target.id,n).source,s?"unknown":"not-applied")}async request(e,t,n){let s=typeof e.path=="string"?e.path:typeof e.cwd=="string"?e.cwd:this.target.workspace,o=S(this.target.id,s).source,c=n.timeoutMs??3e4;if(!Number.isFinite(c)||c<=0)throw new TypeError("SSH operation deadline must be positive");n.signal?.throwIfAborted();let h=await A(b(this.target),"file"),d=U(this.target),l=await re({...this.target,workspace:e.operation==="gitIndex"?s:d},H(h),[],o,{signal:n.signal,timeoutMs:c,maxBytes:48*1024*1024,limitCode:"CONTENT_LIMIT",effect:t?"unknown":"not-applied",input:Buffer.from(JSON.stringify(e))});if(l.exitCode!==0)throw new f("REMOTE_OPERATION_FAILED",o,t?"unknown":"not-applied");let m;try{m=JSON.parse(l.stdout.toString("utf8"))}catch{throw new f("INVALID_RESPONSE",o,t?"unknown":"not-applied")}if(!en(m))throw new f("INVALID_RESPONSE",o,t?"unknown":"not-applied");if(!m.ok)throw new f(m.code,o,m.effect);return m.data}};function en(r){return De.Check(Qt,r)}i(en,"isReply");import{readFile as tn}from"node:fs/promises";import B from"node:path";import{Type as E}from"typebox";import{Value as nn}from"typebox/value";var rn=E.Object({targets:E.Array(E.Object({id:E.String(),host:E.String(),workspace:E.String(),configFile:E.Optional(E.String({minLength:1})),os:E.Optional(E.Union([E.Literal("linux"),E.Literal("windows")]))},{additionalProperties:!1}))},{additionalProperties:!1});function wr(r){return{globalPath:B.join(B.dirname(r.globalPath),"ssh.json"),projectPath:B.join(B.dirname(r.projectPath),"ssh.json")}}i(wr,"resolveSshConfigPaths");async function Sr(r){let e=await $e(r.globalPath),t=await $e(r.projectPath),n=new Map(e.map(s=>[s.id,s]));for(let s of t)n.set(s.id,s);return[...n.values()]}i(Sr,"readSshTargets");async function $e(r){let e;try{e=await tn(r,"utf8")}catch(t){if(typeof t=="object"&&t!==null&&"code"in t&&t.code==="ENOENT")return[];throw new Error(`Cannot read SSH settings at ${r}`,{cause:t})}try{let t=JSON.parse(e);if(!nn.Check(rn,t))throw new Error("Invalid settings");return sn(t,r)}catch{throw new Error(`Invalid SSH settings at ${r}`)}}i($e,"readScope");function sn(r,e){let t=new Set;return r.targets.map(n=>{if(t.has(n.id))throw new Error("Duplicate target");t.add(n.id);let s={id:n.id,host:n.host,workspace:n.workspace,...n.os===void 0?{}:{os:n.os},...n.configFile===void 0?{}:{configFile:B.resolve(B.dirname(e),n.configFile)}};return new R(s).target})}i(sn,"validateScope");var je=class{static{i(this,"SshBackendRegistry")}#e=new Map;constructor(e){for(let t of e){if(this.#e.has(t.id))throw new TypeError(`Duplicate SSH target: ${t.id}`);this.#e.set(t.id,new R(t))}}hasTargetOs(e){return[...this.#e.values()].some(t=>b(t.target)===e)}resolve(e,t){let n=J(e,t,o=>this.#e.get(o)?.target.os);if(!n)return;let s=this.#e.get(n.target);if(!s)throw new f("UNKNOWN_TARGET",n.source,"not-applied");return{location:n,backend:s}}};export{cn as a,S as b,de as c,b as d,U as e,H as f,gn as g,N as h,re as i,f as j,wr as k,Sr as l,je as m};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as s}from"./chunk-EI7MMDWY.js";import{execFile as f}from"node:child_process";import{existsSync as l}from"node:fs";import c from"node:os";import d from"node:path";function y(n=process.env.PI_CODING_AGENT_DIR??d.join(c.homedir(),".pi","agent"),e=process.platform){let t=d.join(n,"bin",e==="win32"?"rg.exe":"rg");return l(t)?t:"rg"}s(y,"resolveRipgrepExecutable");async function w(n,e,t){let r=["check-ignore","-q","."],i;try{e===void 0?i=await g("git",r,n,t):e.execute!==void 0&&(i=(await e.execute("git",r,n,t)).code)}catch{}return t?.throwIfAborted(),i===1?[]:["--no-ignore-parent"]}s(w,"parentIgnoreArguments");function g(n,e,t,r){return new Promise((i,h)=>{f(n,e,{cwd:t,windowsHide:!0,timeout:1e4,...r===void 0?{}:{signal:r}},o=>{o===null?i(0):typeof o.code=="number"?i(o.code):h(o)})})}s(g,"localExitCode");var a=64*1024,m=/^rg: (.+?): (.+\(os error \d+\))$/u,u=class{static{s(this,"RipgrepStderr")}#e="";#t="";#n="";#i=!1;#s=0;#r;#o;constructor(e=t=>t){this.#o=e}write(e){this.#t.length<a&&(this.#t+=e.slice(0,a-this.#t.length));let t=(this.#e+e).split(/\r?\n/u);this.#e=t.pop()??"";for(let r of t)this.#d(r)}get message(){return this.#a(),this.#n.trim()||this.#t.trim()}unreadable(e){if(this.#a(),!(e!==2||this.#r===void 0||this.#i))return{count:this.#s,first:this.#r}}failed(e){return e!==0&&e!==1&&this.unreadable(e)===void 0}#a(){this.#d(this.#e),this.#e=""}#d(e){if(e.length===0)return;let t=m.exec(e);if(t===null){this.#i||=/PCRE2: error matching/iu.test(e),this.#n.length<a&&(this.#n+=`${e}
|
|
2
|
+
`);return}this.#s+=1,this.#r??={path:this.#o(t[1]??""),error:t[2]??""}}};function E(n,e){return n===void 0||e===void 0?n??e:{count:n.count+e.count,first:n.first}}s(E,"mergeUnreadablePaths");export{y as a,w as b,u as c,E as d};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{A as E,B as h,D as P,H as C,M as A,ka as k,v as w}from"./chunk-OEEE5BLN.js";import{C as B,m as D,o as I}from"./chunk-IRLWXPL4.js";import{a as l}from"./chunk-EI7MMDWY.js";import{Type as s}from"typebox";import{Value as S}from"typebox/value";import{Type as R}from"typebox";var F="File or resource address, or an unchanged result or its id.",U=`${F} An array reads each source separately, in order.`,_=R.Object({path:R.Optional(R.Union(k.anyOf,{description:F})),offset:R.Optional(R.Number({description:"For raw: sources, use a zero-based byte offset; negative offsets count from the file end. For other sources: first line to return, numbered from 1. Omit or use 0 to start at line 1; -1 starts at the last line, -10 at the tenth line from the end. For path#anchor, SEARCH or RESULT# selections, count from its containing line instead: 0 or 1 starts there, 2 starts one line later, -1 one line earlier. For image and sequence views, offset is a zero-based row-major grid cell index and requires limit."})),limit:R.Optional(R.Number({description:"For raw: sources, use a non-negative byte count (0 reads no bytes). Otherwise, maximum lines from the selected starting position. Output is bounded; omit for the default read. For image and sequence views, limit is the square grid cell size in pixels; omit offset to select cell 0, or omit both for the bounded full image."})),views:R.Optional(R.Array(R.String(),{description:`Optional source-specific presentations. Combine views when both presentations are needed, for example ["anchors", "ast"]. Omit for the source's default presentation.`}))});function v(e){let{path:t,...o}=e;return t===void 0?o:{...o,path:typeof t=="string"?t:t.id}}l(v,"readRequestOf");var b=R.Object({..._.properties,path:R.Optional(R.Union([...k.anyOf,R.Array(k,{minItems:1})],{description:U}))});function Ee(e){let{path:t,...o}=e;return Array.isArray(t)?t.map(n=>v({...o,path:n})):[v(t===void 0?o:{...o,path:t})]}l(Ee,"readRequestsOf");var Q={path:U,offset:"First line, from 1; negative counts from the end. For raw:, a byte offset.",limit:"Maximum lines. For raw:, bytes.",views:"Extra presentations; combine them unless a view says otherwise."};function Ce(e){let t=l((o,n)=>({...o,description:[Q[n],n==="path"?void 0:e[n]].filter(a=>a!==void 0).join(`
|
|
2
|
+
`)}),"describe");return{...b,properties:{path:t(b.properties.path,"path"),offset:t(b.properties.offset,"offset"),limit:t(b.properties.limit,"limit"),views:t(b.properties.views,"views")}}}l(Ce,"describeReadParameters");import{readFile as Y}from"node:fs/promises";function X(e,t,o=(a,i)=>["filesystem","ssh"].includes(i),n){return async a=>{let i=a.state;if(i?.contentKind!=="text"||!o(i.source,i.resolvedBy)||a.sourceText!==i.text.content)return{kind:"continue",context:a};if(i.resolvedBy==="filesystem")try{if(await Y(i.source,{encoding:"utf8",signal:a.resolverContext.signal})!==i.text.content)return{kind:"continue",context:a}}catch{return a.resolverContext.signal?.throwIfAborted(),{kind:"continue",context:a}}let d=a.sourceTarget===void 0?void 0:e.resolve(a.sourceTarget,a.resolverContext.cwd),c=d?.targets.filter(u=>u.source===i.source);return c?.some(u=>u.expectedContent!==i.text.content)?{kind:"continue",context:a}:{kind:"continue",context:a,transform(u){let y=u.script;if(u.isError||y?.kind!=="text"||y.source!==i.source||!y.lines.every(x=>{let O=i.text.lines[x.lineNumber-1];return O?.content===x.content&&O.lineEnding===x.lineEnding}))return u;let m=y.lines[0],f=y.lines.at(-1),p=m===void 0||f===void 0?i.text.content.length===0?{start:{lineNumber:1,column:0},end:{lineNumber:1,column:0}}:void 0:{start:{lineNumber:m.lineNumber,column:0},end:f.lineEnding.length>0?{lineNumber:f.lineNumber+1,column:0}:{lineNumber:f.lineNumber,column:f.content.length},linewise:!0},L=e.register(p===void 0?[]:[{source:i.source,expectedContent:i.text.content,ranges:c===void 0?[p]:c.flatMap(x=>x.ranges.flatMap(O=>ee(O,p))),readCurrent:Z(t,i.source,a.resolverContext.cwd)}],a.resolverContext.cwd,d?.complete??!0,void 0,n);return{...u,script:{...y,target:L,...(i.resolvedBy==="filesystem"||i.resolvedBy==="ssh")&&i.entries===void 0&&{fileDigest:w(i.text.content)}}}}}}}l(X,"createReadResultTargetHandler");function Z(e,t,o){return async n=>{let a=await e({path:t},{cwd:o,...n===void 0?{}:{signal:n}},"script");if(a.isError||a.script?.kind!=="text"||a.script.source!==t)throw new Error("Could not verify the owning source; repeat Read/Search.");return a.script.content}}l(Z,"ownedReader");function ee(e,t){let o=l((i,d)=>i.lineNumber-d.lineNumber||i.column-d.column,"compare"),n=o(e.start,t.start)>=0?e.start:t.start,a=o(e.end,t.end)<=0?e.end:t.end;return o(n,a)>0||o(n,a)===0&&o(e.start,e.end)!==0?[]:[{start:n,end:a}]}l(ee,"intersectRange");import{Type as r}from"typebox";function Ie(e,t,o,n){if(!se(e))return{content:e,source:t,resolvedBy:o,preserveTruncatedOutput:n.preserveTruncatedOutput,textMode:n.textMode,contentKind:"other"};let a=e[0].text;return{content:e,source:t,resolvedBy:o,...n.entries===void 0?{}:{entries:[...n.entries]},preserveTruncatedOutput:n.preserveTruncatedOutput,textMode:n.textMode,contentKind:"text",text:D(t,a)}}l(Ie,"createReadState");function Be(e,t,o){if(e.contentKind!=="text"){if(t.offset!==void 0||t.limit!==void 0)return re({code:"UNSUPPORTED_RANGE",source:e.source,resolverId:e.resolvedBy,message:"Line ranges require textual content. Omit offset and limit to read this content without a line range."});let p=oe(e.content);return{script:{kind:"native",source:e.source,blocks:e.content},content:p.content,details:{...j(e),...p.unsupportedContentBlocks!==void 0&&{unsupportedContentBlocks:p.unsupportedContentBlocks}}}}let n=e.text.lines.length,a=ae(t,n,o?.originLine),i=e.text.lines.slice(a.startIndex,a.endIndex),d=a.endIndex<n,c=e.textMode==="final"||i.every(p=>p.presentation===void 0),u=c?te(i,d):I({...e.text,lines:i.map((p,L)=>({...p,lineEnding:L===i.length-1&&d?"":p.lineEnding}))}),y=e.textMode==="normal"&&(e.resolvedBy==="filesystem"||e.resolvedBy==="ssh")&&e.entries===void 0&&!d&&i.at(-1)?.lineEnding==="",m=e.content[0],f=[{type:"text",text:y?`${u}
|
|
3
|
+
${B}`:u,...m.textSignature!==void 0&&{textSignature:m.textSignature}}];return{script:{kind:"text",...e.text.references===void 0?{}:{references:e.text.references},source:e.source,content:c&&!d?u:i.map(p=>p.content+p.lineEnding).join(""),...c?{}:{presented:u},...e.entries===void 0?{}:{entries:e.entries},lines:i,startLine:i[0]?.lineNumber??0,endLine:i.at(-1)?.lineNumber??0,totalLines:n},content:f,details:{...j(e),startLine:i[0]?.lineNumber??0,endLine:i.at(-1)?.lineNumber??0,totalLines:n,lines:i,...y&&{noFinalLineBreak:y}}}}l(Be,"projectReadState");function te(e,t){return e.map((o,n)=>`${o.content}${n===e.length-1&&t?"":o.lineEnding}`).join("")}l(te,"renderFinalTextLines");function M(e){let t=e.cause,o,n=new Set;for(;t instanceof Error&&!n.has(t);)n.add(t),o=t,t=t.cause;return o}l(M,"deepestCause");var q="Supply path with a source or an unchanged result reference.";function H(e){let t=e.retry??(e.code==="FRAGMENT_FAILED"&&e.source!==void 0?{path:e.source,views:["anchors"]}:void 0);return t===void 0?void 0:`Run read(${JSON.stringify(t)}).`}l(H,"readRetry");function V(e){return e.candidates?.length?["Possible matches:",...e.candidates.map(t=>`- ${JSON.stringify(t.path)}`),"","Retry read with an exact candidate path."]:[]}l(V,"candidateLines");function $(e){let t=M(e),o=t!==void 0&&"code"in t?t.code:void 0,n=[];o==="ENOENT"&&!e.candidates?.length&&n.push("Search for the correct path.");let a=H(e);return e.code==="INVALID_REQUEST"?n.push(q):a!==void 0?n.push(a):e.code==="NO_RESOLVER"?n.push("Choose a supported source from the path parameter."):e.code==="NO_FRAGMENT_RESOLVER"&&n.push("Read the source without the anchor."),[...n,...V(e)]}l($,"readFailureRecovery");function ne(e){let t=M(e),o=t!==void 0&&"code"in t?t.code:void 0,n=t?.message||e.message;o==="ENOENT"?n=e.candidates?.length?"Source not found.":"Source not found. Search for the correct path.":o==="EACCES"||o==="EPERM"?n="Access denied.":e.code==="INVALID_RESOLVER_RESULT"?n="The source provider returned an invalid result.":e.code==="INVALID_RESOURCE_CONTENT"?n="The source provider returned invalid content.":e.code==="UNSUPPORTED_CAPABILITY"?n="This source does not support reading.":e.code==="NO_RESOLVER"?n="This source is not supported. Choose a supported source from the path parameter.":e.code==="NO_FRAGMENT_RESOLVER"&&(n="This anchor is not supported. Read the source without the anchor.");let a=H(e);return e.code==="INVALID_REQUEST"?n+=`. ${q}`:a!==void 0&&(n+=`
|
|
4
|
+
${a}`),`Read failed${e.source===void 0?"":` for ${JSON.stringify(e.source)}`}: ${n}`}l(ne,"readFailureMessage");function Fe(e,t,o){if(!o?.aborted||!e.isError)return e;let n=e.details.source??e.details.failure?.source??t;return{...e,content:[{type:"text",text:`Read cancelled${n===void 0?"":` for ${JSON.stringify(n)}`}. No completed result was returned.`}]}}l(Fe,"withReadCancellation");function re(e){let t=e.cause instanceof h?e.cause:void 0;return t!==void 0?e={...e,source:e.source??t.source,message:`${t.code}: ${e.source??t.source}`,cause:new h(t.code,t.source,t.effect,{metadata:E(t)})}:e.cause instanceof Error&&"code"in e.cause&&!["ENOENT","EACCES","EPERM"].includes(String(e.cause.code))&&(e={...e,message:`${e.code}: ${e.source??"source"}`,cause:void 0}),{content:[{type:"text",text:[ne(e),...e.candidates?.length?["",...V(e)]:[]].join(`
|
|
5
|
+
`)}],details:{failure:e},isError:!0}}l(re,"failureResult");function j(e){return{source:e.source,resolvedBy:e.resolvedBy}}l(j,"readDetails");function oe(e){let t=[],o=[];for(let[a,i]of e.entries()){if(i.type!=="custom"){t.push(i);continue}o.push({index:a,kind:i.kind}),t.push({type:"text",text:`[unsupported_content_block kind=${i.kind} index=${a}]`})}let n=o[0];return{content:t,...n!==void 0&&{unsupportedContentBlocks:[n,...o.slice(1)]}}}l(oe,"projectAgentContent");function ae(e,t,o){let n=e.offset===void 0?1:Math.trunc(e.offset),a=ie(n,t,o),i=e.limit===void 0?t:Math.max(0,Math.trunc(e.limit));return{startIndex:Math.min(t,a-1),endIndex:Math.min(t,a-1+i)}}l(ae,"resolveTextRange");function ie(e,t,o){if(o===void 0)return e<0?Math.max(1,t+e+1):Math.max(1,e);let n=e<0?o+e:o+Math.max(1,e)-1;return Math.max(1,n)}l(ie,"anchoredStartLine");function se(e){return e.length===1&&e[0].type==="text"}l(se,"isSingleTextContent");var de=r.Object({value:r.String(),kind:r.String(),state:r.Optional(r.String())},{additionalProperties:!1}),le=r.Object({lineNumber:r.Integer(),content:r.String(),lineEnding:r.String(),anchors:r.Optional(r.Array(r.String()))},{additionalProperties:!1}),ce=r.Object({path:r.String(),offset:r.Integer()},{additionalProperties:!1}),N={source:r.String(),truncated:r.Boolean(),continuation:r.Optional(ce),fullResult:r.Optional(r.String())},G=r.Object({...N,kind:r.Literal("text"),target:r.Optional(r.String()),text:r.Optional(r.String()),entries:r.Optional(r.Array(r.String())),lines:r.Array(le),startLine:r.Integer(),endLine:r.Integer(),totalLines:r.Integer(),references:r.Optional(r.Array(de))},{additionalProperties:!1}),K=r.Object({...N,kind:r.Literal("bytes"),bytes:r.Array(r.Integer({minimum:0,maximum:255})),byteOffset:r.Integer(),byteLength:r.Integer(),totalBytes:r.Integer()},{additionalProperties:!1}),ue=r.Union([r.Object({type:r.Literal("text"),text:r.String()},{additionalProperties:!1}),r.Object({type:r.Literal("image"),mimeType:r.String()},{additionalProperties:!1})]),J=r.Object({...N,kind:r.Literal("native"),blocks:r.Array(ue)},{additionalProperties:!1}),W=r.Union([r.Object({kind:r.Literal("recovery"),source:r.String(),candidates:r.Array(r.Object({path:r.String()},{additionalProperties:!1}))},{additionalProperties:!1}),G,K,J,r.Object({kind:r.Literal("resources"),source:r.Optional(r.String()),resources:r.Array(r.Union([G,K,J])),truncated:r.Boolean(),fullResult:r.Optional(r.String())},{additionalProperties:!1})]),T=r.Union([...W.anyOf,r.Object({kind:r.Literal("list"),items:r.Array(P(W))},{additionalProperties:!1})]),pe=P(T);function Re(e){return{lineNumber:e.lineNumber,content:e.content,lineEnding:e.lineEnding,...e.anchors===void 0?{}:{anchors:[...e.anchors]}}}l(Re,"publicLine");function z(e,t){if(e.kind==="resources"){let d=e.resources.map(c=>z(c,t));return{kind:e.kind,...e.source===void 0?{}:{source:e.source},resources:d,truncated:d.some(c=>typeof c=="object"&&c!==null&&"truncated"in c&&c.truncated===!0)}}if(e.kind==="bytes"){let d=t?[...e.bytes]:e.bytes.slice(0,32768),c=e.truncated===!0||d.length<e.bytes.length;return{kind:e.kind,source:e.source,bytes:d,byteOffset:e.byteOffset,byteLength:d.length,totalBytes:e.totalBytes,truncated:c,...e.byteOffset+d.length<e.totalBytes?{continuation:{path:e.source,offset:e.byteOffset+d.length}}:{}}}if(e.kind==="native")return{kind:e.kind,source:e.source,truncated:!1,blocks:e.blocks.map(d=>{if(d.type==="text")return{type:d.type,text:d.text};if(d.type==="image")return{type:d.type,mimeType:d.mimeType};throw new TypeError("Custom content requires a structured adapter")})};let o=[],n=0;for(let d of e.lines){let c=Re(d);if(!t&&(n+=Buffer.byteLength(JSON.stringify(c)),o.length>=2e3||n>512*1024))break;o.push(c)}if(o.length===0&&e.lines.length>0)throw new RangeError("Selected line exceeds the structured window; use a raw byte range or a source-specific view");let a=o.length<e.lines.length,i=o.at(-1)?.lineNumber??e.startLine-1;return{kind:e.kind,source:e.source,...e.target===void 0?{}:{target:e.target},...t&&{text:e.presented??e.content},...t&&e.entries!==void 0&&{entries:[...e.entries]},lines:o,startLine:o[0]?.lineNumber??0,endLine:o.at(-1)?.lineNumber??0,totalLines:e.totalLines,truncated:a,...e.target===void 0?{}:{target:e.target},...e.references===void 0?{}:{references:e.references},...a||i<e.totalLines?{continuation:{path:e.source,offset:i+1}}:{}}}l(z,"publicData");function ye(e,t={}){let o=t.complete===!0,n=e.details.failure,a=n?.cause instanceof h?n.cause:void 0,i=a===void 0?void 0:E(a);if(e.isError||n!==void 0)return C(e,T,{status:"error",...n?.candidates?.length&&n.source!==void 0?{data:{kind:"recovery",source:n.source,candidates:n.candidates}}:{},errors:[{code:a?.code??n?.code??"READ_FAILED",message:a===void 0?[n?.message??"Read failed",...n===void 0?[]:$(n)].join(`
|
|
6
|
+
`):`${a.code}: ${n?.source??a.source}`,...n?.source===void 0?{}:{source:n.source},...i===void 0?{}:{metadata:i}}]});try{if(e.script===void 0)throw new TypeError("Read handler must return structured script data");let d=z(e.script,o);return C(e,T,{status:"success",data:e.details.temporarySource!==void 0&&typeof d=="object"&&d!==null?{...d,fullResult:e.details.temporarySource}:d,errors:[]},o?{maxBytes:1/0}:{})}catch(d){return C(e,T,{status:"error",errors:[{code:d instanceof RangeError?"STRUCTURED_RESULT_TOO_LARGE":"STRUCTURED_ADAPTER_REQUIRED",message:d instanceof Error?d.message:String(d)}]})}}l(ye,"structuredRead");var g=s.Function([],s.Unknown()),ge=s.Object({resolver:s.Unknown(),matchesCall:s.Optional(g),renderCall:s.Optional(g),priority:s.Optional(s.Number()),renderResult:s.Optional(g),preserveTruncatedOutput:s.Optional(s.Boolean())}),fe=s.Object({resolver:s.Unknown(),priority:s.Optional(s.Number())}),me=s.Object({id:s.String({pattern:"\\S"}),priority:s.Optional(s.Number()),resolve:g}),xe=s.Object({view:s.String({pattern:"\\S"}),contentKind:s.Optional(s.Union([s.Literal("text"),s.Literal("any")])),includes:s.Optional(s.Array(s.String({pattern:"\\S"}))),showsLinesOutsideRange:s.Optional(s.Boolean()),presenter:s.Object({id:s.String(),present:g}),priority:s.Optional(s.Number())}),he=s.Object({resolvedBy:s.String({pattern:"\\S"}),contentKind:s.Union([s.Literal("text"),s.Literal("any")])}),be=s.Union([s.Object({stage:s.Literal("pre-read"),handler:g}),s.Object({stage:s.Literal("read"),when:he,handler:g}),s.Object({stage:s.Literal("post-read"),handler:g})]);function Je(e){if(!S.Check(fe,e))return!1;let t=e,o=t.resolver;return typeof o.id=="string"&&o.id.length>0&&typeof o.tryResolve=="function"&&(!("priority"in t)||typeof t.priority=="number")}l(Je,"isTextTargetResolverRegistration");function We(e){if(!S.Check(ge,e))return!1;let t=e;return A(t.resolver)?t.resolver.id!=="any"&&(!("priority"in t)||typeof t.priority=="number")&&(!("matchesCall"in t)||typeof t.matchesCall=="function")&&(!("renderCall"in t)||typeof t.renderCall=="function")&&"matchesCall"in t=="renderCall"in t&&(!("renderResult"in t)||typeof t.renderResult=="function"):!1}l(We,"isResourceResolverRegistration");function ze(e){return S.Check(be,e)}l(ze,"isReadHandlerRegistration");function Qe(e){return S.Check(xe,e)}l(Qe,"isReadViewRegistration");function Ye(e){return S.Check(me,e)}l(Ye,"isFragmentResolverRegistration");function Xe(e){return Te(e)?e.kind==="not-handled"?!0:e.kind==="failed"?typeof e.message=="string"&&e.message.length>0&&(e.retryPath===void 0||typeof e.retryPath=="string"&&e.retryPath.length>0):e.kind==="resolved"&&typeof e.originLine=="number":!1}l(Xe,"isReadFragmentResolution");function Te(e){return typeof e=="object"&&e!==null}l(Te,"isRecord");export{X as a,ee as b,Ie as c,Be as d,Fe as e,re as f,ae as g,ie as h,_ as i,v as j,Ee as k,Ce as l,T as m,pe as n,ye as o,Je as p,We as q,ze as r,Qe as s,Ye as t,Xe as u};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{a as U}from"./chunk-MMQIHUU5.js";import{a as A}from"./chunk-54EFJYUB.js";import{a as k,b as x}from"./chunk-VPBGKSFI.js";import{b as C}from"./chunk-V2LLMBTA.js";import{b,d as v,f as S,j as m,k as O,l as R,m as T}from"./chunk-S4GTWS2J.js";import{a as h,b as N,c as I,e as F}from"./chunk-SZRC24OB.js";import{c as P}from"./chunk-XHFAV2NI.js";import"./chunk-PBMHSK6J.js";import{c as y,l as u,m as E}from"./chunk-OA26FH5G.js";import"./chunk-BXGMMZT3.js";import"./chunk-2YO6RVX4.js";import"./chunk-MLFJU2US.js";import"./chunk-OEEE5BLN.js";import"./chunk-2QCE7GOV.js";import"./chunk-2EY3LEZ7.js";import"./chunk-ZC65Z3CK.js";import"./chunk-ZAWRSA7N.js";import"./chunk-OFILFO6D.js";import{a as l}from"./chunk-EI7MMDWY.js";import f from"node:path";import{realpath as D}from"node:fs/promises";function _(s){let p=k(s),g=A(s),w=new Map;return{async resolveProject(n,e){if(n.startsWith("ssh://")||e.startsWith("ssh://")){let i=s.resolve(n,e);if(!i)throw new m("UNSUPPORTED_SOURCE",n,"not-applied");let o=s.resolve(e);if(o&&o.location.target!==i.location.target)throw new m("UNSUPPORTED_SOURCE",n,"not-applied");return U(i.backend,i.location.path,o?.location.path,"formatters",h)}if(n.includes("://")||e.includes("://"))throw new m("UNSUPPORTED_SOURCE",n,"not-applied");let t=await y(e,n,"formatters",h);return t===void 0?void 0:{cwd:t,external:t!==f.resolve(e)}},async loadRegistry(n,e){let t=JSON.stringify([n,e]),i=w.get(t);if(!i){let o=s.resolve(n);i=N.fromDirectory(n,{includeGlobal:!e,requireBuiltInEvidence:!0,...o?{layerAccess:p,executableAvailability:l(r=>C(o.backend,o.location.path,r),"executableAvailability"),recipeEvidence:l(r=>x(o.backend,o.location.path,r),"recipeEvidence")}:{}}),w.set(t,i)}return i},async rustfmtAccess(n,e){let t=s.resolve(e);if(!t)return{file:f.join(await D(f.dirname(e)),f.basename(e)),access:I(n,e)};let i=v(t.backend.target),o=await t.backend.execute(S(`import json,os
|
|
2
|
+
home=os.path.expanduser('~')
|
|
3
|
+
config=os.environ.get('APPDATA') if os.name == 'nt' else (os.environ.get('XDG_CONFIG_HOME') or os.path.join(home,'.config'))
|
|
4
|
+
print(json.dumps([home,os.path.join(config,'rustfmt') if config else '']))`),[],f.posix.dirname(t.location.path));if(o.exitCode!==0)throw new m("CONFIG_ENVIRONMENT_FAILED",e,"not-applied");let r=JSON.parse(o.stdout.toString("utf8"));if(!Array.isArray(r)||!r.every(a=>typeof a=="string"))throw new TypeError("Invalid rustfmt configuration environment");return{file:f.posix.join(await t.backend.realpath(f.posix.dirname(t.location.path)),f.posix.basename(t.location.path)),access:{paths:f.posix,userConfigDirectories:r.filter(Boolean).map(a=>b(t.location.target,a,i).path),async readText(a){try{return(await t.backend.read(a)).bytes.toString("utf8")}catch(c){if(c instanceof m&&["ENOENT","ENOTDIR","EISDIR"].includes(c.code))return;throw c}},run:l((a,c)=>u(a,{projectRoot:n,filePath:e,processAccess:g,input:c}),"run")}}},async run(n,e,t,i){let o=s.resolve(t);if(!o){if(t.includes("://")||e.includes("://"))throw new m("UNSUPPORTED_SOURCE",t,"not-applied");return E(n,{projectRoot:e,filePath:t,stdin:i})}let r=await o.backend.read(o.location.path),a=await u(n.run,{projectRoot:e,filePath:t,processAccess:g,input:i?r.bytes.toString("utf8"):void 0}),c=await o.backend.read(o.location.path);if(!a.ok)return{ok:!1,changed:!c.bytes.equals(r.bytes)};if(n.output==="stdout"){if(c.version!==r.version)throw new m("CONFLICT",t,"not-applied");let d=Buffer.from(a.stdout);return d.equals(r.bytes)||await o.backend.write(o.location.path,d,r.version),{ok:!0,changed:!d.equals(r.bytes)}}return{ok:!0,changed:!c.bytes.equals(r.bytes)}}}}l(_,"createOwnedFormatterRuntime");async function j(s){let p=new T(await R(O(P())));await F(s,_(p))}l(j,"registerOwnedFormatter");export{_ as createOwnedFormatterRuntime,j as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as b,c as $,d as z}from"./chunk-PBMHSK6J.js";import{b as P,c as T,g as I,i as A,k as O,l as S,m as h,n as D}from"./chunk-OA26FH5G.js";import{a as v}from"./chunk-2YO6RVX4.js";import{b as R,c as k}from"./chunk-MLFJU2US.js";import{a as F}from"./chunk-ZAWRSA7N.js";import{a as E,b as x}from"./chunk-OFILFO6D.js";import{a as c}from"./chunk-EI7MMDWY.js";var W=[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".json",".jsonc",".css",".scss",".html",".md",".yaml",".yml",".vue",".svelte"],U=[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".json",".jsonc",".css",".scss",".less",".html",".htm",".md",".markdown",".mdx",".yaml",".yml",".toml"],u=[a("dart-format",["dart"],["dart"],["pubspec.yaml","analysis_options.yaml"],[".dart"],["dart","format","{file}"],"https://dart.dev/tools/dart-format"),a("zig-format",["zig"],["zig"],["build.zig","build.zig.zon","zls.json"],[".zig",".zon"],["zig","fmt","{file}"],"https://ziglang.org/documentation/master/"),a("styler",["r"],["Rscript"],[".Rprofile","DESCRIPTION"],[".r"],["Rscript","-e","styler::style_file(commandArgs(TRUE)[1])","{file}"],"https://styler.r-lib.org/"),a("clang-format",["c","cpp"],["clang-format"],[".clang-format","_clang-format"],[".c",".h",".cc",".cpp",".cxx",".hh",".hpp",".hxx"],["clang-format","-i","{file}"],"https://clang.llvm.org/docs/ClangFormat.html"),a("prettier",["javascript","typescript","html","css","json","yaml","markdown","vue","svelte"],["prettier"],[".prettierrc",".prettierrc.json",".prettierrc.json5",".prettierrc.yaml",".prettierrc.yml",".prettierrc.toml",".prettierrc.js",".prettierrc.cjs",".prettierrc.mjs","prettier.config.js","prettier.config.cjs","prettier.config.mjs","prettier.config.ts","prettier.config.mts","prettier.config.cts"],W,["prettier","--write","{file}"],"https://prettier.io/docs/",["prettier"],{"package.json":["prettier"]}),a("biome",["javascript","typescript","json","css"],["biome"],["biome.json","biome.jsonc"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".json",".jsonc",".css"],["biome","format","--write","{file}"],"https://biomejs.dev/",["@biomejs/biome"]),a("oxfmt",["javascript","typescript","json","css","html","markdown","yaml","toml"],["oxfmt"],[".oxfmtrc.json",".oxfmtrc.jsonc","oxfmt.config.ts","oxfmt.config.mts"],U,["oxfmt","--write","{file}"],"https://oxc.rs/docs/guide/usage/formatter.html",["oxfmt"]),a("ruff-format",["python"],["ruff"],["ruff.toml",".ruff.toml"],[".py",".pyi"],["ruff","format","{file}"],"https://docs.astral.sh/ruff/formatter/",["ruff"],{"pyproject.toml":["tool.ruff"]}),a("black",["python"],["black"],[],[".py",".pyi"],["black","--quiet","{file}"],"https://black.readthedocs.io/",["black"],{"pyproject.toml":["tool.black"]}),a("gofmt",["go"],["gofmt"],["go.mod"],[".go"],["gofmt","-w","{file}"],"https://pkg.go.dev/cmd/gofmt"),a("goimports",["go"],["goimports"],["go.mod"],[".go"],["goimports","-w","{file}"],"https://pkg.go.dev/golang.org/x/tools/cmd/goimports"),a("rustfmt",["rust"],["rustfmt"],["rustfmt.toml",".rustfmt.toml","Cargo.toml"],[".rs"],["rustfmt","{file}"],"https://github.com/rust-lang/rustfmt"),a("csharpier",["csharp"],["csharpier"],[".csharpierrc",".csharpierrc.json",".csharpierrc.yaml",".csharpierrc.yml"],[".cs"],["csharpier","format","{file}"],"https://csharpier.com/"),a("google-java-format",["java"],["google-java-format"],["pom.xml","build.gradle"],[".java"],["google-java-format","--replace","{file}"],"https://github.com/google/google-java-format"),a("ktlint-format",["kotlin"],["ktlint"],[".editorconfig","build.gradle.kts"],[".kt",".kts"],["ktlint","-F","{file}"],"https://pinterest.github.io/ktlint/"),a("rubocop-format",["ruby"],["rubocop"],[".rubocop.yml","Gemfile"],[".rb",".rake"],["rubocop","--fix-layout","{file}"],"https://docs.rubocop.org/"),a("pint",["php"],["pint"],["pint.json","composer.json"],[".php"],["pint","{file}"],"https://laravel.com/docs/pint"),a("swift-format",["swift"],["swift-format"],[".swift-format","Package.swift"],[".swift"],["swift-format","format","--in-place","{file}"],"https://github.com/swiftlang/swift-format"),a("stylua",["lua"],["stylua"],["stylua.toml",".stylua.toml"],[".lua"],["stylua","{file}"],"https://github.com/JohnnyMorganz/StyLua"),a("shfmt",["shell"],["shfmt"],[".editorconfig"],[".sh",".bash",".zsh"],["shfmt","-w","{file}"],"https://github.com/mvdan/sh"),a("taplo",["toml"],["taplo"],["taplo.toml"],[".toml"],["taplo","format","{file}"],"https://taplo.tamasfe.dev/"),a("sqlfluff-format",["sql"],["sqlfluff"],[".sqlfluff","pyproject.toml"],[".sql"],["sqlfluff","format","{file}"],"https://docs.sqlfluff.com/"),a("terraform-fmt",["terraform"],["terraform"],[".terraform.lock.hcl"],[".tf",".tfvars"],["terraform","fmt","{file}"],"https://developer.hashicorp.com/terraform/cli/commands/fmt"),a("cmake-format",["cmake"],["cmake-format"],[".cmake-format.py","CMakeLists.txt"],[".cmake"],["cmake-format","-i","{file}"],"https://cmake-format.readthedocs.io/",void 0,void 0,["CMakeLists.txt"]),a("xmlformat",["xml"],["xmlformat"],[".xmlformat.conf"],[".xml",".xsd",".xsl"],["xmlformat","--overwrite","{file}"],"https://github.com/pamoller/xmlformatter"),a("mix-format",["elixir"],["mix"],["mix.exs",".formatter.exs"],[".ex",".exs"],["mix","format","{file}"],"https://hexdocs.pm/mix/Mix.Tasks.Format.html"),a("scalafmt",["scala"],["scalafmt"],[".scalafmt.conf"],[".scala",".sc",".sbt"],["scalafmt","{file}"],"https://scalameta.org/scalafmt/"),a("julia-format",["julia"],["julia"],[".JuliaFormatter.toml","Project.toml"],[".jl"],["julia","--startup-file=no","--history-file=no","-e","using JuliaFormatter; format_file(ARGS[1])","{file}"],"https://github.com/domluna/JuliaFormatter.jl"),a("powershell-format",["powershell"],["pwsh"],["PSScriptAnalyzerSettings.psd1"],[".ps1",".psm1",".psd1"],["pwsh","-NoProfile","-NonInteractive","-CommandWithArgs",'$ErrorActionPreference="Stop";$p=$args[0];$options=@{};if(Test-Path -LiteralPath PSScriptAnalyzerSettings.psd1){$options.Settings="PSScriptAnalyzerSettings.psd1"};[IO.File]::WriteAllText($p,(Invoke-Formatter -ScriptDefinition ([IO.File]::ReadAllText($p)) @options))',"{file}"],"https://learn.microsoft.com/powershell/module/psscriptanalyzer/invoke-formatter"),a("dockfmt",["dockerfile"],["dockfmt"],["Dockerfile","Containerfile"],[".dockerfile"],["dockfmt","fmt","--write","{file}"],"https://github.com/jessfraz/dockfmt",void 0,void 0,["Dockerfile","Containerfile"])];function a(r,t,o,i,e,n,f,m,s,p){return{id:r,name:r,kind:"formatter",languages:t,executables:o,configFiles:i,documentation:f,...m&&{dependencies:m},...s&&{configSections:s},formatter:{extensions:e,...p&&{fileNames:p},run:{command:n},output:"in-place"}}}c(a,"recipe");var d=class r{constructor(t,o,i=new Map){this.formatters=t;this.availableBuiltIns=o;this.evidence=i}static{c(this,"FormatterCommandRegistry")}static async fromDirectory(t,o={}){let i=await I(t,"formatters",m=>D(m).formatters,o),{available:e,evidence:n}=await O(t,i.entries.filter(m=>m.layer==="built-in").map(m=>({id:m.id,config:m.config.run})),u,o),f=[...i.entries].sort((m,s)=>m.layer==="built-in"&&s.layer==="built-in"?(n.get(s.id)?.score??0)-(n.get(m.id)?.score??0):0);return new r(f,e,n)}static fromConfig(t){return new r(Object.entries(t.formatters).map(([o,i])=>({id:o,config:i,layer:"project",sourcePath:"<memory>"})),new Set)}resolve(t,o){return this.resolveEntry(t,o)?.config}resolveEntry(t,o){return A(this.formatters,this.availableBuiltIns,this.evidence,t,o)}get entries(){return this.formatters}};var N={protocol:R,apiVersion:k,id:"formatter",setup(r){for(let t of u)r.addToolRecipe(t);r.addSetupCheck({id:"effective-config",inspect:V}),r.addCheck({id:"config",title:"Formatter",async run(t){try{let o=await d.fromDirectory(t.cwd,b(t)),i=B(o,t.files,t.cwd);return i.length===0?[{status:"skip",message:"No formatter matches the inspected project files"}]:await Promise.all(i.map(async({entry:e,source:n})=>{let f=`${e.id} [${e.layer}] command ${JSON.stringify(e.config.run.command)}`;return z(t,n,async m=>{try{let s=t.workspace?await t.workspace.run(e.config.run,m,t.signal):await h(e.config,{projectRoot:t.cwd,filePath:m,env:t.env});return t.signal?.throwIfAborted(),s.ok?{status:"pass",message:`${f}: probe passed`,detail:e.sourcePath}:{status:"fail",message:`${f}: probe failed`,detail:e.sourcePath}}catch(s){return t.signal?.throwIfAborted(),{status:"fail",message:`${f}: ${s instanceof Error?s.message:String(s)}`,detail:e.sourcePath}}})}))}catch(o){return t.signal?.throwIfAborted(),[{status:"fail",message:o instanceof Error?o.message:String(o)}]}}})}};async function V(r){try{let t=await d.fromDirectory(r.cwd,b(r)),o=[],i=new Map;for(let[e,n]of r.detectedLanguages){let f=n.map(m=>t.resolveEntry(m,r.cwd)).find(m=>m!==void 0);f!==void 0&&(o.push({kind:"formatter",languageId:e,toolId:f.id}),await $(r,f.config.run)||i.set(f.id,{id:`formatter-${f.id}-unavailable`,message:`Configured formatter ${f.id} cannot run ${JSON.stringify(f.config.run.command)}`}))}return{selections:o,actions:[...i.values()]}}catch(t){return r.signal?.throwIfAborted(),{actions:[{id:"formatter-config-invalid",message:`Formatter configuration cannot load: ${t instanceof Error?t.message:String(t)}`}]}}}c(V,"inspectFormatterSetup");function B(r,t,o){let i=new Map;for(let e of t){let n=r.resolveEntry(e,o);n!==void 0&&!i.has(n.id)&&i.set(n.id,{entry:n,source:e})}return[...i.values()]}c(B,"applicableFormatters");import C from"node:path";import{realpath as Z}from"node:fs/promises";import w from"node:path";import j from"node:os";import{readFile as H}from"node:fs/promises";import{parse as X}from"smol-toml";function _(r,t){let o=process.platform==="win32"?process.env.APPDATA:process.platform==="darwin"?w.join(j.homedir(),"Library","Application Support"):process.env.XDG_CONFIG_HOME||w.join(j.homedir(),".config");return{paths:w,userConfigDirectories:[j.homedir(),...o?[w.join(o,"rustfmt")]:[]],async readText(i){try{return await H(i,"utf8")}catch(e){if(typeof e=="object"&&e!==null&&"code"in e&&(e.code==="ENOENT"||e.code==="ENOTDIR"||e.code==="EISDIR"))return;throw e}},run:c((i,e)=>S(i,{projectRoot:r,filePath:t,input:e}),"run")}}c(_,"localRustfmtAccess");async function M(r,t,o){let i=[],e=o.paths.dirname(t);for(;;){i.push(e);let s=o.paths.dirname(e);if(s===e||/^\/[A-Z]:\/?$/u.test(e))break;e=s}i.push(...o.userConfigDirectories);let n=!1;for(let s of i){for(let p of[".rustfmt.toml","rustfmt.toml"]){let g=await o.readText(o.paths.join(s,p));if(g!==void 0){if(n=!0,Object.hasOwn(X(g),"edition"))return r;break}}if(n)break}let f;try{f=await o.run({command:["cargo","read-manifest","--offline"],cwd:"file"})}catch(s){if(typeof s=="object"&&s!==null&&"code"in s&&s.code==="ENOENT")return r;throw s}if(!f.ok)return r;let m=JSON.parse(f.stdout);return typeof m!="object"||m===null||!("edition"in m)||typeof m.edition!="string"?r:{...r,run:{...r.run,command:["rustfmt","--edition",m.edition,"{file}"]}}}c(M,"rustfmtWithEdition");var q=new Map;function J(r){return{kind:"formatter",name:"formatter",priority:100,extensions:["*"],detect:c(async t=>(r?await r.loadRegistry(t.cwd,!1):await L(t.cwd),!0),"detect"),async format({filePath:t,before:o},i){if(!r&&(t.includes("://")||i.cwd.includes("://")))throw Object.assign(new Error("Formatter requires its resource owner"),{code:"UNSUPPORTED_SOURCE"});let e=r?await r.resolveProject(t,i.cwd):await T(i.cwd,t,"formatters",u).then(l=>l===void 0?void 0:{cwd:l,external:l!==C.resolve(i.cwd)});if(e===void 0)return{ok:!0,edits:0,formatter:null};let n=e.cwd,m=(r?await r.loadRegistry(n,e.external):await L(n,e.external)).resolveEntry(t,n),s=m?.config;if(s===void 0)return{ok:!0,edits:0,formatter:null};let p=!1;if(m?.layer==="built-in"&&m.id==="rustfmt")try{let l=r?.rustfmtAccess?await r.rustfmtAccess(n,t):{file:C.join(await Z(C.dirname(t)),C.basename(t)),access:_(n,t)};s=await M(s,l.file,l.access);let G=s.run.command.filter(y=>y!=="{file}");if(s={...s,output:"stdout",run:{...s.run,command:[...G,"--emit","stdout"],cwd:"file"}},p=!0,o!==void 0&&o.length>0){let y=await l.access.run(s.run,o);if(!y.ok)return{ok:!1,edits:0,formatter:"rustfmt"};if(y.stdout!==o)return{ok:!0,edits:0,formatter:"rustfmt",skipped:"style"}}}catch{return{ok:!1,edits:0,formatter:"rustfmt"}}let g=P(s.run.command);if(r){let l=await r.run(s,n,t,p);return{ok:l.ok,edits:l.changed?1:0,formatter:g}}try{let l=await h(s,{projectRoot:n,filePath:t,stdin:p});return{ok:l.ok,edits:l.changed?1:0,formatter:g}}catch{return{ok:!1,edits:0,formatter:g}}}}}c(J,"createFormatter");async function L(r,t=!1){let o=JSON.stringify([r,t]),i=q.get(o);return i===void 0&&(i=d.fromDirectory(r,{includeGlobal:!t,requireBuiltInEvidence:!0}),q.set(o,i)),i}c(L,"loadRegistry");async function K(r){await Q(r)}c(K,"registerFormatter");async function Q(r,t){let o=J(t),i={kind:"formatter",name:"pi-agent-ide-formatter",priority:200,extensions:["*"],detect:c(()=>Promise.resolve(!0),"detect"),async format(n,f){return o.format(n,f)}},e={protocol:E,apiVersion:5,id:"formatter",setup(n){n.addTool(i)}};await Promise.all([F(r,e),v(r,N)])}c(Q,"registerFormatterWithOwner");export{u as a,d as b,_ as c,K as d,Q as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as p,f as S,j as n}from"./chunk-S4GTWS2J.js";import{a as d}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as f}from"typebox/value";var w=e.Object({pid:e.Integer({minimum:1}),parentPid:e.Integer({minimum:0}),command:e.String(),started:e.String(),identity:e.String({pattern:"^[a-f0-9-]+:[0-9]+$"}),executable:e.Union([e.String(),e.Null()])}),y=e.Object({processes:e.Array(w)}),u=p(new URL("./process-metadata-worker.py",new URL("../src/backend/process-metadata.ts",import.meta.url).href));async function m(s,o,a,r){if(r?.throwIfAborted(),!Number.isSafeInteger(a)||a<1)throw new Error("Invalid process PID");let i=s.resolve(o);if(!i)throw new n("UNSUPPORTED_SOURCE",o,"not-applied");let c=await i.backend.execute(S(await u),[String(a)],i.location.path,{signal:r});if(r?.throwIfAborted(),c.exitCode!==0)throw new n("CAPABILITY_UNAVAILABLE",o,"not-applied");let t;try{t=JSON.parse(c.stdout.toString("utf8"))}catch{throw new n("INVALID_RESPONSE",o,"not-applied")}if(typeof t=="object"&&t!==null&&"error"in t){if(t.error==="ENOENT")return;let h=new Set(["CAPABILITY_UNAVAILABLE","EACCES","BYTE_LIMIT"]);throw new n(typeof t.error=="string"&&h.has(t.error)?t.error:"INVALID_RESPONSE",o,"not-applied")}if(!f.Check(y,t)||t.processes.length!==1||t.processes[0]?.pid!==a)throw new n("INVALID_RESPONSE",o,"not-applied");return t.processes[0]}d(m,"findSshProcessMetadata");async function R(s,o,a){try{await s.stop()}catch(r){if(!(r instanceof n)||r.code!=="TRANSPORT_FAILED"||!s.identity)throw r;let i;try{i=await m(o,a,s.pid)}catch(c){throw new AggregateError([r,c],"Owned SSH cleanup could not be reconciled",{cause:c})}if(i===void 0||i.identity!==s.identity)return;throw r}}d(R,"stopOwnedSshProcess");export{R as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as n}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as a}from"typebox/value";var t=e.Function([],e.Unknown()),i=e.Union([e.Object({stage:e.Literal("text-pre-edit"),when:e.Optional(t),handler:t}),e.Object({stage:e.Literal("text-edit"),handler:t}),e.Object({stage:e.Literal("text-post-edit"),handler:t})]);function l(r){return a.Check(i,r)}n(l,"isTextEditHandlerRegistration");export{l as a};
|