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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,77 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.1 — 2026-11-23
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- `lsp_search` no longer aborts a whole query when one workspace symbol cannot be anchored. It returns the hits it can resolve and lists the skipped symbols.
|
|
8
|
+
- `lsp_search` finds the declarations of an exact name in every project under the searched directory. Before, a language server that indexes only the projects it has loaded (clangd with several compilation databases, gopls with several modules, TypeScript with several projects) could miss a declaration in a sibling project and still report a complete result. The files that write the name are now opened so their own server answers; files past a limit of 64 are reported as unchecked and make the result incomplete.
|
|
9
|
+
- Vue and TypeScript projects: a declaration in a nested TypeScript project is found, and an import binding is no longer reported as the definition of the symbol it imports.
|
|
10
|
+
- Go and Rust: qualified names that the server's index spells differently from the file outline are anchored to their real declaration. This covers Go methods with a pointer receiver (`Engine.Start` for `(*Engine).Start`), struct fields (`Holder.Value`) and Rust alias entries. Two types with a member of the same name stay distinct, and a stale range never anchors a different declaration.
|
|
11
|
+
- When a server caps its `workspace/symbol` reply (gopls at 100 candidates, rust-analyzer at 128 by default), `lsp_search` marks the result incomplete, names the server, and does not offer an anchor for all matches.
|
|
12
|
+
|
|
13
|
+
## 1.0.0 — 2026-11-22
|
|
14
|
+
|
|
15
|
+
### Breaking changes
|
|
16
|
+
|
|
17
|
+
- Edit selectors have new names. Update saved calls and Codemode scripts:
|
|
18
|
+
|
|
19
|
+
| Tool | Before | Now |
|
|
20
|
+
| ----------------------------------- | --------------------------- | ------------------------------ |
|
|
21
|
+
| `replace`, `delete`, `copy`, `move` | `start` | `at` |
|
|
22
|
+
| `replace`, `delete`, `copy`, `move` | `start` + `end` | `from` + `through` |
|
|
23
|
+
| `copy`, `move` destination | `targetStart` | `targetAfter` |
|
|
24
|
+
| `copy`, `move` destination | `targetStart` + `targetEnd` | `targetFrom` + `targetThrough` |
|
|
25
|
+
| `insert` | `anchor` | `after` |
|
|
26
|
+
| `insert` | `anchor` + `before: true` | `before` |
|
|
27
|
+
|
|
28
|
+
`from` and `through` include both matches. Use `after` or `before` instead to leave the opening or closing match out of the range. In a destination, `targetAt` replaces one match and `targetBefore` inserts before it. The new text still goes in `text`.
|
|
29
|
+
|
|
30
|
+
- Codemode scripts get tool-specific values:
|
|
31
|
+
- `read` returns the full text in `.text`. Pass the Read value or its `id` to another tool to keep the selection. Raw reads return base64 bytes, directory reads return their entries.
|
|
32
|
+
- `search`, `ast_search` and `lsp_search` return a list of matches. Use a match's `id` or the result's `id`; Search no longer has a `result` field.
|
|
33
|
+
- `file_search` and `semantic_search` return arrays of paths. `diff` returns the diff as a string.
|
|
34
|
+
- Terminal calls return `output`, `exit_code` and `session`, plus log and timing fields.
|
|
35
|
+
- Edits return a selection ID when they can confirm the new text.
|
|
36
|
+
- A failed call returns `null` and shows up in the script's failure summary. A command that ran and exited with a nonzero code still returns its exit code.
|
|
37
|
+
- Write takes images in the `image` field. `content` is always text, so a JSON string or a path that looks like an image is written as text.
|
|
38
|
+
- Check a file with `diagnostics({ path })` instead of `read({ path: "diagnostics:…" })`. The `diagnostics` view of Read still shows findings next to the code.
|
|
39
|
+
- The `symbol:` edit selector is gone. To rename a symbol, find its declaration with `lsp_search` and replace its name capture with the new name.
|
|
40
|
+
|
|
41
|
+
### Added
|
|
42
|
+
|
|
43
|
+
- `outline` lists a file's declarations page by page, without their bodies.
|
|
44
|
+
- `diagnostics` checks a file without reading it.
|
|
45
|
+
- Read accepts several sources in one call. In Codemode it returns one value per source, in order, with `null` for a source that failed.
|
|
46
|
+
- Search takes a list of files and folders as its scope and supports `AND NOT` and a leading `NOT`. Quotes in an ordinary query are matched literally.
|
|
47
|
+
- Terminal sessions can be named, renamed, listed and searched with a regex. The session log stays readable after the process exits.
|
|
48
|
+
- Windows SSH targets support file operations, search, Git changes and PowerShell terminals. On native Windows, local commands run in PowerShell and `remote_bash` runs commands on configured Linux targets.
|
|
49
|
+
- `ast_search` works out of the box: ast-grep ships with the package on supported platforms.
|
|
50
|
+
|
|
51
|
+
### Changed
|
|
52
|
+
|
|
53
|
+
- Text copied from Read or Search works as an edit selector, including line anchors. Search's `⟦ ⟧` highlight markers are ignored when the text doesn't match with them.
|
|
54
|
+
- When a selector is missing, outdated or matches several places, the error shows the current lines and a ready call to fix it. To change every occurrence, use an all-match selector.
|
|
55
|
+
- An edit over a large range you haven't read is refused until you read it.
|
|
56
|
+
- Edits change only the selected text. Line endings and look-alike characters elsewhere stay as they were. Replacing whole lines keeps the line ending of the last one, and deleting whole lines removes their line breaks too.
|
|
57
|
+
- Read marks a file that has no final newline. The marker is not part of the text in Codemode and can't be used in an edit.
|
|
58
|
+
- A selection stays valid after edits elsewhere in the file, including moved blocks and appended lines. If an edit can no longer tell repeated matches apart, it stops.
|
|
59
|
+
- Write refuses to overwrite a file that changed since you last read it, and suggests a targeted edit or a fresh Read.
|
|
60
|
+
- Parallel edits to one file wait for each other. In a Codemode batch, an edit whose selection no longer resolves fails on its own, and the result lists the failed edits.
|
|
61
|
+
- `file_search` stops at `limit`: 100 by default in direct calls, no limit in Codemode. After 30 seconds it returns the paths found so far and says the search is incomplete.
|
|
62
|
+
- Search times out after 30 seconds by default; the limit can be raised to 120 seconds. Edit locks, language-server requests and SSH transfers also time out instead of hanging.
|
|
63
|
+
- Search reports loose matches, such as the words found separately, as hints. A hint can't be used as an edit selection.
|
|
64
|
+
- Rust diagnostics no longer start a Cargo build. Compiler checks and Clippy run only when you turn them on.
|
|
65
|
+
- Built-in `rustfmt` uses the project's edition and formats only the edited file, and only if that file was already formatted.
|
|
66
|
+
- SSH reuses Pi's OpenSSH connections, streams large transfers and reconnects if the network drops while connecting.
|
|
67
|
+
|
|
68
|
+
### Fixed
|
|
69
|
+
|
|
70
|
+
- C and C++ navigation tells overloads and redeclarations apart. References and renames retry when other edits change the files during the request. When clangd can't cover all the files it needs, the result says so and a rename changes nothing.
|
|
71
|
+
- `lsp_search` skips results in files that no longer exist.
|
|
72
|
+
- On Unix, a terminal keeps the last of its output when the process closes the terminal.
|
|
73
|
+
- If an SSH connection drops during a write, the result says the effect is unknown, so you can check the target before trying again.
|
|
74
|
+
|
|
3
75
|
## 0.9.8 — 2026-11-08
|
|
4
76
|
|
|
5
77
|
### Fixed
|
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ For example, this script reads a section, finds a checklist item inside it, and
|
|
|
58
58
|
```js
|
|
59
59
|
const section = await tools.read({ path: "notes.md", offset: 10, limit: 20 });
|
|
60
60
|
const item = await tools.search({ path: section, query: "- [ ] Update docs" });
|
|
61
|
-
text(await tools.replace({
|
|
61
|
+
text(await tools.replace({ at: item.matches[0], text: "- [x] Update docs" }));
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
### Read anything through `read`
|
|
@@ -85,7 +85,7 @@ Views change how the same resource is presented. The agent can request source st
|
|
|
85
85
|
|
|
86
86
|
Use `/agent-ide-settings` to enable or disable optional semantic search and choose ColGREP (the default) or Vera. Global and Project settings follow the usual scope rules. Engine selection takes effect when saved in the settings menu; enabling or disabling the semantic search module requires a reload. Run `/semantic-index` in the project to prepare the selected engine and create its local index. The first setup may download tools and a model. Each engine has a separate index, and switching engines does not delete the other index. Searches refresh the selected index; an update failure is reported instead of returning stale results.
|
|
87
87
|
|
|
88
|
-
Once the selected index is usable, `semantic_search` returns ranked files with counts of retrieved candidates, not occurrence counts. Set `path` to a local project directory to narrow the search or to a file for bounded, approximate ranges. Use `include` and `exclude` globs to filter files. ColGREP filters before ranking; Vera's scoped and filtered search can omit relevant results because it may filter a limited candidate pool. Read the source before editing: ranges are hints, not editable selections. Ordinary search does not depend on the index.
|
|
88
|
+
Once the selected index is usable, `semantic_search` returns ranked files with counts of retrieved candidates, not occurrence counts. Set `path` to a local project directory to narrow the search or to a file for bounded, approximate ranges. Use `include` and `exclude` globs to filter files. ColGREP filters before ranking; Vera's scoped and filtered search can omit relevant results because it may filter a limited candidate pool. Read the source before editing: ranges are hints, not editable selections. In Codemode, `semantic_search` resolves to the ranked files as a `string[]`, without ranges. Ordinary search does not depend on the index.
|
|
89
89
|
|
|
90
90
|
<div align="center">
|
|
91
91
|
|
|
@@ -204,7 +204,7 @@ Pi Agent IDE is experimental and under active development. Interfaces and behavi
|
|
|
204
204
|
|
|
205
205
|
## Installation
|
|
206
206
|
|
|
207
|
-
Install [Pi](https://pi.dev/) **0.99.1 or newer** first, then install Pi Agent IDE from npm. Development and integration tests use Pi 1.5.
|
|
207
|
+
Install [Pi](https://pi.dev/) **0.99.1 or newer** first, then install Pi Agent IDE from npm. Development and integration tests use Pi 1.5.2. Older hosts are rejected with an upgrade message.
|
|
208
208
|
|
|
209
209
|
```bash
|
|
210
210
|
pi install npm:pi-agent-ide
|
|
@@ -224,6 +224,8 @@ pi -e npm:pi-agent-ide
|
|
|
224
224
|
|
|
225
225
|
Pi packages run with your full system permissions. Review the package before installing it.
|
|
226
226
|
|
|
227
|
+
npm 12 and newer skip the install scripts of dependencies you have not approved and list the skipped packages in an `install-scripts` notice at the end of `pi install`. npm 11.16 and later 11.x releases print the same notice but still run the scripts. All entries in that notice can stay unapproved. AST features load the grammars' bundled WebAssembly files and the prebuilt ast-grep parsers and binary directly, so they do not need the tree-sitter and `@ast-grep/*` scripts. The terminal tool loads the prebuilt `node-pty` binaries for Linux, macOS and Windows on x64 and arm64; the Linux binaries need glibc 2.28 or newer.
|
|
228
|
+
|
|
227
229
|
## Check project tools
|
|
228
230
|
|
|
229
231
|
Pi Agent IDE includes formatter, linter, LSP, and debugger mappings. It discovers each tool from the project that owns the file, including project-local binaries and commands on your `PATH`. Settings from one project do not leak into another.
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as x,e as C}from"./chunk-QUK5ZEYX.js";import{a as R}from"./chunk-PS2B6THP.js";import{A as y,B as S,G as p}from"./chunk-IRLWXPL4.js";import{a as u}from"./chunk-EI7MMDWY.js";import{keyText as $}from"@earendil-works/pi-coding-agent";import{Text as D}from"@earendil-works/pi-tui";function w(e,r){let{files:o,...t}=e,s=p(r);return{...t,storedFiles:o.map(({lines:l,...a})=>({...a,lines:l.map(n=>{let i=[n.lineNumber,y(n.text,s),n.ranges];return n.logicalMatchIds===void 0?i:[...i,n.logicalMatchIds]})}))}}u(w,"compactSearchDetails");function g(e,r){if("files"in e)return e;let{storedFiles:o,...t}=e,s=p(r);return{...t,files:o.map(({lines:l,...a})=>({...a,lines:l.map(([n,i,h,c])=>({lineNumber:n,text:S(i,s),ranges:h,matchCount:h.length,...c===void 0?{}:{logicalMatchIds:c}}))}))}}u(g,"restoreSearchDetails");var k=new WeakMap,z=12;function j(e,r,o,t){if(typeof e.details=="object"){let a=k.get(e.details);a===void 0&&(a=g(e.details,e.content.flatMap(n=>n.type==="text"?[n.text]:[]).join(`
|
|
2
|
+
`)),k.set(e.details,a)),e={...e,details:a}}if(r.isPartial||t.isError||!C(e.details)){let a=e.content[0],n=a?.type==="text"?a.text:"",i=t.isError?"error":r.isPartial?"dim":"toolOutput";return new D(o.fg(i,n),0,0)}let l=(t.lastComponent instanceof m?t.lastComponent:void 0)??new m(e.details,o,r.expanded);return l.updateSearch(e.details,o,r.expanded),l}u(j,"renderSearchResult");var m=class extends R{static{u(this,"SearchResultPanel")}constructor(r,o,t){super(T(r,t),o,t)}updateSearch(r,o,t){super.update(T(r,t),o,t)}};function T(e,r){let o=P(e,r).map(t=>t.kind==="file"?{kind:"source",label:t.file.path,link:t.file.link,count:t.file.matchCount}:t.kind==="line"?{kind:"line",...t.line}:t.kind==="candidate"?{kind:"note",text:t.identifier}:t.kind==="summary"?{kind:"note",text:t.text}:t.kind==="omitted"?{kind:"note",text:`\u2026 ${t.matches} more ${d(t.matches,"match","matches")} \xB7 ${$("app.tools.expand")} to expand`}:{kind:"note",text:"No matches found"});return{summary:b(e),rows:o}}u(T,"searchModel");function P(e,r){let o=e.fuzzy?.status==="ready"&&e.fuzzy.candidates.length>0,t=e.files.length===0?o?[]:[{kind:"empty"}]:e.files.flatMap(n=>[{kind:"file",file:n},...n.uniqueLineCount===void 0?n.lines.map(i=>({kind:"line",file:n,line:i})):[{kind:"summary",text:`${String(n.uniqueLineCount)} unique line texts \xB7 ${x(n.matchCount)}`},...(n.groups??[]).map(i=>({kind:"summary",text:`\xD7${String(i.matchCount)} ${i.text}`}))]]);if(e.fuzzy!==void 0&&(e.fuzzy.status==="skipped"?t.push({kind:"summary",text:"Fuzzy search unavailable"}):e.fuzzy.candidates.length>0&&t.push(...e.fuzzy.candidates.flatMap(n=>{let i=e.fuzzyPresentation?.groups.find(c=>c.identifier===n.identifier)?.files??[],h=i.reduce((c,f)=>c+f.matchCount,0);return[{kind:"candidate",identifier:n.identifier},...i.length===0?[]:[{kind:"summary",text:`Shown ${String(h)} of ${String(n.matchCount)}${n.selection.complete?"":"+"}`},...i.flatMap(c=>[{kind:"file",file:c},...c.lines.map(f=>({kind:"line",file:c,line:f}))])]]}))),(e.omittedFileCount??0)>0&&t.push({kind:"summary",text:`\u2026 ${e.omittedFileCount} more files (${e.omittedMatchCount} matches) \xB7 narrow path, include, or query`}),e.fuzzy!==void 0||r||t.length<=z)return t;let s=t.slice(0,z-1);for(;s.at(-1)?.kind==="file";)s.pop();let l=new Set(s.flatMap(n=>n.kind==="line"?n.line.logicalMatchIds??[]:[])),a=l.size>0?l.size:s.reduce((n,i)=>n+(i.kind==="line"?i.line.matchCount:0),0);return[...s,{kind:"omitted",matches:Math.max(0,e.matchCount-a)}]}u(P,"searchViewport");function b(e){if(e.matchCount===0&&e.fuzzy?.status==="ready"&&e.fuzzy.candidates.length>0&&e.fuzzyPresentation!==void 0){let o=e.fuzzy.candidates.reduce((l,a)=>l+a.matchCount,0),t=e.fuzzy.candidates.every(l=>l.selection.complete)?"":"+",s=e.fuzzyPresentation.fileCount;return`0 exact \xB7 ${String(o)}${t} fuzzy ${d(o,"match","matches")} \xB7 ${String(s)}${t} ${d(s,"file","files")}`}return e.matchCount===0?e.complete?"No matches":"No matches \xB7 incomplete":`${`${String(e.matchCount)}${e.complete?"":"+"}`} ${d(e.matchCount,"match","matches")} in ${String(e.fileCount)} ${d(e.fileCount,"file","files")}`}u(b,"searchSummary");function d(e,r,o){return e===1?r:o}u(d,"plural");export{w as a,j as b,m as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as d}from"./chunk-EI7MMDWY.js";import x from"cross-spawn";import{constants as S}from"node:fs";import{access as g,stat as T}from"node:fs/promises";import a from"node:path";function h(e){let o=process.platform==="win32"?"Scripts":"bin";return["node_modules/.bin",`.venv/${o}`,`venv/${o}`,"vendor/bin"].map(r=>a.resolve(e,r))}d(h,"projectExecutableDirectories");function y(e){return process.platform!=="win32"?{...e}:Object.fromEntries(Object.entries(e).map(([o,r])=>[o.toUpperCase(),r]))}d(y,"normalizeProcessEnvironment");function P(e,o){let r=y(o);return r.PATH=[...h(e),r.PATH].filter(Boolean).join(a.delimiter),r}d(P,"projectProcessEnvironment");async function J(e,o,r,c){c?.throwIfAborted();let n=P(o,r),u=a.isAbsolute(e)||a.dirname(e)!=="."?[a.resolve(o,e)]:(n.PATH??"").split(a.delimiter).filter(Boolean).map(t=>a.join(process.platform==="win32"?t.replace(/^"|"$/gu,""):t,e)),p=process.platform==="win32"?[...new Set((n.PATHEXT??".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean).flatMap(t=>[t,t.toLowerCase()]))]:[],i=u.flatMap(t=>[...process.platform!=="win32"||a.extname(t)?[t]:[],...p.map(l=>`${t}${l}`)]);for(let t of i){c?.throwIfAborted();try{await g(t,S.X_OK),c?.throwIfAborted();let l=await T(t);if(c?.throwIfAborted(),!l.isFile())continue;return!0}catch{c?.throwIfAborted()}}return!1}d(J,"isExecutableAvailable");function N(e,o,r,c,n){return n?.aborted?Promise.reject(n.reason):new Promise((u,p)=>{let i=x(e,o,{cwd:r,env:P(r,c),stdio:["ignore","pipe","pipe"],windowsHide:!0}),t="",l="",E=!1,v=!1,m,b,f=d(()=>{v||(v=!0,i.kill(),b=setTimeout(()=>i.kill("SIGKILL"),1e3),b.unref())},"stop"),w=setTimeout(()=>{E=!0,f()},5e3);n?.addEventListener("abort",f,{once:!0}),i.stdout?.setEncoding("utf8"),i.stderr?.setEncoding("utf8"),i.stdout?.on("data",s=>t+=s),i.stderr?.on("data",s=>l+=s),i.once("error",s=>{m=s.message}),i.once("close",s=>{if(clearTimeout(w),clearTimeout(b),n?.removeEventListener("abort",f),n?.aborted){p(n.reason);return}if(E){u({ok:!1,detail:`${e} did not respond within 5 seconds`});return}let A=(t.trim()||l.trim()).split(/\r?\n/u)[0];u({ok:m===void 0&&s===0,detail:m??(A||`${e} exited with code ${String(s)}`)})}),n?.aborted&&f(),w.unref()})}d(N,"probeExecutable");export{h as a,y as b,P as c,J as d,N as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as c}from"./chunk-EI7MMDWY.js";import{lstatSync as S}from"node:fs";import g from"node:path";import{Value as b}from"typebox/value";function y(e){return e.anyOf?.flatMap(y)??e.oneOf?.flatMap(y)??[e]}c(y,"branches");function h(e,u){try{return S(g.resolve(u,e)),!0}catch(t){let s=t.code;return!["ENOENT","ENOTDIR","ENAMETOOLONG"].includes(s??"")}}c(h,"literalPathExists");function m(e,u){if(Array.isArray(e))return e.every(t=>m(t,u));if(typeof e=="string")return!0;if(e===null||typeof e!="object"||!("id"in e)||typeof e.id!="string")return!1;try{return u.resolveSource(e),!0}catch{return!1}}c(m,"validSource");function l(e,u,t,s=!1){let n=e,f=u.flatMap(y);if(typeof n=="string"){let o=f.some(a=>a.type==="string");if(o&&(!s||t===void 0))return n;let i=n.trimStart()[0],r=i==="{"?"object":i==="["?"array":void 0;if(r===void 0||!f.some(a=>a.type===r))return n;try{n=JSON.parse(n)}catch{return e}if(o&&t!==void 0){if(h(e,t.cwd))return e;let a=l(n,u,t,s);try{return m(a,t)&&b.Check({anyOf:f},a)?a:e}catch{return e}}}if(Array.isArray(n)){let o=f.flatMap(r=>r.type==="array"&&r.items?[r.items]:[]);if(o.length===0)return n;let i=n.map(r=>l(r,o,t,s));return i.some((r,a)=>r!==n[a])?i:n}if(n!==null&&typeof n=="object"){let o=n,i=o;for(let r of Object.keys(o)){let a=f.flatMap(d=>d.type==="object"&&d.properties?.[r]?[d.properties[r]]:[]);if(a.length===0)continue;let p=l(o[r],a,t,t?.sourceFields.includes(r));p!==o[r]&&(i===o&&(i={...o}),Object.defineProperty(i,r,{value:p,enumerable:!0,configurable:!0,writable:!0}))}return i}return n}c(l,"normalize");function T(e,u,t){return l(e,[u],t)}c(T,"normalizeStructuredArguments");export{T as a};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as U,b as A,c as I,d as $}from"./chunk-SF44YQCB.js";import{a as k,s as v}from"./chunk-3JBQYLJ4.js";import{H as F,i as E,j as D,o as C}from"./chunk-OEEE5BLN.js";import{a as u}from"./chunk-EI7MMDWY.js";import{spawn as G}from"node:child_process";import{stat as O}from"node:fs/promises";import m from"node:path";import{createInterface as T}from"node:readline";async function Z(s,r,t,d,n){let b=r.limit??100,f=["--files","--sort","path","--line-buffered","--hidden","--no-config","--glob","!.git/**"];for(let e of v(r.include))f.push("--glob",e);for(let e of v(r.exclude))f.push("--glob",`!${e}`);let l=r.paths??(r.path===void 0?[]:[r.path]),g=Symbol("file search match limit"),p=new AbortController,i=d===void 0?p.signal:AbortSignal.any([d,p.signal]),a=new Set;E(e=>{let o=[...a],h=C(e);return F({...h,content:[...h.content,{type:"text",text:[`Incomplete file list (${o.length} found)`,...o.slice(0,100)].join(`
|
|
2
|
+
`)}]},k,{status:"partial",data:{kind:"files",complete:!1,files:o},errors:[{code:e.code,source:e.target,message:e.message}]},{maxBytes:1/0})});let w,x=u((e,o)=>{i.aborted||!K(e,s)||(a.add(o),a.size>=b&&p.abort(g))},"accept"),P=u((e,o)=>{if(!p.signal.aborted&&e.failed(o))throw new Error(e.message||`rg exited with code ${String(o)}`);w=$(w,e.unreadable(p.signal.aborted?2:o))},"recordExit");try{if(i.throwIfAborted(),n!==void 0){let e=(l.length===0?["."]:l).map(o=>n.resolve(t,o)).toSorted();for(let o of e){let h=await n.isDirectory(o,i),c=h?o:n.dirname(o),y=[...f,...h?await A(o,n,i):[],"--",h?".":`./${n.basename(o)}`];i.throwIfAborted();let R=await n.runLines(y,c,S=>{let z=S.replace(/^\.\//u,"");x(z,n.resolve(c,S))},i),L=new I(S=>n.resolve(c,S));L.write(R.stderr),P(L,R.code),i.throwIfAborted()}}else{if(l.some(c=>c.includes("://"))||t.includes("://"))throw new Error("No search environment owns this scope.");let e=l.toSorted((c,y)=>j(m.resolve(t,c),m.resolve(t,y)));f.push(...await H(e,t,i)),e.length>0&&f.push("--",...e),i.throwIfAborted();let o=new I(c=>m.resolve(t,c)),h=await B(f,t,o,i,c=>{let y=m.relative(t,m.resolve(t,c));x(y,y)});P(o,h),i.throwIfAborted()}}catch(e){if(d?.throwIfAborted(),e!==g)throw e}return{files:[...a],complete:!p.signal.aborted,...w===void 0?{}:{unreadable:w}}}u(Z,"searchFiles");function j(s,r){return s<r?-1:s>r?1:0}u(j,"comparePaths");function B(s,r,t,d,n){return new Promise((b,f)=>{let l=G(U(),s,{cwd:r,stdio:["ignore","pipe","pipe"],windowsHide:!0}),g,p=new Promise(a=>l.once("close",()=>a())),i=u(()=>{D(p),l.kill("SIGKILL")},"abort");d.addEventListener("abort",i,{once:!0}),l.stderr.setEncoding("utf8"),l.stderr.on("data",a=>t.write(a)),T({input:l.stdout,crlfDelay:1/0}).on("line",a=>{if(!(a===""||d.aborted||g!==void 0))try{n(a)}catch(w){g=w,i()}}),l.once("error",a=>{g=a}),l.once("close",a=>{d.removeEventListener("abort",i),g!==void 0?f(g):b(a)})})}u(B,"runLocalLines");async function H(s,r,t){return(await Promise.all((s.length===0?["."]:s).map(async n=>{let b=m.resolve(r,n);return await O(b).then(l=>l.isDirectory(),()=>!1)?A(b,void 0,t):[]}))).some(n=>n.length>0)?["--no-ignore-parent"]:[]}u(H,"localParentIgnoreArguments");function K(s,r){if(/[*?[\]{}]/u.test(r)){let t=r.replace(/^\.\//u,"");return m.matchesGlob(t.includes("/")?s:m.basename(s),t)}return M(s,r)}u(K,"matchFile");function M(s,r){if(r.length===0)return!0;let t=0,d=s.toLowerCase();for(let n of r.toLowerCase()){if(t=d.indexOf(n,t),t===-1)return!1;t+=1}return!0}u(M,"fuzzyMatch");export{Z as a};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{a as D,b as M}from"./chunk-PS2B6THP.js";import{D as F,la as E,pa as N}from"./chunk-OEEE5BLN.js";import{a as s}from"./chunk-EI7MMDWY.js";function K(e,t,r){return{limit:e??(t&&r==="matches"?Number.MAX_SAFE_INTEGER:void 0),audience:t?"script":"agent",uncappedFiles:t&&r==="files"}}s(K,"searchCallPolicy");import{Type as u}from"typebox";var I="File, directory, URL (no read needed first), docs:all for all packaged guide bodies, docs:<id> for one guide, unchanged Read/Search/edit result or its UUID, or an array of file and directory paths or of results. Use literal text or regex: for docs: sources. Results select only their registered ranges.",m=u.Object({query:u.String({minLength:1,description:"Text to find, matched literally, quotes included. Uppercase AND, OR, NOT, || or a spaced | make it a Boolean expression, where quotes group literal text. Use regex:<pattern> for regular expressions."}),path:u.Optional(u.Union(E.anyOf,{description:I})),include:u.Optional(u.String({description:"Optional include glob for local or SSH files"})),exclude:u.Optional(u.String({description:"Optional exclude glob for local or SSH files"})),caseSensitive:u.Optional(u.Boolean({description:"Match letter case"})),wholeWord:u.Optional(u.Boolean({description:"Match complete words"})),multiline:u.Optional(u.Boolean({description:"Let text or regex:<pattern> match across lines; . also matches line breaks. Local or SSH files and result scopes only."})),limit:u.Optional(u.Integer({minimum:1,maximum:1e3,description:"Maximum displayed items, including compact file summaries (default 50)."}))},{additionalProperties:!1});function Ae(e){let t=[...new Set(e.flatMap(o=>o.split(`
|
|
2
|
+
`)))].filter(o=>o.trim()!=="");if(t.length===0)return m;let r=s(o=>({...o,description:[I,...t].join(`
|
|
3
|
+
`)}),"describe");return{...m,properties:{...m.properties,path:r(m.properties.path)}}}s(Ae,"describeSearchParameters");import x from"node:path";import{pathToFileURL as Y}from"node:url";function ee(e,t,r,o,i,l=[],c=[]){let d=l.map(a=>({kind:"note",text:a}));d.push(...M(e.flatMap(a=>{let w=x.isAbsolute(a.source),X=w&&i?x.relative(i,a.source)||x.basename(a.source):a.source,L=w?Y(a.source).href:/^https?:/iu.test(a.source)?a.source:void 0,P=a.endLineNumber??a.lineNumber;return(P===a.lineNumber?[a.lineText]:[a.lineText,...a.matchedText.split(`
|
|
4
|
+
`).slice(1)]).slice(0,20).map(($,k)=>({source:a.source,label:X,...L===void 0?{}:{link:L},...w?{}:{badge:a.source.startsWith("docs:")?"DOC":/^https?:/iu.test(a.source)?"WEB":"SH"},lineNumber:a.lineNumber+k,text:$,ranges:[{from:k?0:a.startColumn,to:a.lineNumber+k===P?a.endColumn:$.length}]}))}))),e.length||d.push({kind:"note",text:"No matches found"}),e.some(a=>(a.endLineNumber??a.lineNumber)-a.lineNumber>=20)&&d.push({kind:"note",text:"\u2026 source preview shortened"}),d.push(...c.map(a=>({kind:"note",text:a,expandedOnly:!0})));let g=`${e.length}${t?"":"+"}`,z=new Set(e.map(a=>a.source)),J=e.length>0&&e.every(a=>x.isAbsolute(a.source));return new D({summary:`${g} ${e.length===1?"match":"matches"} in ${z.size} ${J?z.size===1?"file":"files":z.size===1?"source":"sources"}`,rows:d},r,o)}s(ee,"renderSearchMatches");var y=class extends Error{static{s(this,"SearchScopeChangedError")}code="SCOPE_CHANGED";constructor(t,r){super(`The scope this search ran in is no longer in its file (${t}). Run the search again from a current Read or Search result.`,r),this.name="SearchScopeChangedError"}};async function te(e,t){if(e.scope!==void 0)try{return e.rescope!==void 0?await e.rescope(t):(await N(e.scope,t),e.scope)}catch(r){throw t?.aborted===!0||r instanceof y?r:new y(r instanceof Error?r.message:String(r),{cause:r})}}s(te,"currentScope");function ne(e,t){return e.targets.some(r=>r.source===t.source&&r.ranges.some(o=>(o.start.lineNumber<t.lineNumber||o.start.lineNumber===t.lineNumber&&o.start.column<=t.startColumn)&&(o.end.lineNumber>(t.endLineNumber??t.lineNumber)||o.end.lineNumber===(t.endLineNumber??t.lineNumber)&&o.end.column>=t.endColumn)))}s(ne,"containsSearchMatch");function re(e){if(e===void 0)return[];let t=[],r=0,o="";for(let i of e){if(i==="{"?r+=1:i==="}"&&(r=Math.max(0,r-1)),r===0&&(i===","||/\s/u.test(i))){o.length>0&&(t.push(o),o="");continue}o+=i}return o.length>0&&t.push(o),t}s(re,"splitGlobList");var h=class extends Error{static{s(this,"SearchCaptureLimitError")}constructor(t="the query"){super(`Search capture exceeded its safety budget. Narrow path, include/exclude globs, or ${t} and retry. limit only controls presentation; no complete result or edit scope was captured.`),this.name="SearchCaptureLimitError"}},v=class{constructor(t){this.query=t}static{s(this,"SearchCaptureGuard")}outputBytes=0;textBytes=0;matches=0;addOutput(t){if(this.outputBytes+=t,this.outputBytes>67108864)throw new h(this.query)}addText(t){if(this.textBytes+=t*2,this.textBytes>67108864)throw new h(this.query)}addMatch(t){this.addLine(t.source),this.addText(t.matchedText.length+t.lineText.length+(t.linesText?.length??0))}addLine(t){if(this.matches++,this.matches>5e4)throw new h(this.query);this.addText(t.length)}};var b="\0null";function oe(e,t){if(typeof e!="object"||e===null||Array.isArray(e))return e;let r=Object.entries(e).filter(([,l])=>l===null);if(r.length===0)return e;let o=t.properties??{},i={...e};for(let[l]of r){let c=o[l];if(c===void 0||!j(c))throw new Error(`${l} is null. Omit ${l} instead; a null here usually means the call that produced it failed or selected no text.`);i[l]=b}return i}s(oe,"markNullFields");function ie(e){let t=Object.entries(e).filter(([,o])=>o===b).map(([o])=>o);return t.length===0?void 0:`${t.length===1?`${t[0]} is`:`${t.join(", ")} are`} null: the call that produced the value probably failed or selected no text. Omit the field to leave it unset; an omitted path searches the working directory.`}s(ie,"nullFieldsMessage");function j(e){let{type:t,anyOf:r}=e;return t==="string"||(r?.some(j)??!1)}s(j,"acceptsString");import se from"node:path";var ae=/^(?:RESULT#|SEARCH#|<system-result\b)|^[a-f\d]{8}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{12}$/u;function T(e){return typeof e!="string"||ae.test(e)}s(T,"isResultReference");function le(e){let t=e.filter(r=>!T(r));if(t.length!==0){if(t.length<e.length)throw new Error("A path list holds either file and directory paths or Read/Search/edit results and their UUIDs, not both. Search them in separate calls.");for(let r of t){if(r.trim().length===0)throw new Error("A path in a path list must not be empty.");if(/^[a-z][a-z\d+.-]+:/iu.test(r)&&!r.startsWith("ssh://"))throw new Error(`A path list takes local or ssh:// file and directory paths. Search ${r} in a separate call.`)}return t}}s(le,"plainPathList");function ce(e,t){let r=new Set;return e.filter(o=>{let i=B(o,t);return r.has(i)?!1:(r.add(i),!0)})}s(ce,"uniquePaths");function ue(e,t){let r=B(e,t);if(!r.includes("://"))return"local";let o=new URL(r);return`${o.protocol}//${o.host}`}s(ue,"pathMachine");function de(e){return typeof e=="string"?e===b?"null":e:Array.isArray(e)&&e.length>0&&!e.some(T)?e.join(", "):"result scope"}s(de,"describePathArgument");function B(e,t){return e.includes("://")?e.replace(/\/+$/u,""):t.includes("://")?new URL(e,t.endsWith("/")?t:`${t}/`).href.replace(/\/+$/u,""):se.resolve(t,e)}s(B,"absoluteSource");import{Type as n}from"typebox";var _=n.Object({startLine:n.Integer(),startColumn:n.Integer(),endLine:n.Integer(),endColumn:n.Integer()},{additionalProperties:!1}),H=n.Object({line:n.Optional(n.String()),match:n.Optional(n.String())},{additionalProperties:!1}),U={source:n.String(),target:n.Optional(n.String()),range:_,matchedText:n.Optional(n.String()),lineText:n.Optional(n.String()),textTruncated:n.Optional(n.Boolean()),references:n.Optional(H)},pe=n.Object({...U,captures:n.Optional(n.Record(n.String(),n.Array(n.Object(U,{additionalProperties:!1})))),role:n.Optional(n.Union([n.Literal("definition"),n.Literal("reference")])),symbol:n.Optional(n.Object({id:n.String(),name:n.String(),kind:n.String(),selector:n.Optional(n.Array(n.String())),source:n.String(),range:_},{additionalProperties:!1}))},{additionalProperties:!1}),Z={target:n.Optional(n.String()),kind:n.Literal("matches"),truncated:n.Optional(n.Boolean()),fullResult:n.Optional(n.String()),complete:n.Boolean(),matches:n.Array(pe),all:n.Optional(H),notices:n.Optional(n.Array(n.String())),editWarning:n.Optional(n.String()),fallback:n.Optional(n.Union([n.Literal("regex"),n.Literal("words")]))},A=n.Object({status:n.Union([n.Literal("ready"),n.Literal("skipped")]),message:n.Optional(n.String()),candidates:n.Array(n.Object({identifier:n.String(),kind:n.Union([n.Literal("normalized"),n.Literal("component"),n.Literal("typo")]),reason:n.String(),matchCount:n.Integer(),fileCount:n.Integer(),selection:n.Object(Z,{additionalProperties:!1})},{additionalProperties:!1}))},{additionalProperties:!1}),W=n.Union([n.Object({...Z,fuzzy:n.Optional(A),candidateLimits:n.Optional(n.Array(n.Object({server:n.String(),limit:n.Integer({minimum:0})},{additionalProperties:!1}))),skipped:n.Optional(n.Array(n.Object({name:n.String(),source:n.String()},{additionalProperties:!1})))},{additionalProperties:!1}),n.Object({kind:n.Literal("files"),complete:n.Boolean(),files:n.Array(n.String())},{additionalProperties:!1}),n.Object({kind:n.Literal("custom"),resolverId:n.String(),value:n.Unknown()},{additionalProperties:!1})]),he=F(W);function C(e,t,r,o){return{kind:"matches",...o?.target===void 0?{}:{target:o.target},complete:t,matches:e.map((i,l)=>{let c=i.linesText??((i.endLineNumber??i.lineNumber)===i.lineNumber?i.lineText:void 0);return{source:i.source,...o?.matchTargets?.[l]===void 0?{}:{target:o.matchTargets[l]},range:{startLine:i.lineNumber,startColumn:i.startColumn,endLine:i.endLineNumber??i.lineNumber,endColumn:i.endColumn},matchedText:i.matchedText,...c===void 0?{}:{lineText:c},...r===void 0?{}:{references:{line:`SEARCH#${r}:${l+1}:line`,match:`SEARCH#${r}:${l+1}:match`}}}}),...t&&r!==void 0?{all:{line:`SEARCH#${r}:all:line`,match:`SEARCH#${r}:all:match`}}:{}}}s(C,"selectionData");var S={matches:100,textBytes:4096};function fe(e){if(f(e)&&e.kind==="custom"&&f(e.value))return{...e,value:Object.fromEntries(Object.entries(e.value).map(([o,i])=>[o,fe(i)]))};if(!f(e)||e.kind!=="matches"||!Array.isArray(e.matches))return e;let t=e.matches,r=Array.isArray(e.skipped)?e.skipped:void 0;return{...e,...(t.length>S.matches||(r?.length??0)>S.matches)&&{truncated:!0},...r!==void 0&&{skipped:r.slice(0,S.matches)},matches:t.slice(0,S.matches).map(o=>{if(!f(o))return o;let i=f(o.captures)?Object.fromEntries(Object.entries(o.captures).map(([l,c])=>[l,Array.isArray(c)?c.map(d=>f(d)?q(d):d):c])):void 0;return{...q(o),...i!==void 0&&{captures:i}}})}}s(fe,"selectionPreview");function q(e){let t={...e};for(let r of["matchedText","lineText"])typeof t[r]=="string"&&Buffer.byteLength(t[r])>S.textBytes&&(delete t[r],t.textTruncated=!0);return t}s(q,"previewText");function f(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(f,"isRecord");import{Value as ge}from"typebox/value";var p={candidates:5,previewMatches:3,identifiers:2e4,identifierLength:80,vocabularyBytes:8*1024*1024,matchesPerCandidate:200,verificationBytes:4*1024*1024,timeoutMs:2e3};function me(e){return ge.Check(A,e)}s(me,"isFuzzyResultData");function R(e){return e.length>=5&&e.length<=p.identifierLength&&/^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(e)&&/[A-Za-z]/u.test(e)}s(R,"isFuzzyQuery");var O=class{static{s(this,"FuzzyVocabulary")}names=new Set;bytes=0;limited=!1;account(t){return this.bytes+=t,this.bytes>p.vocabularyBytes&&(this.limited=!0),!this.limited}add(t){if(!(this.limited||!R(t)||this.names.has(t))){if(this.names.size===p.identifiers){this.limited=!0;return}this.names.add(t)}}addText(t){if(this.account(Buffer.byteLength(t))){for(let r of t.matchAll(/[A-Za-z_$][A-Za-z0-9_$]*/gu))if(this.add(r[0]),this.limited)break}}};function V(e){return e.replace(/([A-Z]+)([A-Z][a-z])/gu,"$1 $2").replace(/([a-z0-9])([A-Z])/gu,"$1 $2").split(/[^A-Za-z0-9]+/u).filter(Boolean).map(t=>t.toLowerCase())}s(V,"splitName");function G(e,t){return e.length===t.length&&e.every((r,o)=>r===t[o])}s(G,"same");function ye(e,t){if(e.length<5||t.length<5||Math.abs(e.length-t.length)>1||/\d/u.test(e+t))return!1;let r=0;for(;r<Math.min(e.length,t.length)&&e[r]===t[r];)r++;if(e.length===t.length)return e.slice(r+1)===t.slice(r+1)||e[r]===t[r+1]&&e[r+1]===t[r]&&e.slice(r+2)===t.slice(r+2);let o=e.length<t.length?e:t,i=e.length<t.length?t:e;return o.slice(r)===i.slice(r+1)}s(ye,"oneTypo");function Se(e,t){if(e.join("")===t.join(""))return{kind:"normalized",reason:"same spelling with different case or separators"};let r=e.length<t.length?e:t,o=e.length<t.length?t:e;if(o.length===r.length+1&&r.length>=2&&r.every(c=>c.length>=3)){let c=G(r,o.slice(1)),d=G(r,o.slice(0,-1));if(c||d)return{kind:"component",reason:`${e.length>t.length?"remove":"add"} ${c?"leading":"trailing"} component '${c?o[0]:o.at(-1)}'`}}if(e.length!==t.length)return;let i=e.flatMap((c,d)=>{let g=t[d];return g!==void 0&&c!==g?[{word:c,other:g}]:[]}),l=i[0];if(!(i.length!==1||!l||!ye(l.word,l.other)))return{kind:"typo",reason:`one character edit: '${l.word}' \u2192 '${l.other}'`}}s(Se,"relation");var Q={normalized:0,component:1,typo:2};function xe(e,t){if(!R(e))return[];let r=V(e);if(r.length===0)return[];let o=[];for(let i of new Set(t)){if(i===e||!R(i))continue;let l=Se(r,V(i));l&&o.push({identifier:i,...l})}return o.sort((i,l)=>Q[i.kind]-Q[l.kind]||(i.identifier<l.identifier?-1:i.identifier>l.identifier?1:0)).slice(0,p.candidates)}s(xe,"rankFuzzyIdentifiers");function be(e,t,r){return{identifier:e.identifier,kind:e.kind,reason:e.reason,matchCount:e.matches.length,fileCount:new Set(e.matches.map(o=>o.source)).size,selection:{...C(e.matches.slice(0,p.previewMatches),e.complete,t,r),truncated:e.matches.length>p.previewMatches}}}s(be,"fuzzyCandidateData");function Re(e){let t=e.selection.complete?"":"+",r=e.selection.all?.line??e.selection.matches[0]?.references?.line,o=e.selection.matches[0],i=r??o?.source;return[`Possible name: ${e.identifier} (${e.reason})`,`${e.matchCount}${t} ${e.matchCount===1&&e.selection.complete?"match":"matches"} in ${e.fileCount}${t} ${e.fileCount===1&&e.selection.complete?"file":"files"}`,`Exact alternative: ${JSON.stringify(e.identifier)} (case-sensitive, whole identifier)`,...e.selection.complete?[]:["Capture limit reached; no complete all reference. Inspect the returned location; do not treat this candidate as a complete match set."],...i?[`Read: ${i}${r||!o?"":` \xB7 line ${o.range.startLine}`}`]:[]].join(`
|
|
5
|
+
`)}s(Re,"formatFuzzyCandidate");export{W as a,he as b,C as c,fe as d,oe as e,ie as f,T as g,le as h,ce as i,ue as j,de as k,K as l,m,Ae as n,ee as o,y as p,te as q,ne as r,re as s,h as t,v as u,p as v,me as w,R as x,O as y,xe as z,be as A,Re as B};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import{a as Ne,b as We,c as Be}from"./chunk-PBQDHYNX.js";import{a as De}from"./chunk-NKI4TZSS.js";import{d as q,k as _e,l as Le,m as V}from"./chunk-S4GTWS2J.js";import{c as Me}from"./chunk-XHFAV2NI.js";import{c as Ee,o as $e}from"./chunk-3JBQYLJ4.js";import{a as Ae}from"./chunk-47SPPIXK.js";import{a as ve,b as Pe}from"./chunk-VAXLSPPU.js";import"./chunk-VNNAVC4S.js";import{a as j}from"./chunk-6DC2Q5BI.js";import{f as oe}from"./chunk-BW3XONMZ.js";import"./chunk-GTZOIJCH.js";import{f as Ce,g as Ie}from"./chunk-KN6VPARZ.js";import{b as L}from"./chunk-IZTOXSTR.js";import{a as ke}from"./chunk-JY63UUC2.js";import{a as be}from"./chunk-I3G6K7QU.js";import{a as Se,b as Te}from"./chunk-HSAGZWPO.js";import"./chunk-PS2B6THP.js";import{d as xe,e as Re}from"./chunk-XEPCURYZ.js";import{G as se,H as G}from"./chunk-OEEE5BLN.js";import"./chunk-2QCE7GOV.js";import{d as Oe}from"./chunk-TSQ6FBTB.js";import"./chunk-IRLWXPL4.js";import"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import qt from"node:path";import{stripVTControlCharacters as Vt}from"node:util";import{truncateLine as Xt}from"@earendil-works/pi-coding-agent";import{Text as k}from"@earendil-works/pi-tui";import{DEFAULT_MAX_BYTES as Ue,DEFAULT_MAX_LINES as Fe,formatSize as Gt,truncateTail as jt}from"@earendil-works/pi-coding-agent";function N(t){return jt(t,{maxBytes:Ue-4096,maxLines:Fe-32})}a(N,"terminalOutputTail");var X=2e3;function He(t){let e=t.output.trimEnd().length,n=Math.max(0,e-X);return n===0&&e===t.output.length?t:{...t,output:t.output.slice(n,e),outputStart:t.outputStart+n,outputEnd:t.outputStart+e,truncated:t.truncated||n>0}}a(He,"noticeSnapshot");function z(t){let e=N(t.output),n=[`session: ${t.source}`,`status: ${t.status}`,`shell: ${t.shell}`,`cwd: ${t.cwd}`,`elapsedMs: ${t.elapsedMs}`,t.exitCode===void 0?void 0:`exitCode: ${t.exitCode}`,t.signal===void 0?void 0:`signal: ${t.signal}`,t.error===void 0?void 0:`error: ${t.error}`,t.waitReason===void 0?void 0:`reason: ${t.waitReason}`,t.completionReason===void 0?void 0:`completionReason: ${t.completionReason}`,t.status==="running"&&t.background?`next: Continue independent work or finish your turn; completion or a one-time idle inspection notice will wake the agent. Read ${t.source} to inspect output; use write or insert when input is needed.`:void 0,`outputRange: ${t.outputStart}-${t.outputEnd}`,t.truncated?"retainedOutput: earlier data omitted from memory":void 0,e.truncated?`fullOutput: ${t.fullOutputPath}`:void 0].filter(o=>o!==void 0),r=e.content.trimEnd();if(!e.truncated)return`${n.join(`
|
|
2
|
+
`)}
|
|
3
|
+
output:${r.length===0?" (empty)":`
|
|
4
|
+
${r}`}`;let i=e.truncatedBy==="lines"?`${Fe} line output budget`:`${Gt(Ue)} output budget`,s=`[Earlier output omitted: showing the last ${e.outputLines} of ${e.totalLines} lines (${i}). Full output: ${t.fullOutputPath}]`;return`${n.join(`
|
|
5
|
+
`)}
|
|
6
|
+
output:
|
|
7
|
+
${s}${r.length===0?"":`
|
|
8
|
+
${r}`}`}a(z,"formatAgentTerminalSnapshot");var zt=500;function Ge(t,e,n,r,i,s){let o=e?"background":"wait",l=`${i.fg("toolTitle",r.displayName.toLocaleLowerCase())}${de(s,i)} ${i.fg("muted",`\xB7 ${K(n)} \xB7 ${o}`)}`;return new k(`${l}
|
|
9
|
+
${i.fg("accent",le(r.family))} ${t}`,0,0)}a(Ge,"renderRunCall");function je(t,e,n){let r=e.map(i=>` ${n.fg("dim",i)}`);return r.push(n.fg("success",t==="delete"?"\u2713 stopped":"\u2713 sent")),new k(r.join(`
|
|
10
|
+
`),0,0)}a(je,"renderTerminalActionResult");function qe(t,e,n,r,i){let s=[Zt(t,i),i.fg("accent",`${e} ${n}`)];return r.length>0&&s.push(...r.map(o=>` ${i.fg("dim",o)}`)),new k(s.join(`
|
|
11
|
+
`),0,0)}a(qe,"renderTerminalAction");function M(t,e,n,r){let i=ze(t,L,n);return r!==void 0&&i.splice(1,1,n.fg("accent",r)),e&&t.truncated===!0&&t.fullOutputPath!==void 0&&i.push(n.fg("muted",`full output: ${t.fullOutputPath}`)),new k(i.join(`
|
|
12
|
+
`),0,0)}a(M,"renderTerminalResult");function Ve(t,e,n){if(e===!0?e="full":e===!1&&(e="compact"),e==="disabled"){if(!(t.status!==void 0&&!["running","completed"].includes(t.status)||t.exitCode!==void 0&&t.exitCode!==0||t.error!==void 0))return new k(W(t,(d,u)=>n.fg(d,u)),0,0);let o=Y(t.output??"",L),l=[...o.omission===void 0?[]:[` ${n.fg("muted",o.omission)}`],...o.lines.map(d=>` ${n.fg("dim",d)}`),...t.error===void 0?[]:[` ${n.fg("error",t.error)}`],W(t,(d,u)=>n.fg(d,u))];return new k(l.join(`
|
|
13
|
+
`),0,0)}if(e==="full"){let s=ze(t,Number.POSITIVE_INFINITY,n).slice(2);return new k(s.join(`
|
|
14
|
+
`),0,0)}let r=Y(t.output??"",L),i=[...r.omission===void 0?[]:[` ${n.fg("muted",r.omission)}`],...r.lines.map(s=>` ${n.fg("dim",s)}`)];return i.push(W(t,(s,o)=>n.fg(s,o))),new k(i.join(`
|
|
15
|
+
`),0,0)}a(Ve,"renderRunResult");function Xe(t,e){let n=a((o,l)=>e?.fg(o,l)??l,"color"),i=[`${n("accent",t.shell.toLocaleLowerCase())}${t.name===void 0?"":` ${n("toolTitle",t.name)}`} ${n("muted",`\xB7 ${K(t.cwd)} \xB7 ${t.background?"background":"wait"}`)}`,`${n("accent",le(t.shellFamily))} ${ae(t.command,84)}`],s=Yt(t.output,2);return s.length>0&&i.push(...s.map(o=>` ${n("dim",ae(o,90))}`)),i.push(W(t,n)),i.join(`
|
|
16
|
+
`)}a(Xe,"renderActiveTerminal");function ze(t,e,n){let r=(t.shell??"terminal").toLocaleLowerCase(),i=t.background===!0?"background":"wait",s=t.cwd===void 0?"workspace":K(t.cwd),o=t.shellFamily??"posix",l=[`${n.fg("accent",r)}${de(t.name,n)} ${n.fg("muted",`\xB7 ${s} \xB7 ${i}`)}`,`${n.fg("accent",le(o))} ${t.command??""}`],d=Y(t.output??"",e),u=d.omission??(t.truncated===!0?"\u2026 earlier output omitted":void 0);return u!==void 0&&l.push(` ${n.fg("muted",u)}`),d.lines.length>0&&l.push(...d.lines.map(c=>` ${n.fg("dim",c)}`)),l.push(W(t,(c,m)=>n.fg(c,m))),l}a(ze,"terminalCardLines");function Yt(t,e){return Y(t,e).lines}a(Yt,"outputTail");function Y(t,e){let n=N(Vt(t).replaceAll("\r","")),r=n.content.split(`
|
|
17
|
+
`).map(d=>Xt(d.trimEnd(),zt).text);r.at(-1)===""&&r.pop();let i=Number.isFinite(e)?Math.max(0,e):r.length,s=Math.max(0,r.length-i),o=Math.max(0,n.totalLines-n.outputLines),l=s+o;return{lines:r.slice(s),...n.truncated||l>0?{omission:l>0?`\u2026 ${l} earlier lines`:"\u2026 earlier output omitted"}:{}}}a(Y,"outputWindow");function W(t,e){let n=t.status??"running",r=Kt(n),i=n==="completed"?"success":n==="running"?"accent":"error",s=[`${r} ${n}`,Jt(t.elapsedMs??0)];return t.waitReason!==void 0&&s.push(`background \xB7 ${t.waitReason}`),t.completionReason!==void 0&&s.push(`reason ${t.completionReason}`),t.exitCode!==void 0?s.push(`exit ${t.exitCode}`):t.signal!==void 0&&s.push(`signal ${t.signal}`),e(i,s.join(" \xB7 "))}a(W,"statusLine");function Kt(t){return t==="completed"?"\u2713":t==="running"?"\u25CF":t==="stopping"?"\u25CC":"\u2717"}a(Kt,"statusIcon");function le(t){return t==="powershell"?"PS>":t==="cmd"?">":"$"}a(le,"promptMarker");function Zt(t,e){let n=(t.shell??"terminal").toLocaleLowerCase(),r=t.cwd===void 0?"workspace":K(t.cwd),i=t.background===!0?"background":"wait",s=ae(t.command??"process",48);return`${e.fg("toolTitle",n)}${de(t.name,e)} ${e.fg("muted",`\xB7 ${r} \xB7 ${i} \xB7 ${s}`)}`}a(Zt,"terminalIdentity");function de(t,e){return t===void 0?"":` ${e.fg("accent",t)}`}a(de,"nameLabel");function K(t){let e=process.env.HOME;return e!==void 0&&(t===e||t.startsWith(`${e}${qt.sep}`))?`~${t.slice(e.length)}`:t}a(K,"shortCwd");function ae(t,e){let n=t.replaceAll(/\s+/gu," ").trim();return n.length<=e?n:`${n.slice(0,e-1)}\u2026`}a(ae,"oneLine");function Jt(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(t<1e4?1:0)}s`}a(Jt,"formatElapsed");function Ye(t){return{id:"terminal",compactionGuidance:"Read shell: to list every terminal session of this Pi session, including finished ones.",onDidChange:a(e=>t.onDidChange(e),"onDidChange"),list:a(()=>t.list().filter(e=>e.status==="running"||e.status==="stopping").map(e=>({source:e.source,kind:"terminal",title:e.shell.toLocaleLowerCase(),description:e.command,...e.origin===void 0?{}:{sessionId:e.origin.sessionId},status:e.status==="stopping"?"stopping":"running",...e.pid===void 0?{}:{pid:e.pid,owned:!0},...e.remote===void 0?{}:{remote:e.remote,owned:!0},renderSummary:a(n=>Xe(e,n).split(`
|
|
18
|
+
`),"renderSummary"),renderDetail:a(n=>M(e,!0,n),"renderDetail"),sendInput:a(n=>{Promise.resolve(t.write(e.source,n)).catch(()=>{})},"sendInput"),stop:a(()=>t.delete(e.source),"stop")})),"list")}}a(Ye,"terminalProcessProvider");import{setTimeout as Fn}from"node:timers/promises";var Qt="#d8dee9",ue="#111418",en=["#000000","#cd0000","#00cd00","#cdcd00","#0000ee","#cd00cd","#00cdcd","#e5e5e5","#7f7f7f","#ff0000","#00ff00","#ffff00","#5c5cff","#ff00ff","#00ffff","#ffffff"];async function ce(t,e,n,r=1){let i=t.get(e);if(i===void 0)throw new Error(`Unknown terminal session ${e}`);await i.screenReady;let{createCanvas:s}=await import("@napi-rs/canvas"),o=Math.max(0,Math.min(i.rows-1,n?.start??0)),l=Math.max(1,Math.min(i.rows-o,n?.count??i.rows)),d=i.cols*9+24,u=l*18+24,c=s(Math.max(1,Math.round(d*r)),Math.max(1,Math.round(u*r))),m=c.getContext("2d");m.scale(r,r),m.fillStyle=ue,m.fillRect(0,0,c.width,c.height),m.textBaseline="top";let f=i.screen.buffer.active,p=Math.max(0,f.baseY);for(let g=0;g<l;g+=1){let S=f.getLine(p+o+g);if(S!==void 0)for(let y=0;y<i.cols;y+=1){let w=S.getCell(y);w===void 0||w.getWidth()===0||tn(m,w,y,g)}}return i.status==="running"&&f.cursorY>=o&&f.cursorY<o+l&&(m.fillStyle="rgba(216, 222, 233, 0.75)",m.fillRect(12+f.cursorX*9,12+(f.cursorY-o)*18+18-2,9,2)),c.toBuffer("image/png").toString("base64")}a(ce,"renderTerminalScreen");function tn(t,e,n,r){let i=Ke(e,"foreground"),s=Ke(e,"background");e.isInverse()&&([i,s]=[s,i]);let o=12+n*9,l=12+r*18;s!==ue&&(t.fillStyle=s,t.fillRect(o,l,9*Math.max(1,e.getWidth()),18));let d=e.getChars();d.length!==0&&(t.font=`${e.isBold()?"bold ":""}14px monospace`,t.fillStyle=i,t.fillText(d,o,l),e.isUnderline()&&t.fillRect(o,l+18-2,9*Math.max(1,e.getWidth()),1))}a(tn,"drawCell");function Ke(t,e){let n=e==="foreground";if(n?t.isFgDefault():t.isBgDefault())return n?Qt:ue;let i=n?t.isFgRGB():t.isBgRGB(),s=n?t.getFgColor():t.getBgColor();return i?`#${s.toString(16).padStart(6,"0")}`:nn(s)}a(Ke,"cellColor");function nn(t){let e=en[t];if(e!==void 0)return e;if(t>=232){let l=8+(t-232)*10;return Ze(l,l,l)}let n=Math.max(0,t-16),r=Math.floor(n/36),i=Math.floor(n%36/6),s=n%6,o=a(l=>l===0?0:55+l*40,"channel");return Ze(o(r),o(i),o(s))}a(nn,"ansiColor");function Ze(t,e,n){return`#${[t,e,n].map(r=>r.toString(16).padStart(2,"0")).join("")}`}a(Ze,"rgb");import{spawn as pn}from"node:child_process";import{closeSync as gn,mkdirSync as hn,openSync as yn,rmSync as wn,writeSync as Sn}from"node:fs";import Tn from"node:os";import rt from"node:path";import{createRequire as bn}from"node:module";import{randomUUID as xn}from"node:crypto";import{StringDecoder as Rn}from"node:string_decoder";import rn from"node:os";import Je from"node:path";var sn={executable:"powershell.exe",displayName:"Windows PowerShell over SSH",family:"powershell",commandArgs:a(t=>["-NoLogo","-NoProfile","-Command",t],"commandArgs")};function B(t){return t==="windows"?sn:on}a(B,"remoteShellProfile");var on={executable:"/bin/bash",displayName:"Bash over SSH",family:"posix",commandArgs:a(t=>["-lc",t],"commandArgs")};function Qe(t=process.platform,e=process.env){if(t==="win32"){let i=e.SHELL?.trim()||"powershell.exe",s=Je.win32.basename(i).toLowerCase();return s==="cmd"||s==="cmd.exe"?{executable:i,displayName:"Command Prompt",family:"cmd",commandArgs:a(o=>["/d","/s","/c",o],"commandArgs")}:{executable:i,displayName:s.startsWith("pwsh")?"PowerShell":"Windows PowerShell",family:"powershell",commandArgs:a(o=>["-NoLogo","-NoProfile","-Command",o],"commandArgs")}}let n=e.SHELL?.trim()||an()||(t==="darwin"?"/bin/zsh":"/bin/bash"),r=Je.basename(n);return{executable:n,displayName:r==="zsh"?"zsh":r==="bash"?"Bash":r,family:"posix",commandArgs:a(i=>["-c",i],"commandArgs")}}a(Qe,"resolveShellProfile");function an(){try{return rn.userInfo().shell??void 0}catch{return"/bin/sh"}}a(an,"accountShell");function et(t){switch(t.family){case"powershell":return"Write PowerShell syntax. Use PowerShell cmdlets, `$env:NAME` for environment variables, and `;` or pipelines to compose commands.";case"cmd":return"Write Command Prompt syntax. Use `%NAME%` for environment variables and `&&` to chain successful commands.";case"posix":return`Write ${t.displayName} syntax. Use POSIX-style paths, \`$NAME\` for environment variables, and \`&&\` or pipelines to compose commands.`}}a(et,"shellSyntaxGuidance");var Z=class{constructor(e){this.size=e}static{a(this,"TerminalTextStream")}#r=0;#e=0;#t=!1;#n=0;#s="";write(e){let n=this.#s+e;this.#s="";let r="",i=0;for(;i<n.length;){let s=n[i]??"";if(s==="\x1B"||s==="\x9B"){let o=ln(n,i);if(o===void 0){this.#s=n.slice(i);break}r+=this.#d(n.slice(i,o)),i=o;continue}if(i+=s.length,s===`
|
|
19
|
+
`)this.#n=0,this.#u(),r+=s;else if(s==="\r")this.#n=0,this.#e=0,this.#t=!1,r+=s;else if(s===" "||s==="\b")r+=s;else{if(s.charCodeAt(0)<32||s.charCodeAt(0)===127)continue;r+=this.#o(s)}}return r}#o(e){let{cols:n}=this.size(),r=" ".repeat(this.#n);return this.#n=0,this.#t&&(this.#u(),this.#e=0),this.#e+=1,this.#t=this.#e>=n,this.#t&&(this.#e=n-1),r+e}#u(){this.#r=Math.min(this.#r+1,this.size().rows-1),this.#t=!1}#d(e){let n=/^(?:\u001b\[|\u009b)([0-?]*)[ -/]*([@-~])$/u.exec(e);if(!n)return"";let[,r="",i]=n;if(r.startsWith("?")||r.startsWith(">")||r.startsWith("<"))return"";let s=r.split(";").map(d=>Number.parseInt(d,10)),o=Math.max(1,s[0]||1),l=Math.max(1,s[1]||1);return i==="H"||i==="f"?this.#a(o-1,l-1):i==="B"?this.#a(this.#r+o,this.#e):i==="E"?this.#a(this.#r+o,0):i==="G"?this.#a(this.#r,o-1):i==="d"?this.#a(o-1,this.#e):(i==="C"?(this.#n+=o,this.#e=Math.min(this.#e+o,this.size().cols-1),this.#t=!1):i==="D"?(this.#n=Math.max(0,this.#n-o),this.#e=Math.max(0,this.#e-o),this.#t=!1):i==="A"||i==="F"?(this.#r=Math.max(0,this.#r-o),i==="F"&&(this.#e=0),this.#n=0,this.#t=!1):i==="J"&&(s[0]||0)>=2&&(this.#r=0,this.#n=0),"")}#a(e,n){let{cols:r,rows:i}=this.size(),s=Math.min(Math.max(0,e),i-1),o=Math.min(Math.max(0,n),r-1),l="";return s>this.#r?(l=`
|
|
20
|
+
`.repeat(s-this.#r),this.#e=0,this.#n=o):s===this.#r&&o>this.#e?this.#n+=o-this.#e:this.#n=0,this.#r=s,this.#e=o,this.#t=!1,l}};function ln(t,e){if(t[e]==="\x9B")return tt(t,e+1);let n=t[e+1];if(n===void 0)return;if(n==="[")return tt(t,e+2);if(n==="]"||n==="P"||n==="_"||n==="^"||n==="X"){for(let i=e+2;i<t.length;i+=1){if(n==="]"&&t[i]==="\x07")return i+1;if(t[i]==="\x1B"){if(t[i+1]===void 0)return;if(t[i+1]==="\\")return i+2}}return}let r=e+1;for(;r<t.length&&/[ -/]/u.test(t[r]??"");)r+=1;return r<t.length?r+1:void 0}a(ln,"sequenceEnd");function tt(t,e){for(let n=e;n<t.length;n+=1){let r=t.charCodeAt(n);if(r>=64&&r<=126)return n+1;if(r<32||r>126)return n}}a(tt,"csiEnd");import{readSync as dn}from"node:fs";import{ReadStream as un}from"node:tty";var cn=256*1024,mn=4096;function nt(t){let{_socket:e,fd:n}=t;if(!(e instanceof un)||n===void 0||n<0)return;let r=e.destroy.bind(e);e.destroy=i=>{try{!i&&!e.destroyed&&!e.readableEnded&&fn(e,n)}finally{r(i)}return e}}a(nt,"preserveUnixPtyOutput");function fn(t,e){t.read();let n=Buffer.allocUnsafe(mn);for(let r=cn;r>0;){let i;try{i=dn(e,n,0,Math.min(n.length,r),null)}catch{break}if(i===0)break;t.push(n.subarray(0,i)),t.read(),r-=i}t.push(null),t.read()}a(fn,"drainOutput");var ot=bn(new URL("../src/plugins/pi-agent-ide-terminal/src/session-manager.ts",import.meta.url).href),it=1e6,vn=100,Pn=30,En=2e3,$n=50,at=/^[A-Za-z0-9][A-Za-z0-9._-]{0,47}$/u,lt=/^[a-f0-9]{12}$/u;function dt(t){return at.test(t)}a(dt,"isTerminalAddress");function An(t){if(!at.test(t))return"Use 1 to 48 letters, digits, '.', '_' or '-', starting with a letter or digit.";if(lt.test(t))return"Twelve lowercase hexadecimal characters are reserved for generated addresses."}a(An,"terminalNameSyntaxProblem");var U=class{static{a(this,"TerminalSessionManager")}#r;#e=new Map;#t=new Map;#n=new Set;#s=new Set;#o=new Map;#u=new WeakMap;#d=new Map;#a=!1;constructor(e=In){this.#r=e}onDidChange(e){return this.#n.add(e),()=>this.#n.delete(e)}onDidComplete(e){return this.#s.add(e),()=>this.#s.delete(e)}list(){return[...this.#e.values()].sort((e,n)=>n.startedAt-e.startedAt).map(e=>this.snapshot(e))}listOwnedBy(e){return this.list().filter(n=>n.origin===void 0||n.origin.sessionId===e)}get(e){let n=On(e),r=this.#t.get(n);if(r!==void 0)return this.#e.get(r);let i=this.#e.get(n);return i?.name===void 0?i:void 0}getById(e){return this.#e.get(e)}nameProblem(e){let n=An(e);if(n!==void 0)return n;if(this.#t.has(e))return`shell:${e} is already used by another session.`}rename(e,n){let r=this.required(e);if(r.name===n)return r;let i=this.nameProblem(n);if(i!==void 0)throw new Error(`Cannot rename ${r.source}: ${i}`);return r.name!==void 0&&this.#t.delete(r.name),this.#t.set(n,r.id),r.name=n,r.source=`shell:${n}`,this.#i(r),r}snapshot(e,n=Date.now()){return{id:e.id,...e.name===void 0?{}:{name:e.name},source:e.source,...e.origin===void 0?{}:{origin:e.origin},command:e.command,cwd:e.cwd,shell:e.shell.displayName,shellFamily:e.shell.family,...e.process===void 0?{}:{pid:e.process.pid},...e.remote===void 0?{}:{remote:{target:e.remote.target,pid:e.remote.process.pid,...e.remote.process.identity===void 0?{}:{identity:e.remote.process.identity}}},background:e.background,status:e.status,...e.waitReason===void 0?{}:{waitReason:e.waitReason},...e.completionReason===void 0?{}:{completionReason:e.completionReason},lastActivityAt:e.lastActivityAt,idleMs:Math.max(0,n-e.lastActivityAt),startedAt:e.startedAt,...e.endedAt===void 0?{}:{endedAt:e.endedAt},elapsedMs:(e.endedAt??n)-e.startedAt,...e.exitCode===void 0?{}:{exitCode:e.exitCode},...e.signal===void 0?{}:{signal:e.signal},...e.error===void 0?{}:{error:e.error},output:e.output,outputStart:e.outputStart,outputEnd:e.outputStart+e.output.length,truncated:e.outputStart>0,fullOutputPath:e.fullOutputPath,cols:e.cols,rows:e.rows}}start(e){let n=this.#c(e),{id:r,cols:i,rows:s}=n,o;try{let d=ot("node-pty"),u={name:"xterm-256color",cols:i,rows:s,cwd:e.cwd,env:_n(Mn()),...globalThis.process.platform==="win32"?{useConptyDll:!0}:{}};o=d.spawn(e.shell.executable,[...e.shell.commandArgs(e.command)],u)}catch(d){let u={...n,status:"failed",endedAt:Date.now(),error:J(d)};return this.#e.set(r,u),this.#l(r),n.resolveCompletion(u),queueMicrotask(()=>this.#f(u)),u}let l={...n,process:o};return this.#e.set(r,l),o.onData(d=>this.#m(l,d)),globalThis.process.platform!=="win32"&&nt(o),globalThis.process.platform==="win32"&&l.screen.onData(d=>{if(!A(l.status))try{o.write(d)}catch{}}),o.onExit(({exitCode:d,signal:u})=>{A(l.status)||(l.endedAt=Date.now(),l.exitCode=d,u!==0&&(l.signal=u),l.status=l.status==="stopping"?"stopped":d===0?"completed":"failed",(d===124||d===137)&&(l.completionReason="timeout"),this.#l(l.id),l.resolveCompletion(l),this.#i(l),this.#f(l))}),this.#i(l),l}#c(e){if(this.#a)throw new Error("Terminal session manager is closed");let n=this.#r();if(!lt.test(n)||this.#e.has(n)||this.#d.has(n))throw new Error("Terminal session IDs must be unique 12-character hexadecimal values");let r=e.name!==void 0&&this.nameProblem(e.name)===void 0?e.name:void 0;r!==void 0&&this.#t.set(r,n);let i=Nn(n);this.#o.set(n,yn(i,"a",384));let s=e.cols??vn,o=e.rows??Pn,l=Cn(s,o),d=a(c=>{},"resolveCompletion"),u=new Promise(c=>{d=c});return{id:n,...r===void 0?{}:{name:r},source:`shell:${r??n}`,command:e.command,background:e.background,cwd:e.cwd,shell:e.shell,startedAt:Date.now(),lastActivityAt:Date.now(),cols:s,rows:o,fullOutputPath:i,screen:l,status:"running",output:"",outputStart:0,screenReady:Promise.resolve(),completion:u,resolveCompletion:d,completionDelivered:!1,staleReminderDelivered:!1}}async startRemote(e){let n=B(q(e.remote.backend.target)),r=this.#c({...e,cwd:e.remote.location.source,shell:n}),i=new AbortController;this.#d.set(r.id,{abort:i,completion:r.completion});let s=a(()=>i.abort(),"abortStartup");e.signal?.addEventListener("abort",s,{once:!0}),e.signal?.aborted&&s();try{let o=await e.remote.backend.startProcess(n.executable,n.commandArgs(e.command),e.remote.location.path,{pty:{cols:r.cols,rows:r.rows},signal:i.signal}).finally(()=>e.signal?.removeEventListener("abort",s)),l={...r,remote:{target:e.remote.location.target,process:o}};this.#e.set(l.id,l);let d=new Rn("utf8");o.stdout.on("data",c=>this.#m(l,d.write(c))),o.stderr.resume();let u=a(()=>{this.#m(l,d.end()),l.endedAt=Date.now(),this.#l(l.id),l.resolveCompletion(l),this.#i(l),this.#f(l)},"finish");return o.completion.then(({exitCode:c})=>{l.exitCode=c,c<0&&(l.signal=-c),l.status=l.status==="stopping"?"stopped":c===0?"completed":"failed",(c===124||c===137)&&(l.completionReason="timeout"),u()},c=>{l.status="lost",l.error=J(c),u()}),this.#i(l),l}catch(o){let l={...r,status:"failed",endedAt:Date.now(),error:J(o)};return this.#e.set(l.id,l),this.#l(l.id),l.resolveCompletion(l),queueMicrotask(()=>this.#f(l)),l}finally{this.#d.delete(r.id)}}async wait(e,n){let r=this.required(e);return A(r.status)?r:n?.aborted===!0?(await this.stop(r.source,"cancelled"),r):await new Promise((i,s)=>{let o=a(()=>{this.stop(r.source,"cancelled").then(i,s)},"onAbort");n?.addEventListener("abort",o,{once:!0}),r.completion.then(l=>{n?.removeEventListener("abort",o),i(l)},s)})}async waitForForeground(e,n){let r=this.required(e);if(A(r.status))return{session:r};let i=n.interactiveDelayMs??3e3;return await new Promise(s=>{let o=!1,l,d=a(f=>{o||(f!==void 0&&A(r.status)&&(f=void 0),o=!0,clearTimeout(c),clearInterval(m),n.signal?.removeEventListener("abort",u),f!==void 0&&(r.background=!0,f!=="aborted"&&(r.waitReason=f),this.#i(r)),s({session:r,...f===void 0?{}:{reason:f}}))},"finish"),u=a(()=>d("aborted"),"onAbort"),c=setTimeout(()=>d("timeout"),n.timeoutMs),m=setInterval(()=>{if(!kn(r)){l=void 0;return}l??=Date.now(),Date.now()-l>=i&&d("interactive")},Math.min(100,Math.max(10,i/2)));n.signal?.addEventListener("abort",u,{once:!0}),n.signal?.aborted===!0&&u(),r.completion.then(()=>d())})}async waitForOutputAfter(e,n){let r=Date.now()+300,i=n,s;for(;Date.now()<r;){let o=e.outputStart+e.output.length;if(o!==i)i=o,s=Date.now(),await e.screenReady;else if(s!==void 0&&Date.now()-s>=40)return;await me(10)}await e.screenReady}screenRows(e){let n=e.screen.buffer.active;return Array.from({length:e.rows},(r,i)=>(n.getLine(n.baseY+i)?.translateToString(!0)??"").trimEnd())}screenChangeRegion(e,n,r=6){let i=this.screenRows(e),s=Math.max(1,Math.min(e.rows,r)),o=Math.max(0,e.screen.buffer.active.cursorY-Math.floor(s/2)),l=-1;for(let c=0;c<=e.rows-s;c+=1){let m=0;for(let f=c;f<c+s;f+=1){let p=n[f]??"",g=i[f]??"",S=g.length>0&&!n.includes(g),y=p.length>0&&g.length===0;p!==g&&(S||y)&&(m+=1)}m>l&&(l=m,o=c)}let d=e.screen.buffer.active;return{lines:i.slice(o,o+s).map((c,m)=>{if(o+m!==d.cursorY)return c;let p=c.padEnd(d.cursorX," ");return`${p.slice(0,d.cursorX)}\u258C${p.slice(d.cursorX)}`}),startRow:o}}screenChangeWindow(e,n,r=6){return this.screenChangeRegion(e,n,r).lines}screenTail(e,n=e.rows){let r=e.screen.buffer.active,i=Math.max(0,r.baseY),s=[];for(let o=0;o<e.rows;o+=1){let l=r.getLine(i+o)?.translateToString(!0).trimEnd();l!==void 0&&l.length>0&&s.push(l)}return s.slice(-Math.max(0,n))}markInspected(e){let n=this.required(e);n.status==="running"&&(n.lastActivityAt=Date.now(),this.#i(n))}write(e,n){let r=this.requiredRunning(e);if(r.remote)return r.remote.process.write(Buffer.from(n)).catch(i=>{throw r.error=J(i),this.#i(r),i});r.process?.write(n)}sendKeys(e,n){return this.write(e,Ln(n))}async stop(e,n="stopped"){let r=this.required(e);return A(r.status)||(r.status="stopping",this.#i(r),await st(r,!1),await Promise.race([r.completion.then(()=>!0),me(En).then(()=>!1)])||(await st(r,!0),await Promise.race([r.completion,me(1e3)])),A(r.status)||(r.status=n,r.endedAt=Date.now(),this.#l(r.id),r.resolveCompletion(r),this.#f(r)),n==="cancelled"&&(r.status="cancelled"),this.#i(r)),r}async delete(e){let n=this.required(e);n.completionDelivered=!0,await this.stop(n.source),n.screen.dispose(),this.#l(n.id),wn(n.fullOutputPath,{force:!0}),this.#p(n),this.#i(n)}async screenLines(e){let n=this.required(e);await n.screenReady;let r=n.screen.buffer.active,i=[],s=Math.max(0,r.baseY);for(let o=s;o<s+n.rows;o+=1)i.push(r.getLine(o)?.translateToString(!0)??"");return i}cursor(e){let n=this.required(e);return{x:n.screen.buffer.active.cursorX,y:n.screen.buffer.active.cursorY}}async dispose(){if(this.#a)return;this.#a=!0;let e=[...this.#d.values()];for(let n of e)n.abort.abort();await Promise.all(e.map(n=>n.completion)),await Promise.all([...this.#e.values()].filter(n=>!A(n.status)).map(n=>this.stop(n.source)));for(let n of this.#e.values())n.screen.dispose(),this.#l(n.id);this.#n.clear(),this.#s.clear()}required(e){let n=this.get(e);if(n===void 0)throw new Error(`Unknown terminal session ${e}`);return n}requiredRunning(e){let n=this.required(e);if(n.status!=="running")throw new Error(`Terminal session ${n.source} is ${n.status}; input is unavailable`);return n}#m(e,n){e.lastActivityAt=Date.now();let r=this.#u.get(e);if(!r){let{screen:o}=e;r=new Z(()=>({cols:o.cols,rows:o.rows})),this.#u.set(e,r)}let i=r.write(n),s=this.#o.get(e.id);if(s!==void 0&&Sn(s,i),e.output+=i,e.output.length>it){let o=e.output.length-it;e.output=e.output.slice(o),e.outputStart+=o}e.screenReady=e.screenReady.then(()=>new Promise(o=>{e.screen.write(n,o)})),this.#i(e)}#l(e){let n=this.#o.get(e);n!==void 0&&(gn(n),this.#o.delete(e))}#i(e){for(let n of this.#n)n(e)}#f(e){for(let n of this.#s)n(e);this.#g()}#g(){let e=[...this.#e.values()].filter(n=>A(n.status)).sort((n,r)=>(r.endedAt??0)-(n.endedAt??0));for(let n of e.slice($n))n.background&&!n.completionDelivered||(n.screen.dispose(),this.#l(n.id),this.#p(n))}#p(e){this.#e.delete(e.id),e.name!==void 0&&this.#t.get(e.name)===e.id&&this.#t.delete(e.name)}};function kn(t){if(t.status!=="running")return!1;let e=t.screen.buffer.active,n=e.getLine(e.baseY+e.cursorY)?.translateToString(!0).trimEnd()??"";return/\[[^\]\n]{1,20}(?:\/[^\]\n]{1,20})+\]\s*[:?>]?\s*$/iu.test(n)||/(?:choose|select|enter|password|confirm|continue|proceed)[^\n]{0,60}[:?]\s*$/iu.test(n)||/^(?:❯|›)\s+\S/u.test(n)}a(kn,"looksInteractive");function Cn(t,e){let{Terminal:n}=ot("@xterm/headless");return new n({cols:t,rows:e,scrollback:2e3,allowProposedApi:!0})}a(Cn,"createScreen");function In(){return xn().replaceAll("-","").slice(0,12)}a(In,"defaultSessionId");function On(t){return t.startsWith("shell:")?t.slice(6):t}a(On,"normalizeSessionId");function A(t){return t!=="running"&&t!=="stopping"}a(A,"isTerminalStatus");function Mn(){return process.env}a(Mn,"processEnvironment");function _n(t){return{...Object.fromEntries(Object.entries(t).filter(e=>e[1]!==void 0)),PAGER:"cat",GIT_PAGER:"cat",SYSTEMD_PAGER:"cat",GH_PAGER:"cat"}}a(_n,"cleanEnvironment");function Ln(t){return t.split(/[\s,]+/u).filter(Boolean).map(Dn).join("")}a(Ln,"encodeTerminalKeys");function Dn(t){if(/^\^[?@A-Z[\\\]^_]$/iu.test(t)){let c=t.slice(1).toUpperCase();return c==="?"?"\x7F":String.fromCharCode(c.charCodeAt(0)&31)}let e=t.toLowerCase().split("+"),n=e.pop()??"",r=new Set(e);if([...r].some(c=>!["ctrl","control","alt","meta","shift"].includes(c)))throw new Error(`Unsupported terminal key ${t}`);let i=r.has("ctrl")||r.has("control"),s=r.has("alt")||r.has("meta"),o=r.has("shift");if(i&&n.length===1&&/[a-z@[\\\]^_?]/u.test(n)){let c=n.toUpperCase(),m=c==="?"?"\x7F":String.fromCharCode(c.charCodeAt(0)&31);return s?`\x1B${m}`:m}let l={enter:"\r",tab:" ",escape:"\x1B",esc:"\x1B",backspace:"\x7F",home:"\x1B[H",end:"\x1B[F",delete:"\x1B[3~"};if(!i&&!s&&!o&&l[n]!==void 0)return l[n];if(s&&!i&&!o&&l[n]!==void 0)return`\x1B${l[n]}`;let u={up:"A",down:"B",right:"C",left:"D",home:"H",end:"F"}[n];if(u!==void 0)return!i&&!s&&!o?`\x1B[${u}`:`\x1B[1;${1+(o?1:0)+(s?2:0)+(i?4:0)}${u}`;if(s&&!i&&n.length===1)return`\x1B${o?n.toUpperCase():n}`;throw new Error(`Unsupported terminal key ${t}`)}a(Dn,"encodeTerminalKey");async function st(t,e){if(t.remote){await t.remote.process.stop().catch(()=>{});return}let n=t.process;if(n!==void 0){if(globalThis.process.platform!=="win32")try{globalThis.process.kill(-n.pid,e?"SIGKILL":"SIGTERM");return}catch{try{n.kill(e?"SIGKILL":"SIGTERM")}catch{}return}await new Promise(r=>{let i=pn("taskkill.exe",["/PID",String(n.pid),"/T",...e?["/F"]:[]],{windowsHide:!0,stdio:"ignore"});i.once("error",()=>r()),i.once("exit",()=>r())})}}a(st,"terminateProcessTree");function me(t){return new Promise(e=>setTimeout(e,t))}a(me,"delay");function J(t){return t instanceof Error?t.message:String(t)}a(J,"errorMessage");function Nn(t){let e=rt.join(Tn.tmpdir(),`pi-agent-ide-terminal-${process.pid}`);return hn(e,{recursive:!0,mode:448}),rt.join(e,`${t}.log`)}a(Nn,"createOutputLog");import{Text as Wn}from"@earendil-works/pi-tui";var ct="Read shell:<session> for its status and output. Search with path shell: to search all listed sessions.";function mt(t,e=Date.now()){if(t.length===0)return"No terminal sessions in this Pi session.";let n=[...t].sort((i,s)=>Number(Q(s))-Number(Q(i))||s.startedAt-i.startedAt),r=n.filter(Q).length;return[`Terminal sessions of this Pi session: ${n.length} (${r} running)`,...n.map(i=>Bn(i,e)),ct].join(`
|
|
21
|
+
`)}a(mt,"formatTerminalList");function ft(t,e){let n=t.content.find(o=>o.type==="text")?.text??"",[r="",...i]=n.split(`
|
|
22
|
+
`),s=[e.fg("toolTitle","terminal sessions"),e.fg("muted",r),...i.filter(o=>o!==ct).map(o=>o.includes(" \xB7 running \xB7 ")||o.includes(" \xB7 stopping \xB7 ")?` ${e.fg("accent",o)}`:` ${e.fg("dim",o)}`)];return new Wn(s.join(`
|
|
23
|
+
`),0,0)}a(ft,"renderTerminalList");function Bn(t,e){let n=Q(t)?`${t.status} \xB7 last activity ${ut(e-t.lastActivityAt)} ago`:[t.status,t.exitCode===void 0?void 0:`exit ${t.exitCode}`,t.signal===void 0?void 0:`signal ${t.signal}`,`ended ${ut(e-(t.endedAt??e))} ago`].filter(r=>r!==void 0).join(" \xB7 ");return[t.source,n,t.shell,t.cwd,Un(t.command)].join(" \xB7 ")}a(Bn,"formatEntry");function Q(t){return t.status==="running"||t.status==="stopping"}a(Q,"isActive");function ut(t){let e=Math.max(0,Math.round(t/1e3));if(e<60)return`${e}s`;let n=Math.round(e/60);return n<60?`${n}m`:`${Math.round(n/60)}h`}a(ut,"duration");function Un(t){let e=t.replaceAll(/\s+/gu," ").trim();return e.length<=120?e:`${e.slice(0,119)}\u2026`}a(Un,"oneLine");var fe="shell:",pe="\0pi-terminal-write\0",ge="\0pi-terminal-keys\0";function Hn(t){let e=t?.find(d=>d==="image"||d==="sequence"||d.startsWith("image:")||d.startsWith("sequence:"));if(e===void 0)return;let n=e.indexOf(":"),r=n<0?e:e.slice(0,n),i=new Map;if(n>=0)for(let d of e.slice(n+1).split(",")){let[u,c,m]=d.split("=");if(u===void 0||c===void 0||m!==void 0||c.length===0)throw new Error(`Invalid terminal ${r} view parameter: ${d}`);if(u!=="duration"&&u!=="interval"&&u!=="scale")throw new Error(`Unsupported terminal ${r} view parameter: ${u}`);let f=Number(c);if(!Number.isFinite(f))throw new Error(`Terminal ${u} must be a number`);i.set(u,f)}let s=i.get("duration")??2,o=i.get("interval")??.5,l=i.get("scale")??1;if(!(l>0&&l<=1))throw new Error("Terminal image scale must be greater than 0 and at most 1");if(r==="sequence"){if(!(s>0&&s<=10))throw new Error("Terminal sequence duration must be greater than 0 and at most 10 seconds");if(!(o>0))throw new Error("Terminal sequence interval must be greater than 0 seconds");if(Math.floor(s/o)+1>20)throw new Error("Terminal sequence capture is limited to 20 frames")}return{mode:r,duration:s,interval:o,scale:l}}a(Hn,"parseTerminalVisualView");async function yt(t,e,n=()=>{}){let r=new Set,i=new Map,s=new Map,o={protocol:Se,apiVersion:Te,id:"terminal",setup(d){for(let u of["image","sequence"])d.addView({view:u,contentKind:"any",presenter:{id:`terminal-${u}`,present:a(c=>c,"present")}});d.addResolver({resolver:Gn(e,n),preserveTruncatedOutput:!0,renderResult(u,c,m){let f=u.details;if(f.source===fe)return ft(u,m);let p=f.source===void 0?void 0:e.get(f.source),g=p===void 0?{}:e.snapshot(p);return M(p===void 0?g:{...g,output:e.screenTail(p).join(`
|
|
24
|
+
`)},c.expanded,m,"read terminal")}}),d.addHandler({stage:"pre-read",async handler(u){let c=u.request.path;if(c===void 0||!c.startsWith("shell:"))return{kind:"continue",context:u};let m;try{m=Hn(u.request.views)}catch(p){return{kind:"return",result:ee(c,p instanceof Error?p.message:String(p))}}if(m===void 0)return{kind:"continue",context:u};if(c===fe)return{kind:"return",result:ee(c,"Image and sequence views show one terminal screen. Read shell:<session> with the view; shell: lists sessions as text.")};let f=e.get(c);if(f===void 0)return{kind:"return",result:ee(c,he(c))};try{e.markInspected(c);let p=m.mode==="image"?1:Math.floor(m.duration/m.interval)+1,g=[];for(let S=0;S<p;S+=1){u.resolverContext.signal?.throwIfAborted(),S>0&&await Fn(m.interval*1e3,void 0,{signal:u.resolverContext.signal});let y=await ce(e,c,void 0,m.scale);g.push({type:"image",data:y,mimeType:"image/png"})}return{kind:"return",result:{content:g,script:{kind:"native",source:f.source,blocks:g},details:{source:f.source,resolvedBy:"terminal",frames:p,mode:m.mode}}}}catch(p){return{kind:"return",result:ee(c,p instanceof Error?p.message:String(p))}}}})}},l={protocol:xe,apiVersion:Re,id:"terminal",setup(d){d.addResolver({resolver:jn(e,r)}),d.tool("move").addHandler({stage:"text-pre-edit",handler:a(u=>(E(u.input)&&ye(u.input.path)&&typeof u.input.target=="string"&&u.input.target.startsWith("shell:")&&e.get(u.input.target)===void 0&&r.add(u.input.target),u),"handler")}),d.tool("move").addSemanticHandler({matches:a(u=>E(u)&&typeof u.path=="string"&&u.path.startsWith("shell:"),"matches"),execute(u,c){let m=c,f=String(m.path),p=m.target;try{if(typeof p!="string"||!p.startsWith("shell:")||oe(m))throw new Error(`Terminal sessions support only renaming: move with path ${f} and target shell:<name>.`);let g=e.get(f)?.source??f,S=e.rename(f,p.slice(6));return{source:S.source,summary:g===S.source?`${g} already has this name.`:`Renamed ${g} to ${S.source}.`,data:{kind:"terminal-session",renamed:g!==S.source,from:g,to:S.source}}}finally{typeof p=="string"&&r.delete(p)}}}),d.tool("write").addHandler({stage:"text-pre-edit",handler:a(async u=>(gt(u.input,e,i),await pt(u.input,e,s),qn(u,pe)),"handler")}),d.tool("insert").addHandler({stage:"text-pre-edit",handler:a(async u=>(await pt(u.input,e,s),gt(u.input,e,i),Vn(u)),"handler")});for(let u of["write","insert","delete"])d.addToolRenderer({tool:u,matches:a((c,m)=>Kn(c,m),"matches"),renderCall(c,m,f){let p=c,g=typeof p.path=="string"?e.get(p.path):void 0,S=f.state;return g!==void 0&&(S.snapshot=e.snapshot(g)),qe(S.snapshot??{},u,ht(u,p),[],m)},renderResult(c,m,f){let p=Yn(c.details);return je(p.action,p.changedLines,f)}})}};await Promise.all([be(t,o),ke(t,l)]),t.on("tool_result",async(d,u)=>{if(!E(d.input))return;d.toolName==="move"&&typeof d.input.target=="string"&&r.delete(d.input.target);let c=d.input.path;if(d.toolName==="replace"&&typeof c=="string"&&C(c)){let T=`replace is unsupported for ${c}; use write for text, insert for keys, or delete to terminate and remove the session.`;return G({content:[{type:"text",text:T}],details:d.details},j(d.toolName),{status:"error",errors:[se(T,"UNSUPPORTED_OPERATION",c)],data:{operation:"replace",effect:"not-applied",files:[{source:c,effect:"not-applied"}]}})}if(d.toolName==="delete"&&!oe(d.input)&&typeof c=="string"&&C(c)){let T=e.get(c);if(T===void 0)return;let $=e.snapshot(T);return e.delete(c).then(()=>G({content:[{type:"text",text:`Deleted terminal session ${c}.`}],details:{source:c,deleted:!0,snapshot:$,action:"delete",input:"session",changedLines:[]}},j(d.toolName),{status:"success",errors:[],data:{operation:"delete",effect:"applied",files:[{source:c,effect:"applied"}]}}),R=>G({content:[{type:"text",text:R instanceof Error?R.message:String(R)}],details:{source:c,deleted:!1}},j(d.toolName),{status:"error",errors:[se(R,"TERMINAL_DELETE_FAILED",c)],data:{operation:"delete",effect:"unknown",files:[{source:c,effect:"unknown"}]}}))}if(d.toolName!=="write"&&d.toolName!=="insert"||d.isError)return;let m=d.input.path;if(typeof m!="string"||!C(m))return;let f=e.get(m);if(f===void 0)return;let p=s.get(m)??e.screenRows(f);s.delete(m);let g=i.get(m)??f.outputStart+f.output.length;i.delete(m),await e.waitForOutputAfter(f,g);let S=e.snapshot(f),y=d.toolName,w=ht(y,d.input),b=e.screenChangeRegion(f,p,6),I=[{type:"text",text:`Sent ${w} to ${f.source}.`}];return u.model?.input.includes("image")===!0&&I.push({type:"image",data:await ce(e,m,{start:b.startRow,count:b.lines.length}),mimeType:"image/png"}),{content:I,details:{source:f.source,action:y,status:f.status,snapshot:S,input:w,changedLines:b.lines},isError:d.isError,...d.structuredContent===void 0?{}:{structuredContent:d.structuredContent}}})}a(yt,"registerTerminalResources");function Gn(t,e){return{id:"terminal",async tryResolve(n){if(!n.startsWith("shell:"))return{kind:"not-handled"};if(n===fe)return{kind:"resolved",resource:{source:n,async read(){return[{type:"text",text:mt(t.listOwnedBy(e()))}]}}};let r=t.get(n);return r===void 0?{kind:"failed",error:new Error(he(n))}:{kind:"resolved",resource:{source:r.source,async read(){t.markInspected(r.source);let i=t.snapshot(r);return[{type:"text",text:Xn(i)}]}}}}}}a(Gn,"createReadResolver");function jn(t,e){return{id:"terminal-input",async tryResolve(n){if(!n.startsWith("shell:"))return{kind:"not-handled"};let r=t.get(n);return r===void 0&&e.has(n)?{kind:"resolved",resource:{source:n,skipPostEdit:!0,async read(){return[{type:"text",text:"terminal rename target"}]}}}:r===void 0?{kind:"failed",error:new Error(he(n))}:{kind:"resolved",resource:{source:r.source,skipPostEdit:!0,async read(){return[{type:"text",text:"terminal input"}]},async write(i){let s=zn(i),o=s.indexOf(pe),l=s.indexOf(ge);if(o>=0){await t.write(r.source,s.slice(o+pe.length));return}if(l>=0){await t.sendKeys(r.source,s.slice(l+ge.length).trim());return}throw new Error(`Unsupported text operation for ${r.source}`)}}}}}}a(jn,"createInputResolver");function qn(t,e){return!E(t.input)||!ye(t.input.path)?t:{...t,input:{...t.input,content:`${e}${typeof t.input.content=="string"?t.input.content:""}`}}}a(qn,"transformWriteInput");function Vn(t){if(!E(t.input)||!ye(t.input.path))return t;if(t.input.after!==void 0||t.input.before!==void 0)throw new Error("Omit after and before when sending keys to a terminal session.");return{...t,input:{...t.input,after:"end",text:`${ge}${typeof t.input.text=="string"?t.input.text:""}`}}}a(Vn,"transformInsertInput");function Xn(t){return z(t)}a(Xn,"formatSnapshot");function zn(t){if(t.length!==1||t[0].type!=="text")throw new Error("Terminal input must contain one text block");return t[0].text}a(zn,"singleText");function ee(t,e){return{content:[{type:"text",text:e}],details:{source:t,failure:{code:"READ_FAILED",source:t,resolverId:"terminal",message:e}},isError:!0}}a(ee,"failure");function C(t){return t.startsWith("shell:")&&dt(t.slice(6))}a(C,"isShellSource");function he(t){return`Unknown terminal session ${t}. Read shell: to list your terminal sessions.`}a(he,"unknownSessionMessage");function ye(t){return typeof t=="string"&&C(t)}a(ye,"isShellSourceValue");function Yn(t){if(!E(t)||!E(t.snapshot))throw new TypeError("Invalid terminal action result");let e=t.snapshot,n=t.action;if(n!=="write"&&n!=="insert"&&n!=="delete")throw new TypeError("Invalid terminal action");return{source:typeof t.source=="string"?t.source:"shell:unknown",action:n,input:typeof t.input=="string"?t.input:"",changedLines:Array.isArray(t.changedLines)?t.changedLines.filter(r=>typeof r=="string"):[],snapshot:{...typeof e.name=="string"?{name:e.name}:{},...typeof e.shell=="string"?{shell:e.shell}:{},...typeof e.cwd=="string"?{cwd:e.cwd}:{},...typeof e.command=="string"?{command:e.command}:{},...typeof e.background=="boolean"?{background:e.background}:{},...typeof e.status=="string"?{status:e.status}:{}}}}a(Yn,"terminalActionDetails");async function pt(t,e,n){if(!E(t)||typeof t.path!="string"||!C(t.path))return;let r=e.get(t.path);r!==void 0&&await r.screenReady,r!==void 0&&n.set(t.path,e.screenRows(r))}a(pt,"rememberScreen");function gt(t,e,n){if(!E(t)||typeof t.path!="string"||!C(t.path))return;let r=e.get(t.path);r!==void 0&&n.set(t.path,r.outputStart+r.output.length)}a(gt,"rememberOutputEnd");function ht(t,e){if(t==="delete")return"session";let n=t==="write"?e.content:e.text,r=typeof n=="string"?n:"";return t==="write"?`text ${JSON.stringify(r)}`:`keys ${r}`}a(ht,"terminalInputLabel");function Kn(t,e){if(!E(t))return!1;if(e==="call")return typeof t.path=="string"&&C(t.path);let n=t.details;return E(n)&&typeof n.source=="string"&&C(n.source)}a(Kn,"isTerminalRenderValue");function E(t){return typeof t=="object"&&t!==null}a(E,"isRecord");async function Tt(t,e,n=()=>{}){await Ae(t,{protocol:ve,apiVersion:Pe,id:"terminal",setup(i){i.addResolver({resolver:Zn(e,n),priority:-20})}})}a(Tt,"registerTerminalSearch");function Zn(t,e){return{readResources:a(n=>n.path?.startsWith("shell:")?[n.path]:[],"readResources"),id:"terminal",toScriptData(n){let r=te(n);return Ee(r.matches,r.complete)},async tryResolve(n){if(n.path===void 0||!n.path.startsWith("shell:"))return{kind:"not-handled"};try{bt(n)}catch(o){return{kind:"failed",error:o}}let r;if(n.path==="shell:")r=t.listOwnedBy(e());else{let o=t.get(n.path);if(o===void 0)return{kind:"failed",error:new Error(`Unknown terminal session ${n.path}. Read shell: to list your terminal sessions.`)};r=[t.snapshot(o)]}let i=n.limit??100,s=[];for(let o of r){if(s.length>=i)break;s.push(...Jn(o,{...n,limit:i-s.length}))}return{kind:"resolved",payload:{source:n.path,sessions:r.map(({source:o,status:l})=>({source:o,status:l})),query:n.query,matches:s,complete:!1}}},format(n){let r=te(n),i=r.matches.map(l=>`${l.source}:${l.lineNumber}: ${l.lineText}`),s=r.source==="shell:"?`${r.sessions.length} terminal session${r.sessions.length===1?"":"s"}`:r.source;return{content:[{type:"text",text:r.source==="shell:"&&r.sessions.length===0?"No terminal sessions in this Pi session to search.":i.length===0?`No matches in ${s}`:`${i.join(`
|
|
25
|
+
`)}
|
|
26
|
+
|
|
27
|
+
${i.length} match${i.length===1?"":"es"} in ${s}`}],details:{source:r.source,payload:r}}},renderResult(n,r,i){let s=n.details,o=xt(s)?te(s.payload):te(void 0);return $e(o.matches,!1,i,r.expanded===!0,void 0,[o.source==="shell:"?`Retained terminal output \xB7 ${o.sessions.length} sessions \xB7 read-only`:`Retained terminal output \xB7 ${o.sessions[0]?.status??"unknown"} \xB7 read-only`])}}}a(Zn,"terminalSearchResolver");var wt="regex:";function bt(t){if(t.query.startsWith(wt)){let n=t.query.slice(wt.length);if(n.length===0)return()=>[];let r=new RegExp(n,t.caseSensitive===!0?"gu":"giu");return function*(i){for(let s of i.matchAll(r)){let o=s.index+s[0].length;s[0].length>0&&(t.wholeWord!==!0||St(i,s.index,o))&&(yield[s.index,o])}}}let e=t.caseSensitive===!0?t.query:t.query.toLocaleLowerCase();return e.length===0?()=>[]:function*(n){let r=t.caseSensitive===!0?n:n.toLocaleLowerCase(),i=0;for(;;){let s=r.indexOf(e,i);if(s<0)return;let o=s+e.length;(t.wholeWord!==!0||St(r,s,o))&&(yield[s,o]),i=Math.max(o,s+1)}}}a(bt,"terminalMatcher");function Jn(t,e){let n=bt(e),r=[],i=e.limit??100;for(let[s,o]of t.output.replaceAll("\r","").split(`
|
|
28
|
+
`).entries()){for(let[l,d]of n(o)){if(r.length>=i)return r;r.push({source:t.source,lineNumber:s+1,startColumn:l,endColumn:d,matchedText:o.slice(l,d),lineText:o})}if(r.length>=i)break}return r}a(Jn,"findTerminalMatches");function St(t,e,n){return!/[\p{L}\p{N}_]/u.test(t[e-1]??"")&&!/[\p{L}\p{N}_]/u.test(t[n]??"")}a(St,"isWordBoundary");function te(t){if(!Qn(t))throw new TypeError("Invalid terminal search result");return t}a(te,"parsePayload");function Qn(t){return xt(t)&&typeof t.source=="string"&&typeof t.query=="string"&&Array.isArray(t.matches)&&Array.isArray(t.sessions)}a(Qn,"isTerminalSearchPayload");function xt(t){return typeof t=="object"&&t!==null}a(xt,"isRecord");import{AgentSession as er}from"@earendil-works/pi-coding-agent";var ne=Symbol.for("pi-agent-ide.terminal-steering-observers");function Rt(t){let e=er.prototype,n=e[ne]??tr(e);return n.listeners.add(t),()=>{n.listeners.delete(t),n.listeners.size===0&&n.restore()}}a(Rt,"observeQueuedSteering");function tr(t){let e=t.prompt,n=t.steer,r=new Set,i=a(d=>{for(let u of[...r])u(d)},"notify"),s=a(function(d,u){return u?.streamingBehavior!=="steer"?e.call(this,d,u):e.call(this,d,{...u,preflightResult:a(c=>{u.preflightResult?.(c),c==="queued"&&i(this)},"preflightResult")})},"prompt"),o=a(async function(...d){let u=await n.apply(this,d);return u==="queued"&&i(this),u},"steer");t.prompt=s,t.steer=o;let l={listeners:r,restore:a(()=>{t[ne]===l&&(t.prompt===s&&(t.prompt=e),t.steer===o&&(t.steer=n),delete t[ne])},"restore")};return t[ne]=l,l}a(tr,"installObservers");import $t from"node:path";import{stripVTControlCharacters as rr}from"node:util";import{defineTool as ir}from"@earendil-works/pi-coding-agent";import{Type as x}from"typebox";import{Container as sr,Text as we}from"@earendil-works/pi-tui";import{open as nr}from"node:fs/promises";import{Type as h}from"typebox";var vt=1024*1024,Pt=h.Object({output:h.String({description:"ANSI-free PTY output, up to 1 MiB. Longer output joins the first and last 512 KiB without adding labels or an omission marker. See output_ranges for the gap."}),truncated:h.Boolean({description:"Whether output omits bytes from the retained log. This is independent of whether the process has finished."}),full_output_path:h.String({description:"UTF-8 log of all output received so far. Available until the shell session is deleted."}),output_ranges:h.Array(h.Object({start:h.Integer(),end:h.Integer()}),{description:"Zero-based, end-exclusive UTF-8 byte ranges in the log, concatenated into output."}),exit_code:h.Optional(h.Number({description:"Process exit code, only when known."})),wall_time_seconds:h.Number(),session:h.String({description:"Session name, or its generated ID when it has none."}),source:h.String({description:"Persistent shell: source for Read, input and termination."}),notice:h.Optional(h.String({description:"Why the requested session name was not applied."})),status:h.Union(["running","completed","failed","stopping","stopped","cancelled","lost"].map(t=>h.Literal(t))),background:h.Boolean(),cwd:h.String({description:"Actual working directory; SSH sessions retain their canonical ssh:// target URI."}),remote:h.Optional(h.Object({target:h.String(),pid:h.Integer({minimum:1})},{description:"Remote process identity, never a local native PID."})),wait_reason:h.Optional(h.Union([h.Literal("timeout"),h.Literal("interactive"),h.Literal("steering")])),completion_reason:h.Optional(h.Literal("timeout")),signal:h.Optional(h.Number()),error:h.Optional(h.String())});async function Et(t){let e=await nr(t.fullOutputPath,"r");try{let n=(await e.stat()).size,r=a(async(l,d)=>{let u=Buffer.alloc(d),c=0;for(;c<d;){let m=await e.read(u,c,d-c,l+c);if(m.bytesRead===0)throw new Error("Shell output log ended before its snapshot size");c+=m.bytesRead}return u},"readRange"),i,s,o=n>vt;if(!o)i=(await r(0,n)).toString("utf8"),s=[{start:0,end:n}];else{let l=vt/2,d=await r(0,l),u=await r(n-l,l),c=new TextDecoder().decode(d,{stream:!0}),m=0;for(;m<u.length&&(u.readUInt8(m)&192)===128;)m++;let f=u.subarray(m).toString("utf8");i=c+f,s=[{start:0,end:Buffer.byteLength(c)},{start:n-l+m,end:n}]}return{output:i,truncated:o,full_output_path:t.fullOutputPath,output_ranges:s,...t.exitCode===void 0?{}:{exit_code:t.exitCode},wall_time_seconds:t.elapsedMs/1e3,session:t.name??t.id,source:t.source,status:t.status,background:t.background,cwd:t.cwd,...t.remote===void 0?{}:{remote:t.remote},...t.waitReason===void 0?{}:{wait_reason:t.waitReason},...t.completionReason===void 0?{}:{completion_reason:t.completionReason},...t.signal===void 0?{}:{signal:t.signal},...t.error===void 0?{}:{error:t.error}}}finally{await e.close()}}a(Et,"structuredShellResult");var _={linux:"Linux",windows:"Windows"},At=a(t=>t==="windows"?"remote_powershell":"remote_bash","remoteToolName");function or(t){t.registerTool({name:"bash",label:"bash",description:"",exposure:"hidden",parameters:x.Object({},{additionalProperties:!1}),execute(){throw new Error("Hidden bash must never execute.")}})}a(or,"hideBuiltinBash");var ar=a((t,e)=>x.Object({command:x.String({minLength:1,description:`Command for ${t.displayName} (${t.executable}). ${et(t)}`}),name:x.Optional(x.String({description:"Session name that becomes its address: dev-server gives shell:dev-server. Use 1 to 48 letters, digits, '.', '_' or '-', starting with a letter or digit, and a name no other session uses. Defaults to a generated ID."})),background:x.Optional(x.Boolean({description:"Set true to return after an initial output preview instead of waiting for completion. Defaults to false."})),timeoutSeconds:x.Optional(x.Number({minimum:.1,maximum:86400,description:"Set the foreground wait limit in seconds. On expiry, the live session returns in background without stopping the process. Ignored when background is true. Defaults to 60."})),cwd:x.Optional(x.String({description:e.remoteOnly?`Working directory on a ${_[e.targetOs]} SSH target: ssh://<target>/${e.targetOs==="windows"?"C:/path":"absolute/path"}.`:"Working directory. Relative paths resolve from the current workspace."})),cols:x.Optional(x.Integer({minimum:20,maximum:300,description:"Virtual terminal width in cells"})),rows:x.Optional(x.Integer({minimum:5,maximum:120,description:"Virtual terminal height in cells"}))},{additionalProperties:!1}),"createRunParameters");function lr(t,e,n){if(e===void 0){if(t.remoteOnly)throw new Error(`${t.name} runs only on remote targets. Pass cwd as an ssh:// directory of a ${_[t.targetOs]} target.`);return}let r=q(e.backend.target);if(r===t.targetOs)return;let i=r===n?n==="windows"?"powershell":"bash":At(r);throw new Error(`${e.location.source} is on a ${_[r]} target. Use ${i} for it; ${t.name} accepts ${_[t.targetOs]} targets.`)}a(lr,"assertScope");function kt(t,e,n,r,i="compact",s=new V([]),o,l=process.platform){let d=l==="win32"?"windows":"linux",u=new Set;m({name:d==="windows"?"powershell":"bash",targetOs:d,remoteOnly:!1},n),d==="windows"&&or(t);let c=d==="windows"?"linux":"windows";s.hasTargetOs(c)&&m({name:At(c),targetOs:c,remoteOnly:!0},B(c));function m(f,p){let g=f.name,S=ar(p,f);f.remoteOnly&&S.required.push("cwd"),t.registerTool(ir({name:g,exposure:"direct",namespace:{name:"ide_terminal",description:"Run shell commands in persistent terminal sessions."},annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},label:p.displayName,promptSnippet:f.remoteOnly?`Execute ${p.displayName} commands on ${_[f.targetOs]} SSH targets`:`Execute ${p.displayName} commands in synchronous or background terminal sessions`,promptGuidelines:[`Edit files with the edit tools, not ${g}.`],description:f.remoteOnly?`Use ${g} to execute a command in ${p.displayName} on a configured ${_[f.targetOs]} SSH target. It runs only on remote targets; use ${d==="windows"?"powershell":"bash"} for local commands and ${_[d]} targets. Each call creates a new terminal session and returns its shell: source for inspection and interaction.`:`Use ${g} to execute a command in the user's configured shell. Each call creates a new terminal session and returns its shell: source for inspection and interaction.`,parameters:S,outputSchema:Pt,async execute(y,w,b,I,T){r.bind(T);let $=o?.(y,T),R=s.resolve(w.cwd??T.cwd,T.cwd);lr(f,R,d);let v=w.name===""?void 0:w.name,ie=v===void 0?void 0:e.nameProblem(v),F={command:w.command,...v===void 0||ie!==void 0?{}:{name:v},background:w.background??!1,...w.cols===void 0?{}:{cols:w.cols},...w.rows===void 0?{}:{rows:w.rows}},P=R?await e.startRemote({...F,remote:R,...b===void 0?{}:{signal:b}}):e.start({...F,cwd:w.cwd===void 0?T.cwd:$t.resolve(T.cwd,w.cwd),shell:p});P.origin??=$;let Ft=v===void 0||P.name===v?void 0:{name:v,reason:ie??e.nameProblem(v)??`shell:${v} is already used by another session.`},H=a(Ht=>dr(Ht,Ft),"terminalResult");if(w.background===!0&&P.status!=="failed")return await ur(e,P,I),P.status!=="running"&&(P.completionDelivered=!0),H(e.snapshot(P));if(P.status==="failed")return H(e.snapshot(P));let D=new AbortController;u.add(D);let O;try{O=await e.waitForForeground(P.source,{signal:b===void 0?D.signal:AbortSignal.any([b,D.signal]),timeoutMs:(w.timeoutSeconds??60)*1e3})}finally{u.delete(D)}return O.reason==="aborted"&&D.signal.aborted&&b?.aborted!==!0?(O.session.waitReason="steering",H(e.snapshot(O.session))):(O.reason==="aborted"&&r.notifyWaitTransition(O.session),H(e.snapshot(O.session)))},renderCall(y,w,b){if((b.expanded?"full":typeof i=="function"?i():i)==="disabled")return new we(w.fg("toolTitle",g),0,0);let T=typeof y.command=="string"?y.command:"",$=typeof y.cwd=="string"&&y.cwd.startsWith("ssh:"),R=typeof y.cwd=="string"?$?y.cwd:$t.resolve(process.cwd(),y.cwd):process.cwd();return Ge(T,y.background===!0,R,$?B(f.targetOs):p,w,typeof y.name=="string"?y.name:void 0)},renderResult(y,w,b,I){let T=y.details;if(I.isError&&T?.status===void 0){let F=y.content.find(P=>P.type==="text")?.text.split(`
|
|
29
|
+
|
|
30
|
+
`)[0]??"Command was not started.";return new we(b.fg("error",F),0,0)}let $=Ve(T??{},w.expanded?"full":typeof i=="function"?i():i,b),R=y.details?.nameRejection;if(R===void 0)return $;let v=new sr;return v.addChild(new we(b.fg("warning",`! name ${R.name} not applied: ${R.reason}`),0,0)),v.addChild($),v}}))}return a(m,"registerShellTool"),()=>{for(let f of u)f.abort()}}a(kt,"registerTerminalTools");function Ct(t,e){return`Name ${t.name} was not applied: ${t.reason} The session runs as ${e}. Rename it with move, path ${e} and target shell:<name>, using a valid name no other session uses.`}a(Ct,"nameRejectionNotice");function It(t,e){let n=N(t.output).content,r=z(t),i=e===void 0?void 0:Ct(e,t.source);return{content:[{type:"text",text:i===void 0?r:`${i}
|
|
31
|
+
|
|
32
|
+
${r}`}],details:{...t,output:n,outputStart:t.outputEnd-n.length,truncated:t.truncated||n.length<t.output.length,...e===void 0?{}:{nameRejection:e}},isError:t.status==="failed"||t.status==="lost"}}a(It,"terminalPreview");async function dr(t,e){return{...It(t,e),structuredContent:{...await Et(t),...e===void 0?{}:{notice:Ct(e,t.source)}}}}a(dr,"shellToolResult");async function ur(t,e,n){await new Promise(r=>{let i=!1,s,o=a(()=>{},"unsubscribe"),l=a(()=>{i||(i=!0,clearTimeout(s),o(),r())},"finish"),d=a(()=>{let u=t.snapshot(e);n?.(It(u)),(rr(u.output).replaceAll("\r","").split(`
|
|
33
|
+
`).filter(m=>m.length>0).length>=L||u.status!=="running")&&l()},"publish");o=t.onDidChange(u=>{u.id===e.id&&d()}),s=setTimeout(l,2e3),d()})}a(ur,"captureInitialBackgroundPreview");import{Box as _t,Container as Lt}from"@earendil-works/pi-tui";var cr=120,mr=12e4,re=class{constructor(e,n,r=mr){this.pi=e;this.manager=n;this.staleIntervalMs=r;e.registerMessageRenderer("terminal-stale",(i,{expanded:s},o)=>Ot(i.details,s,o)),e.registerMessageRenderer("terminal-completion",(i,{expanded:s},o)=>Mt(i.details,s,o)),e.registerEntryRenderer("terminal-stale-display",(i,{expanded:s},o)=>Ot(i.data,s,o)),e.registerEntryRenderer("terminal-completion-display",(i,{expanded:s},o)=>Mt(i.data,s,o)),this.#u=[n.onDidChange(i=>this.#d(i)),n.onDidComplete(i=>{this.#l(i.id),i.background&&this.#i(i)})]}static{a(this,"TerminalUi")}#r=new Map;#e;#t=new Map;#n=new Set;#s;#o=!1;#u;bind(e){this.#s=e;for(let n of this.manager.list()){let r=this.manager.getById(n.id);r===void 0||!r.background||(r.status==="running"?this.#d(r):r.status!=="stopping"&&this.#i(r))}}onAgentSettled(e){this.#s=e;for(let n of[...this.#n]){this.#n.delete(n);let r=this.manager.getById(n);r!==void 0&&this.#d(r,!0)}}notifyWaitTransition(e){let n=this.#c(e);this.pi.sendMessage({customType:"terminal-wait-transition",display:!1,content:`Terminal wait ended; ${n.source} is still running in background. Read it to inspect output, then use write or insert to send input.`,details:n},{triggerTurn:!0,deliverAs:"steer"})}dispose(){this.#o=!0,this.#e!==void 0&&clearTimeout(this.#e),this.#e=void 0,this.#r.clear();for(let e of this.#t.values())clearTimeout(e);this.#t.clear(),this.#n.clear(),this.#s=void 0;for(let e of this.#u)e()}#d(e,n=!1){if(this.#l(e.id),this.#o||e.staleReminderDelivered||!e.background||e.status!=="running")return;let r=this.#c(e),i=Math.max(0,this.staleIntervalMs-r.idleMs);if(n&&i===0){this.#a(e);return}this.#t.set(e.id,setTimeout(()=>this.#a(e),i))}#a(e){if(this.#t.delete(e.id),this.#o||e.staleReminderDelivered||e.status!=="running"||!e.background)return;if(this.#s?.isIdle()!==!0){this.#n.add(e.id);return}e.staleReminderDelivered=!0;let n=this.#c(e);this.pi.sendMessage({customType:"terminal-stale",display:!1,content:gr(n),details:n},{triggerTurn:!0,deliverAs:"followUp"}),this.pi.appendEntry("terminal-stale-display",{...n,...this.#m(n)})}#c(e){return He({...this.manager.snapshot(e),...e.origin===void 0?{}:{origin:e.origin}})}#m(e){let n=e.origin;return n!==void 0&&n.sessionId===this.#s?.sessionManager.getSessionId()?{parentToolCallId:n.parentToolCallId}:{}}#l(e){let n=this.#t.get(e);n!==void 0&&clearTimeout(n),this.#t.delete(e),this.#n.delete(e)}#i(e){this.#o||e.completionDelivered||(this.#r.set(e.id,e),this.#e===void 0&&(this.#e=setTimeout(()=>{this.#e=void 0;let n=[...this.#r.values()].filter(s=>!s.completionDelivered);if(this.#r.clear(),this.#o||n.length===0)return;for(let s of n)s.completionDelivered=!0;let r=n.map(s=>this.#c(s));this.pi.sendMessage({customType:"terminal-completion",display:!1,content:pr(r),details:{sessions:r}},{triggerTurn:!0,deliverAs:"steer"});let i=new Map;for(let s of r){let o=this.#m(s).parentToolCallId,l=i.get(o)??[];l.push(s),i.set(o,l)}for(let[s,o]of i)this.pi.appendEntry("terminal-completion-display",{sessions:o,...s===void 0?{}:{parentToolCallId:s}})},cr)))}};function Ot(t,e,n){let r=new Lt;Dt(t)&&r.addChild(M(t,e,n,"stale \xB7 inspect session"));let i=new _t(1,1,s=>n.bg("toolPendingBg",s));return i.addChild(r),i}a(Ot,"renderStale");function Mt(t,e,n){let r=new Lt;for(let s of fr(t))r.addChild(M(s,e,n));let i=new _t(1,1,s=>n.bg("toolSuccessBg",s));return i.addChild(r),i}a(Mt,"renderCompletion");function fr(t){return!Wt(t)||!Array.isArray(t.sessions)?[]:t.sessions.filter(Dt)}a(fr,"completionSnapshots");function Dt(t){return Wt(t)&&typeof t.id=="string"&&typeof t.source=="string"&&typeof t.command=="string"&&typeof t.cwd=="string"&&typeof t.shell=="string"&&typeof t.background=="boolean"&&typeof t.status=="string"&&typeof t.startedAt=="number"&&typeof t.elapsedMs=="number"&&typeof t.output=="string"}a(Dt,"isTerminalSessionSnapshot");function pr(t){return`${t.length===1?"Background terminal completed:":"Background terminals completed:"}
|
|
34
|
+
${t.map(n=>{let r=n.exitCode===void 0?"":`, exit ${n.exitCode}`,i=n.completionReason===void 0?"":`, reason ${n.completionReason}`,s=n.output.trimEnd().slice(-X);return`- ${n.source}: ${n.status}${r}${i}, ${Nt(n.elapsedMs)}
|
|
35
|
+
${s||"(no output)"}`}).join(`
|
|
36
|
+
`)}`}a(pr,"formatCompletionMessage");function gr(t){let e=t.output.trimEnd().slice(-X);return`Background terminal ${t.source} has produced no output for ${Nt(t.idleMs)}. Inspect it with read. If it is healthy, keep waiting; otherwise send input or stop it.
|
|
37
|
+
${e||"(no output)"}`}a(gr,"formatStaleMessage");function Nt(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(t<1e4?1:0)}s`}a(Nt,"formatElapsed");function Wt(t){return typeof t=="object"&&t!==null}a(Wt,"isRecord");function Bt(t){let e=new Map;return t.on("tool_call",n=>{let r=n.parentToolCallId;e.set(n.toolCallId,r===void 0?n.toolCallId:e.get(r)??r)}),t.on("tool_result",n=>{e.delete(n.toolCallId)}),t.on("agent_end",()=>{e.clear()}),t.on("session_shutdown",()=>{e.clear()}),(n,r)=>({toolCallId:n,parentToolCallId:e.get(n)??n,sessionId:r.sessionManager.getSessionId()})}a(Bt,"registerTerminalOrigins");function Ut(t){return t==="full"||t==="disabled"?t:"compact"}a(Ut,"toolPresentation");async function hr(t,e){Ie(t,[await Ce({id:"terminal",description:"Foreground and background commands, shell resources, and processes",triggers:[{tool:"bash"},{tool:"powershell"},{tool:"remote_bash"},{tool:"remote_powershell"},...["read","search","write","insert","delete","move"].map(p=>({tool:p,resourcePrefixes:["shell:"]}))]})]);let n=We("terminal",U)??new U,r=Qe(),i=new V(await Le(_e(Me()))),s=new re(t,n),o=De(t).add(Ye(n)),l,d=a(()=>l,"currentSessionId");t.on("session_start",(p,g)=>{l=g.sessionManager.getSessionId()}),await Promise.all([yt(t,n,d),Tt(t,n,d)]);let c=kt(t,n,r,s,a(()=>Ut(e?.preferences["ui.terminal"]),"presentation"),i,Bt(t)),m="For shell:<session> resources, write sends exact terminal input, insert sends named keys at end, and delete terminates and removes the session. replace is unsupported.";Oe(t,{version:1,id:"terminal",tools:["bash","powershell","remote_bash","remote_powershell"],schemas:{read:{parameters:{path:"shell: \u2014 terminal sessions started in this Pi session; shell:<session> \u2014 status and output tail.",views:"On shell:<session>: image[:scale=S] \u2014 screen image; sequence[:duration=D,interval=I,scale=S] \u2014 frames over time. Duration and interval are in seconds (defaults: 2 and 0.5); up to 10 s and 20 frames."}},search:{promptGuidelines:["path shell:<session> searches the retained text output of that terminal, including rows outside its current screen; path shell: searches every terminal session of this Pi session."]},write:{parameters:{path:"shell:<session> types into that terminal.",content:"For shell:<session>, exact input; Enter is not added."},promptGuidelines:[m]},insert:{parameters:{path:"shell:<session> sends keys to that terminal.",after:"Omit both after and before for shell:<session>.",text:"For shell:<session>: named keys and chords such as Enter, Ctrl+C, Up, or caret forms such as ^C, separated by spaces or commas."},promptGuidelines:[m]},delete:{parameters:{path:"shell:<session> ends that session."},promptGuidelines:[m]},move:{parameters:{path:"shell:<session> with target shell:<name> renames that terminal session."}}}});let f=a(()=>{},"removeSteeringObserver");t.on("session_start",(p,g)=>{s.bind(g),f(),f=Rt(S=>{S.sessionManager===g.sessionManager&&c()})}),t.on("agent_settled",(p,g)=>s.onAgentSettled(g)),t.on("session_shutdown",async p=>{if(f(),s.dispose(),o(),p.reason!=="quit"){Ne("terminal",n);return}Be("terminal",n),await n.dispose()})}a(hr,"registerTerminal");export{hr as default};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import{a as y,b as k,d as b}from"./chunk-ASVMQMPX.js";import{b as T}from"./chunk-72WO7H5T.js";import{a as j}from"./chunk-QR7JR3P2.js";import{C as W,E as N,F as _,G as $,m as q,t as P}from"./chunk-IRLWXPL4.js";import{a as l}from"./chunk-EI7MMDWY.js";var L=class{constructor(e,n){this.source=e;this.content=n}static{l(this,"AnchoredLiteralView")}view;viewWithBom;*matchers(e,n){let r=e.replace(/\r?\n$/u,""),a=`
|
|
2
|
+
${W}`,s=r.endsWith(a);if(s&&this.content.endsWith(`
|
|
3
|
+
`))return;let o=r.slice(0,-a.length),i=s?o.replace(/\r$/u,""):e;if(!i.includes("|")&&!/\n[0-9A-HJKMNP-TV-Z]{1,7}\s*$/u.test(i))return;let c=y(i).text.includes("\uFEFF")?this.viewWithBom??=I(this.source,this.content,!0):this.view??=I(this.source,this.content,!1),u=k(y(i).text).split(`
|
|
4
|
+
`);for(let g of n)yield(f,h)=>{let m=[];return g.find(c.text,i,p=>{let x=c.toSource(p,u);return x===void 0||s&&x.to!==this.content.length||!f(x)?!1:(m.push(x),!0)},h),m}}};function I(t,e,n){let{lines:r}=q(t,e),a=P(r),s=(a[0]?.length??0)+1,o=n?0:y(e).bom.length,i=[],d=0,c=r.map((f,h)=>{i.push(d);let m=`${a[h]}|${f.content.slice(h===0?o:0)}${f.lineEnding}`;return d+=m.length,m}).join("");function u(f){let h=0,m=i.length-1;for(;h<m;){let p=h+m+1>>>1;(i[p]??1/0)<=f?h=p:m=p-1}return h}l(u,"rowAt");function g(f,h){return Math.max(f,(i[h]??0)+s)-(h+1)*s+o}return l(g,"sourceOffset"),{text:c,toSource(f,h){let m=u(f.from),p=u(f.to),x=!1,E=0;for(let S=m;S<=p;S++){let F=i[S]??0,A=Math.max(F,f.from),B=Math.min(F+s,f.to);if(A<B){if(!h[E]?.startsWith(c.slice(A,B)))return;x=!0}let v=i[S+1];v!==void 0&&v<f.to&&(E+=k(c.slice(A,v)).split(`
|
|
5
|
+
`).length-1)}if(!x)return;let C=g(f.from,m),O=g(f.to,p);return C<O?{from:C,to:O}:void 0}}}l(I,"createView");var ne={find(t,e,n,r){return M(t,e,a=>{let s=a+e.length;return{from:t[a]===`
|
|
6
|
+
`&&t[a-1]==="\r"?a-1:a,to:t[s-1]==="\r"&&t[s]===`
|
|
7
|
+
`?s+1:s}},n,r)}},te={find(t,e,n,r){let{bom:a,text:s}=y(t),o=k(y(e).text),i=k(s);if(o.length===0||a===""&&i===s&&o===e)return[];let d=G(s,a.length);return M(i,o,c=>({from:d(c),to:d(c+o.length)}),n,r)}},re={find(t,e,n,r){let a=b(k(y(e).text));if(a.length===0)return[];let{bom:s,text:o}=y(t),i=k(o),d=b(i);if(!d.includes(a))return[];let c=oe(i,d);if(c===void 0)return[];let u=G(o,s.length);return M(d,a,g=>{let f=g+a.length,h=c(g),m=c(f-1);if(h===void 0||m===void 0)return;let p=g>0&&c(g-1)?.from===h.from,x=f<d.length&&c(f)?.from===m.from;return p||x?void 0:{from:u(h.from),to:u(m.to)}},n,r)}},V=[ne,te,re];function w(t,e,n,r=()=>!0,a){for(let s of K(t,e,n)){if(a===void 0){let[g,f]=s(r,2);if(f!==void 0)return{kind:"ambiguous"};if(g!==void 0)return{kind:"unique",span:g};continue}let o=[],[i,d]=s(g=>r(g)?g.from>=a?!0:(o.length<2&&o.push(g),!1):!1,2);if(d!==void 0)return{kind:"ambiguous"};if(i!==void 0)return{kind:"unique",span:i};let[c,u]=o;if(u!==void 0)return{kind:"before-start"};if(c!==void 0)return{kind:"unique",span:c}}return{kind:"missing"}}l(w,"matchLiteral");function U(t,e,n,r=()=>!0){for(let a of K(t,e,n)){let s=a(r,Number.MAX_SAFE_INTEGER);if(s.length>0)return s}return[]}l(U,"literalCandidates");function*K(t,e,n){if(e.length!==0){for(let r of V)yield(a,s)=>r.find(t,e,a,s);yield*n.matchers(e,V)}}l(K,"matchers");function M(t,e,n,r,a){let s=[];if(e.length===0)return s;for(let o=t.indexOf(e);o!==-1&&s.length<a;o=t.indexOf(e,o+1)){let i=n(o);i!==void 0&&r(i)&&s.push(i)}return s}l(M,"scan");function G(t,e){let n=[];for(let r=t.indexOf(`\r
|
|
8
|
+
`);r!==-1;r=t.indexOf(`\r
|
|
9
|
+
`,r+2))n.push(r-n.length);return r=>{let a=0,s=n.length;for(;a<s;){let o=a+s>>>1;(n[o]??1/0)<r?a=o+1:s=o}return e+r+a}}l(G,"sourceOffsets");function oe(t,e){let n=H(t),r=H(e);if(n.length!==r.length)return;let a=new Map;return s=>{let o=0,i=r.length-1;for(;o<i;){let h=o+i+1>>>1;(r[h]??0)<=s?o=h:i=h-1}let d=n[o]??0,c=(n[o+1]??t.length+1)-1,u=r[o]??0,g=(r[o+1]??e.length+1)-1;if(s===g)return{from:c,to:c+1};if(!a.has(o)){let h=se(t.slice(d,c));a.set(o,h?.text===e.slice(u,g)?h:void 0)}let f=a.get(o)?.unitAt(s-u);return f===void 0?void 0:{from:d+f.from,to:d+f.to}}}l(oe,"fuzzyUnits");function H(t){let e=[0];for(let n=t.indexOf(`
|
|
10
|
+
`);n!==-1;n=t.indexOf(`
|
|
11
|
+
`,n+1))e.push(n+1);return e}l(H,"lineStarts");var ie=/^[\0-\u02FF\u2002-\u200A\u2010-\u2015\u2018-\u201F\u202F\u205F\u2212\u3000]*$/u;function se(t){if(ie.test(t)&&t.normalize("NFKC").length===t.length){let o=b(t);return{text:o,unitAt:l(i=>i<o.length?{from:i,to:i+1}:void 0,"unitAt")}}let e=[],n=[],r=[];for(let o=0;o<t.length;){let i=o+D(t,o);for(;i<t.length&&!ae(t,i);)i+=D(t,i);let d=t.slice(o,i).normalize("NFKC");for(let c of d.split(""))e.push(c),n.push(o),r.push(i);o=i}let a=e.join("").trimEnd(),s=b(a);if(s.length===a.length)return{text:s,unitAt:l(o=>{let i=n[o],d=r[o];return o>=s.length||i===void 0||d===void 0?void 0:{from:i,to:d}},"unitAt")}}l(se,"fuzzyLine");function D(t,e){return(t.codePointAt(e)??0)>65535?2:1}l(D,"codePointLength");function ae(t,e){let n=t.codePointAt(e)??0;return n<768?!0:!(new RegExp("\\p{M}","u").test(String.fromCodePoint(n))||n>=4448&&n<=4607||n>=55216&&n<=55295||n===12441||n===12442||n===65438||n===65439)}l(ae,"startsCharacter");import{Worker as ce}from"node:worker_threads";var Z=String.raw`
|
|
12
|
+
const { parentPort, workerData } = require("node:worker_threads");
|
|
13
|
+
let fuzzy;
|
|
14
|
+
let prepared;
|
|
15
|
+
|
|
16
|
+
function normalizeLine(value) {
|
|
17
|
+
// Guidance only: a CRLF source line keeps its CR, which must not lower the score.
|
|
18
|
+
return value.replace(/[\t \r]+$/u, "");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function normalizeLines(value) {
|
|
22
|
+
const lines = value.replace(/\r\n|\r/gu, "\n").split("\n").map(normalizeLine);
|
|
23
|
+
const indents = lines
|
|
24
|
+
.filter((line) => line.trim().length > 0)
|
|
25
|
+
.map((line) => /^\s*/u.exec(line)[0].length);
|
|
26
|
+
const commonIndent = indents.length === 0 ? 0 : Math.min(...indents);
|
|
27
|
+
return lines.map((line) => line.slice(Math.min(commonIndent, line.length)));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const fuzzyOptions = {
|
|
31
|
+
ignoreCase: true,
|
|
32
|
+
ignoreSymbols: false,
|
|
33
|
+
normalizeWhitespace: false,
|
|
34
|
+
useDamerau: true,
|
|
35
|
+
useSellers: true,
|
|
36
|
+
useSeparatedUnicode: false,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
async function prepare() {
|
|
40
|
+
({ fuzzy } = await import(workerData.moduleUrl));
|
|
41
|
+
const queryLines = normalizeLines(workerData.value);
|
|
42
|
+
const seeds = queryLines
|
|
43
|
+
.map((text, index) => ({ text, index, weight: text.replace(/\s/gu, "").length }))
|
|
44
|
+
.filter(({ weight }) => weight > 0)
|
|
45
|
+
.sort((left, right) => right.weight - left.weight || left.index - right.index)
|
|
46
|
+
.slice(0, workerData.config.seedLimit);
|
|
47
|
+
prepared = { queryLines, seeds };
|
|
48
|
+
parentPort.postMessage({ kind: "ready" });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function search() {
|
|
52
|
+
const { queryLines, seeds } = prepared;
|
|
53
|
+
const sourceLines = workerData.sourceLines;
|
|
54
|
+
const config = workerData.config;
|
|
55
|
+
const starts = new Set();
|
|
56
|
+
for (const seed of seeds) {
|
|
57
|
+
const scoredLines = sourceLines
|
|
58
|
+
.map((line, index) => ({ index, score: fuzzy(seed.text, normalizeLine(line), fuzzyOptions) }))
|
|
59
|
+
.filter(({ score }) => score >= config.threshold)
|
|
60
|
+
.sort((left, right) => right.score - left.score || left.index - right.index)
|
|
61
|
+
.slice(0, config.fuzzyCandidateLimit * 4);
|
|
62
|
+
for (const line of scoredLines) {
|
|
63
|
+
starts.add(Math.max(0, line.index - seed.index));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const query = queryLines.join("\n");
|
|
68
|
+
const searchBlocks = (varianceLimit, options) => {
|
|
69
|
+
const ranked = [];
|
|
70
|
+
for (const start of starts) {
|
|
71
|
+
for (let variance = -varianceLimit; variance <= varianceLimit; variance += 1) {
|
|
72
|
+
const length = queryLines.length + variance;
|
|
73
|
+
if (length < 1 || start + length > sourceLines.length) continue;
|
|
74
|
+
const end = start + length;
|
|
75
|
+
const block = normalizeLines(sourceLines.slice(start, end).join("\n")).join("\n");
|
|
76
|
+
const score = fuzzy(query, block, options);
|
|
77
|
+
if (score >= config.threshold) ranked.push({ startLine: start + 1, endLine: end, score });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return ranked;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
let ranked = searchBlocks(config.blockLineVariance, fuzzyOptions);
|
|
84
|
+
if (ranked.length === 0) {
|
|
85
|
+
const fallbackVariance = Math.max(
|
|
86
|
+
config.blockLineVariance,
|
|
87
|
+
Math.min(10, Math.ceil(queryLines.length * 0.75)),
|
|
88
|
+
);
|
|
89
|
+
ranked = searchBlocks(fallbackVariance, { ...fuzzyOptions, normalizeWhitespace: true });
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const bestByRange = new Map();
|
|
93
|
+
for (const block of ranked) {
|
|
94
|
+
const key = block.startLine + ":" + block.endLine;
|
|
95
|
+
const current = bestByRange.get(key);
|
|
96
|
+
if (current === undefined || block.score > current.score) bestByRange.set(key, block);
|
|
97
|
+
}
|
|
98
|
+
const blocks = [...bestByRange.values()]
|
|
99
|
+
.sort((left, right) => right.score - left.score || left.startLine - right.startLine)
|
|
100
|
+
.slice(0, config.fuzzyCandidateLimit);
|
|
101
|
+
parentPort.postMessage({ kind: "result", blocks });
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
parentPort.once("message", (message) => {
|
|
105
|
+
if (message === "search") search();
|
|
106
|
+
});
|
|
107
|
+
prepare().catch((error) => {
|
|
108
|
+
parentPort.postMessage({ kind: "failed", message: error instanceof Error ? error.message : String(error) });
|
|
109
|
+
});
|
|
110
|
+
`;async function J(t,e,n){if(e.rejection.code==="ambiguous"){let s=Y(t,e,n.exactCandidateLimit);return{kind:"candidates",total:s.total,candidates:s.ranges.map((o,i)=>({rank:i+1,range:o})),...s.allMatches!==void 0&&{allMatches:s.allMatches}}}if(e.rejection.code!=="missing"||!de(t,e.content,n))return{kind:"unavailable"};if(e.signal!==void 0&&e.signal.aborted)return{kind:"failed",error:e.signal.reason};let r=await le(t,e.lines,n,e.signal);if(r.kind!=="blocks")return r.outcome;let a=[];for(let[s,o]of r.blocks.entries()){let i=e.lines[o.endLine-1];if(i===void 0)return{kind:"failed",error:new Error("Fuzzy Worker returned an invalid source range")};a.push({rank:s+1,range:{start:{lineNumber:o.startLine,column:0},end:{lineNumber:o.endLine,column:i.length}}})}return{kind:"candidates",candidates:a,total:a.length}}l(J,"recoverExactText");function de(t,e,n){if(!n.fuzzyEnabled||t.replace(/\s/gu,"").length<4)return!1;let r=new TextEncoder;return r.encode(t).byteLength<=n.maxQuerySizeKiB*1024&&r.encode(e).byteLength<=n.maxFileSizeMiB*1024*1024}l(de,"canSearch");function le(t,e,n,r){return new Promise(a=>{let s=new ce(Z,{eval:!0,workerData:{moduleUrl:import.meta.resolve("fast-fuzzy"),value:t,sourceLines:e,config:n}}),o=!1,i,d=l(u=>{o||(o=!0,i!==void 0&&clearTimeout(i),r!==void 0&&r.removeEventListener("abort",c),s.terminate(),a(u))},"finish"),c=l(()=>{r!==void 0&&d({kind:"outcome",outcome:{kind:"failed",error:r.reason}})},"abort");r!==void 0&&r.addEventListener("abort",c,{once:!0}),s.on("error",u=>d({kind:"outcome",outcome:{kind:"failed",error:u}})),s.on("message",u=>{if(u.kind==="ready"){i=setTimeout(()=>d({kind:"outcome",outcome:{kind:"timed-out"}}),n.timeoutMs),s.postMessage("search",[]);return}if(u.kind==="failed"){d({kind:"outcome",outcome:{kind:"failed",error:new Error(u.message??"Fuzzy Worker failed")}});return}if(u.blocks===void 0){d({kind:"outcome",outcome:{kind:"failed",error:new Error("Fuzzy Worker omitted result blocks")}});return}d({kind:"blocks",blocks:u.blocks})})})}l(le,"runFuzzyWorker");function Fe(t){return{id:"exact-text",description:"Any non-empty value not handled as a structured anchor selects one unique exact text span.",renderFull(e){return e},renderCompact(){return"selected text"},tryResolve(e,n){return Promise.resolve(ue(e,n))},recover(e,n){return J(n.rejection.searchHighlightRetry??e,n,t)}}}l(Fe,"createExactTextAnchorResolver");function ue(t,e){if(t.length===0)return R("invalid","exact text anchor must be non-empty");let n=e.content,r=ee(e),a=new L(e.source,n),s=w(n,t,a,r,e.endAfter);if(s.kind==="missing"){let o=r!==void 0&&w(n,t,a).kind!=="missing",i=$(t);if(!o&&i!==t){let c=`${"\u27E6"} ${"\u27E7"}`,u=i.length===0?{kind:"missing"}:w(n,i,a,r,e.endAfter);if(u.kind==="unique"&&(e.endAfter===void 0||u.span.from>=e.endAfter))return{...Q(t,e,u.span),notice:`Removed Search highlight markers ${c}`};let g=u.kind==="unique"?"before-start":u.kind,f=g==="ambiguous"?"the selector without them matches more than once":g==="before-start"?"the selector without them only matches before the end of the start selection":i.length===0?"removing them leaves an empty selector":"the selector without them did not match within the requested text";return{kind:"rejected",rejection:{code:g,reason:`The selector contains Search highlight markers ${c}; ${f}`,searchHighlightRetry:i}}}let d=t.replace(/(?<!\\)\\[nrt]/gu,c=>c==="\\n"?`
|
|
111
|
+
`:c==="\\r"?"\r":" ");return!o&&d!==t&&w(n,d,a,r).kind!=="missing"?R("missing",`Exact-text selector ${T(t)} contains literal backslash escapes; the character form ${T(d)} matches text inside the ${r===void 0?"file":"selection"}. Pass actual newline, carriage-return and tab characters in exact-text selectors, not literal backslash escapes. No decoding or edit was applied.`):R(o?"outside-scope":"missing",r===void 0?"exact text anchor was not found":"exact text anchor was not found inside the selection")}return s.kind==="ambiguous"?R("ambiguous",(r===void 0?"exact text anchor matched more than once":"exact text anchor matched more than once inside the selection")+(e.endAfter===void 0?"":" after the start selector")):s.kind==="before-start"?R("before-start","all matches start before the end of the start selection"):Q(t,e,s.span)}l(ue,"resolveExactTextAnchor");function Q(t,{source:e,content:n},r){return{kind:"resolved",anchor:new j(t,e,[{start:z(n,r.from),end:z(n,r.to)}])}}l(Q,"resolved");function Y(t,e,n){let{content:r,source:a}=e,s=ee(e),{endAfter:o}=e,i=U(r,t,new L(a,r),o===void 0?s:m=>m.from>=o&&(s===void 0||s(m))),d=i.length>1&&i.every(({from:m,to:p},x)=>m<p&&(i[x-1]?.to??0)<=m),c=0,u=1,g=r.indexOf(`
|
|
112
|
+
`),f=l(m=>{for(;g!==-1&&g<m;)c=g+1,u++,g=r.indexOf(`
|
|
113
|
+
`,c);return{lineNumber:u,column:m-c}},"orderedPosition"),h=d?i.map(({from:m,to:p})=>({start:f(m),end:f(p)})):void 0;return{total:i.length,ranges:h?.slice(0,n)??i.slice(0,n).map(({from:m,to:p})=>({start:z(r,m),end:z(r,p)})),...h!==void 0&&{allMatches:h}}}l(Y,"findExactTextMatches");function ee(t){let e=t.scope?.map(n=>fe(t.content,n));return e===void 0?void 0:n=>e.some(r=>n.from>=r.from&&n.to<=r.to)}l(ee,"scopeFilter");function R(t,e){return{kind:"rejected",rejection:{code:t,reason:e}}}l(R,"rejected");function fe(t,e){let n=X(t,e.end),r=t.startsWith(`\r
|
|
114
|
+
`,n)?2:t[n]===`
|
|
115
|
+
`?1:0;return{from:X(t,e.start),to:n+r}}l(fe,"scopeOffsets");function X(t,e){let n=0;for(let r=1;r<e.lineNumber;r++){let a=t.indexOf(`
|
|
116
|
+
`,n);if(a===-1)return t.length;n=a+1}return Math.min(t.length,n+e.column)}l(X,"offsetAt");function z(t,e){let n=1,r=0;for(let a=t.indexOf(`
|
|
117
|
+
`);a!==-1&&a<e;a=t.indexOf(`
|
|
118
|
+
`,r))r=a+1,n+=1;return{lineNumber:n,column:e-r}}l(z,"positionAt");export{Fe as a,ue as b,Y as c};
|