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
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
2
|
import { requiredValue } from "pi-agent-invariant";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
EDIT_EXECUTION_TIMEOUT_MS,
|
|
5
|
+
EDIT_WAIT_TIMEOUT_MS,
|
|
6
|
+
ResourceScheduler,
|
|
7
|
+
resourceAccesses,
|
|
8
|
+
runWithinToolDeadline,
|
|
9
|
+
} from "pi-agent-resource";
|
|
4
10
|
import type { TextResourceEditOutcome } from "./text-editor-core.ts";
|
|
5
11
|
|
|
6
12
|
type Completed = Exclude<TextResourceEditOutcome<unknown>, { readonly kind: "failed" }>;
|
|
7
|
-
type Finalize = () => Promise<Completed>;
|
|
13
|
+
type Finalize = (signal: AbortSignal) => Promise<Completed>;
|
|
8
14
|
const active = new AsyncLocalStorage<{
|
|
9
15
|
readonly pending: Map<string, Finalize>;
|
|
10
16
|
readonly immediate: boolean;
|
|
@@ -78,7 +84,26 @@ export function createPostEditScope(cwd = process.cwd()) {
|
|
|
78
84
|
const scheduler = new ResourceScheduler();
|
|
79
85
|
const outcomes = await Promise.allSettled(
|
|
80
86
|
work.map(([source, finalize]) =>
|
|
81
|
-
|
|
87
|
+
runWithinToolDeadline(
|
|
88
|
+
"editor post-processing",
|
|
89
|
+
source,
|
|
90
|
+
EDIT_EXECUTION_TIMEOUT_MS,
|
|
91
|
+
undefined,
|
|
92
|
+
"applied",
|
|
93
|
+
(signal) =>
|
|
94
|
+
scheduler.run(
|
|
95
|
+
resourceAccesses(source, cwd, "write"),
|
|
96
|
+
() => finalize(signal),
|
|
97
|
+
signal,
|
|
98
|
+
{
|
|
99
|
+
waitTimeoutMs: EDIT_WAIT_TIMEOUT_MS,
|
|
100
|
+
waitFor: source,
|
|
101
|
+
},
|
|
102
|
+
),
|
|
103
|
+
(error) => {
|
|
104
|
+
throw error;
|
|
105
|
+
},
|
|
106
|
+
),
|
|
82
107
|
),
|
|
83
108
|
);
|
|
84
109
|
for (const [index, outcome] of outcomes.entries()) {
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { requiredValue } from "pi-agent-invariant";
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type {
|
|
3
|
+
FragmentResolverRegistration,
|
|
4
|
+
ReadFragmentContext,
|
|
5
|
+
ReadFragmentResolution,
|
|
6
|
+
} from "pi-agent-read/api/tools/read";
|
|
7
|
+
import { linesWithAnchor, type TextAnchor } from "pi-agent-text";
|
|
8
|
+
import { anchoredLinePreviews } from "./anchor-preview.ts";
|
|
4
9
|
|
|
5
10
|
import type { TextAnchorInTextRequest } from "#src/core/text-editor-core.ts";
|
|
6
11
|
import { TextSelectionAnchor } from "#src/api/text-selection-anchor.ts";
|
|
@@ -43,7 +48,7 @@ export function createReadFragmentResolver(
|
|
|
43
48
|
await error.refreshRecovery();
|
|
44
49
|
}
|
|
45
50
|
|
|
46
|
-
return
|
|
51
|
+
return fragmentFailure(error, context);
|
|
47
52
|
}
|
|
48
53
|
|
|
49
54
|
return { kind: "resolved", originLine: anchorOriginLine(anchor) };
|
|
@@ -59,25 +64,40 @@ function anchorOriginLine(anchor: TextAnchor): number {
|
|
|
59
64
|
return anchor.lineNumber;
|
|
60
65
|
}
|
|
61
66
|
|
|
62
|
-
function
|
|
67
|
+
function fragmentFailure(
|
|
68
|
+
error: unknown,
|
|
69
|
+
{ source, text }: ReadFragmentContext,
|
|
70
|
+
): ReadFragmentResolution {
|
|
63
71
|
if (!(error instanceof TextAnchorResolutionError)) {
|
|
64
|
-
return error instanceof Error ? error.message : String(error);
|
|
72
|
+
return { kind: "failed", message: error instanceof Error ? error.message : String(error) };
|
|
65
73
|
}
|
|
66
74
|
|
|
67
75
|
const parts = [error.message];
|
|
68
76
|
const recovery = error.recovery;
|
|
77
|
+
let path = source;
|
|
69
78
|
|
|
70
79
|
if (recovery?.kind === "candidates" && recovery.candidates.length > 0) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
parts.push(
|
|
80
|
+
const previews = anchoredLinePreviews(text);
|
|
81
|
+
const lines = new Set(recovery.candidates.map(({ range }) => range.start.lineNumber));
|
|
82
|
+
let shown = 0;
|
|
83
|
+
for (const lineNumber of lines) {
|
|
84
|
+
const row = previews.line(lineNumber);
|
|
85
|
+
if (row === undefined) continue;
|
|
86
|
+
if (shown === 0) parts.push("Candidates:");
|
|
87
|
+
parts.push(row);
|
|
88
|
+
const anchor = previews.anchors[lineNumber - 1];
|
|
89
|
+
if (
|
|
90
|
+
path === source &&
|
|
91
|
+
anchor !== undefined &&
|
|
92
|
+
linesWithAnchor(previews.anchors, anchor).length === 1
|
|
93
|
+
)
|
|
94
|
+
path = `${source}#${anchor}`;
|
|
95
|
+
if (++shown === MAX_SHOWN_CANDIDATES) break;
|
|
79
96
|
}
|
|
97
|
+
const hidden =
|
|
98
|
+
recovery.total - recovery.candidates.length + Math.max(0, lines.size - MAX_SHOWN_CANDIDATES);
|
|
99
|
+
if (hidden > 0) parts.push(`… ${hidden} more matches.`);
|
|
80
100
|
}
|
|
81
101
|
|
|
82
|
-
return parts.join("\n");
|
|
102
|
+
return { kind: "failed", message: parts.join("\n"), retryPath: path };
|
|
83
103
|
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { ResultSourceTarget, ResultTargetStore } from "pi-agent-resource";
|
|
2
|
+
import type { TextTarget } from "pi-agent-text";
|
|
3
|
+
import { TEXT_SEARCH_ANCHOR_KIND } from "#src/api/plugin-protocol.ts";
|
|
4
|
+
import type { TextEditorCore } from "#src/core/text-editor-core.ts";
|
|
5
|
+
|
|
6
|
+
const RESULT_PREFIX = "RESULT#";
|
|
7
|
+
const NAME_LIMIT = 80;
|
|
8
|
+
|
|
9
|
+
function isSearchReference(value: string): boolean {
|
|
10
|
+
return value.startsWith("SEARCH#");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function named(item: string): string {
|
|
14
|
+
return item.length > NAME_LIMIT ? `${item.slice(0, NAME_LIMIT)}…` : item;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function describe(error: unknown): string {
|
|
18
|
+
return error instanceof Error ? error.message : String(error);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Search snapshots carry no reader of their own. The edit that consumes them re-reads each source
|
|
23
|
+
* under its lock and compares it with `expectedContent`, so that comparison is the freshness check.
|
|
24
|
+
*/
|
|
25
|
+
function resultTarget(target: TextTarget): ResultSourceTarget {
|
|
26
|
+
if (target.expectedContent === undefined || target.ranges === undefined)
|
|
27
|
+
throw new Error("It does not select a text range.");
|
|
28
|
+
const expected = target.expectedContent;
|
|
29
|
+
return {
|
|
30
|
+
source: target.source,
|
|
31
|
+
expectedContent: expected,
|
|
32
|
+
ranges: target.ranges,
|
|
33
|
+
readCurrent: () => Promise.resolve(expected),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Turn a source array into registered `RESULT#` handles, one group per item and in the given order.
|
|
39
|
+
* Items are references only: a Search reference, a `RESULT#` handle or an issued result. Every
|
|
40
|
+
* edit tool with a list of targets follows one rule: every item that is expired, unknown, stale or
|
|
41
|
+
* a plain path is collected, and one error names all of them with their reasons and current
|
|
42
|
+
* lines. The call then changes nothing, so the agent repeats it once without the listed items.
|
|
43
|
+
*/
|
|
44
|
+
export async function expandReferenceList(
|
|
45
|
+
core: Pick<TextEditorCore, "resolveTextAnchorResources">,
|
|
46
|
+
store: ResultTargetStore,
|
|
47
|
+
list: readonly unknown[],
|
|
48
|
+
cwd: string,
|
|
49
|
+
signal?: AbortSignal,
|
|
50
|
+
): Promise<string[]> {
|
|
51
|
+
const handles: string[] = [];
|
|
52
|
+
const failures: string[] = [];
|
|
53
|
+
for (const item of list) {
|
|
54
|
+
if (typeof item !== "string")
|
|
55
|
+
throw new Error("A reference list holds strings only: Search references or issued results.");
|
|
56
|
+
try {
|
|
57
|
+
if (isSearchReference(item)) {
|
|
58
|
+
const targets = await core.resolveTextAnchorResources(item, [TEXT_SEARCH_ANCHOR_KIND], {
|
|
59
|
+
cwd,
|
|
60
|
+
...(signal !== undefined && { signal }),
|
|
61
|
+
});
|
|
62
|
+
if (targets === undefined)
|
|
63
|
+
throw new Error("It was not issued by a Search in this session.");
|
|
64
|
+
handles.push(store.register(targets.map(resultTarget), cwd));
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
const resolved = store.source(item, cwd);
|
|
68
|
+
const issued = Array.isArray(resolved) ? resolved : [resolved];
|
|
69
|
+
for (const handle of issued) {
|
|
70
|
+
if (typeof handle !== "string" || !handle.startsWith(RESULT_PREFIX))
|
|
71
|
+
throw new Error(
|
|
72
|
+
"It is a path. Arrays hold references only (SEARCH#…, RESULT#… or a result UUID); pass a path as a single string.",
|
|
73
|
+
);
|
|
74
|
+
store.resolve(handle, cwd);
|
|
75
|
+
handles.push(handle);
|
|
76
|
+
}
|
|
77
|
+
} catch (error) {
|
|
78
|
+
signal?.throwIfAborted();
|
|
79
|
+
// A numbered Search reference arrives as the handle it names. A script passes that handle
|
|
80
|
+
// itself as the id of a Search match, so the message names both.
|
|
81
|
+
const name = store.referenceName(item);
|
|
82
|
+
failures.push(
|
|
83
|
+
`Reference ${named(name === item ? item : `${name} (${item})`)} cannot be used: ${describe(error).replaceAll("\n", "\n ")}`,
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (failures.length > 0)
|
|
88
|
+
throw new Error(
|
|
89
|
+
[
|
|
90
|
+
`${String(failures.length)} of ${String(list.length)} references cannot be used; nothing was changed. Repeat the call without them, or with fresh references for them:`,
|
|
91
|
+
...failures.map((failure) => `- ${failure}`),
|
|
92
|
+
].join("\n"),
|
|
93
|
+
);
|
|
94
|
+
return handles;
|
|
95
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import type { ResolvedResultTargets, ResultTargetStore } from "pi-agent-resource";
|
|
3
|
+
import {
|
|
4
|
+
createTextDocument,
|
|
5
|
+
documentLineAnchors,
|
|
6
|
+
type TextAnchor,
|
|
7
|
+
type TextAnchorRecoveryRange,
|
|
8
|
+
type TextSelectionRange,
|
|
9
|
+
} from "pi-agent-text";
|
|
10
|
+
import { TextSelectionAnchor } from "#src/api/text-selection-anchor.ts";
|
|
11
|
+
import type { TextChangeDocument, TextRange } from "./text-change-engine.ts";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A result passed with selectors only limits where they resolve; the selectors carry their own
|
|
15
|
+
* checks. So its ranges may follow the file to their current region after other edits, which an
|
|
16
|
+
* edit of the selected text itself refuses.
|
|
17
|
+
*/
|
|
18
|
+
export function resolveResultScope(
|
|
19
|
+
store: ResultTargetStore,
|
|
20
|
+
input: unknown,
|
|
21
|
+
cwd: string,
|
|
22
|
+
): ResolvedResultTargets {
|
|
23
|
+
// The scope is not the edit selection; guarded selectors are resolved separately.
|
|
24
|
+
const selected = store.resolve(input, cwd, { allowAdjusted: true, forScope: true });
|
|
25
|
+
return {
|
|
26
|
+
complete: selected.complete,
|
|
27
|
+
targets: selected.targets.map((target) => ({
|
|
28
|
+
...target,
|
|
29
|
+
ranges: target.ranges.map(({ adjusted: _adjusted, ...range }) => range),
|
|
30
|
+
})),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** The last line a range covers: a range that ends at the start of a line ends with the previous one. */
|
|
35
|
+
function lastLine({ start, end }: TextSelectionRange): number {
|
|
36
|
+
return end.column === 0 && end.lineNumber > start.lineNumber
|
|
37
|
+
? end.lineNumber - 1
|
|
38
|
+
: end.lineNumber;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Most lines of a result's selection shown with an anchor that missed it. */
|
|
42
|
+
const maxWindowLines = 40;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Offsets of a selected range. A range that ends where a line ends also covers that line's break,
|
|
46
|
+
* so a whole-line selection inside it, which includes the break, still counts as inside.
|
|
47
|
+
*/
|
|
48
|
+
function scopeOffsets(document: TextChangeDocument, range: TextSelectionRange): TextRange {
|
|
49
|
+
const { from, to } = document.range(
|
|
50
|
+
range.start.lineNumber,
|
|
51
|
+
range.start.column,
|
|
52
|
+
range.end.lineNumber,
|
|
53
|
+
range.end.column,
|
|
54
|
+
);
|
|
55
|
+
return { from, to: to + lineBreakAt(document.content, to) };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The length of the LF at `offset`, or of a CRLF when a range stops before a CRLF line's CR. Only
|
|
60
|
+
* LF ends a line; a lone CR is ordinary text.
|
|
61
|
+
*/
|
|
62
|
+
function lineBreakAt(content: string, offset: number): number {
|
|
63
|
+
return content.startsWith("\r\n", offset) ? 2 : content[offset] === "\n" ? 1 : 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The scope range holding each independent anchor selection. Line selectors use the containing
|
|
68
|
+
* lines of the scope; exact selectors keep its column boundaries. No selection may cross a gap.
|
|
69
|
+
*/
|
|
70
|
+
export function scopeRangeIndices(
|
|
71
|
+
document: TextChangeDocument,
|
|
72
|
+
anchor: TextAnchor,
|
|
73
|
+
scope: readonly TextSelectionRange[],
|
|
74
|
+
): readonly number[] | undefined {
|
|
75
|
+
try {
|
|
76
|
+
const ranges = scope.map((range) => scopeOffsets(document, range));
|
|
77
|
+
const lines = scope.map((range) => document.lineRange(range.start.lineNumber, lastLine(range)));
|
|
78
|
+
const selected = TextSelectionAnchor.is(anchor)
|
|
79
|
+
? anchor.ranges.map((range) => ({
|
|
80
|
+
offsets: document.range(
|
|
81
|
+
range.start.lineNumber,
|
|
82
|
+
range.start.column,
|
|
83
|
+
range.end.lineNumber,
|
|
84
|
+
range.end.column,
|
|
85
|
+
),
|
|
86
|
+
linewise: range.linewise === true,
|
|
87
|
+
}))
|
|
88
|
+
: [{ offsets: document.lineRange(anchor.lineNumber, anchor.lineNumber), linewise: true }];
|
|
89
|
+
const indices = selected.map(({ offsets: part, linewise }) =>
|
|
90
|
+
(linewise ? lines : ranges).findIndex(
|
|
91
|
+
(range) => part.from >= range.from && part.to <= range.to,
|
|
92
|
+
),
|
|
93
|
+
);
|
|
94
|
+
return indices.some((index) => index < 0) ? undefined : indices;
|
|
95
|
+
} catch {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Names a result's scope by the anchors bounding each selected range, not by line numbers. */
|
|
101
|
+
export function describeScope(
|
|
102
|
+
source: string,
|
|
103
|
+
scope: readonly TextSelectionRange[],
|
|
104
|
+
document: TextChangeDocument,
|
|
105
|
+
cwd: string,
|
|
106
|
+
): string {
|
|
107
|
+
// A file inside the workspace is named relative to it, as the agent usually names it.
|
|
108
|
+
const root = cwd.endsWith(path.sep) ? cwd : cwd + path.sep;
|
|
109
|
+
const shown = source.startsWith(root) ? source.slice(root.length) : source;
|
|
110
|
+
if (scope.length === 0) return shown;
|
|
111
|
+
const { lines } = createTextDocument(source, document.content);
|
|
112
|
+
const anchors = documentLineAnchors(lines);
|
|
113
|
+
const limit = 5;
|
|
114
|
+
const parts = scope.slice(0, limit).flatMap((range) => {
|
|
115
|
+
const first = anchors[range.start.lineNumber - 1];
|
|
116
|
+
const last = anchors[lastLine(range) - 1];
|
|
117
|
+
if (first === undefined || last === undefined) return [];
|
|
118
|
+
return [first === last ? first : `${first} through ${last}`];
|
|
119
|
+
});
|
|
120
|
+
const omitted = scope.length > limit ? `, … ${scope.length - limit} more ranges` : "";
|
|
121
|
+
return parts.length === 0 ? shown : `${shown} (${parts.join(", ")}${omitted})`;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** The lines of a selection, shown as recovery context when an anchor misses it. */
|
|
125
|
+
export function scopeWindow(scope: readonly TextSelectionRange[]): TextAnchorRecoveryRange {
|
|
126
|
+
const first = Math.min(...scope.map((range) => range.start.lineNumber));
|
|
127
|
+
const last = Math.max(...scope.map(lastLine));
|
|
128
|
+
return { offset: first, limit: Math.min(maxWindowLines, last - first + 1) };
|
|
129
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { rangesInText, type ResultTargetStore } from "pi-agent-resource";
|
|
2
2
|
import { TextSelectionAnchor } from "#src/api/text-selection-anchor.ts";
|
|
3
3
|
import {
|
|
4
4
|
TEXT_SEARCH_ANCHOR_KIND,
|
|
@@ -9,34 +9,42 @@ import {
|
|
|
9
9
|
export function createResultTargetAnchors(
|
|
10
10
|
store: ResultTargetStore,
|
|
11
11
|
): TextAnchorResolverRegistration {
|
|
12
|
+
const ownsReference = (value: string) =>
|
|
13
|
+
value.startsWith("RESULT#") ||
|
|
14
|
+
(value.endsWith(":all:match") && store.hasSearchReference(value));
|
|
12
15
|
return {
|
|
13
16
|
kind: TEXT_SEARCH_ANCHOR_KIND,
|
|
14
17
|
type: "auxiliary",
|
|
15
18
|
describeInPrompt: false,
|
|
19
|
+
// Resolve fixed matches ourselves, rather than sending them to a live Search session.
|
|
20
|
+
priority: -20,
|
|
16
21
|
resolver: {
|
|
17
22
|
id: "result-targets",
|
|
18
23
|
description: "Use returned RESULT# references to target exact source snapshots.",
|
|
19
24
|
renderFull: (value) => value,
|
|
20
25
|
renderCompact: () => "result targets",
|
|
21
26
|
async tryResolve(value, context) {
|
|
22
|
-
if (!value
|
|
27
|
+
if (!ownsReference(value)) return { kind: "not-handled" };
|
|
23
28
|
try {
|
|
24
29
|
const target = store
|
|
25
|
-
.resolve(value, context.cwd)
|
|
30
|
+
.resolve(value, context.cwd, { forEdit: true })
|
|
26
31
|
.targets.find((target) => target.source === context.source);
|
|
27
32
|
if (target === undefined)
|
|
28
33
|
return {
|
|
29
34
|
kind: "rejected",
|
|
30
35
|
rejection: { code: "missing", reason: "Result does not select this source." },
|
|
31
36
|
};
|
|
32
|
-
|
|
37
|
+
// Resolve in the caller's text: the store may already hold this selection on a newer
|
|
38
|
+
// text, or the caller may have read the file before another session wrote it.
|
|
39
|
+
const ranges = rangesInText(target.ranges, target.expectedContent, context.content);
|
|
40
|
+
if (ranges === undefined)
|
|
33
41
|
return {
|
|
34
42
|
kind: "rejected",
|
|
35
43
|
rejection: { code: "stale", reason: "Result target is stale; repeat Read/Search." },
|
|
36
44
|
};
|
|
37
45
|
return {
|
|
38
46
|
kind: "resolved",
|
|
39
|
-
anchor: new TextSelectionAnchor(value, target.source,
|
|
47
|
+
anchor: new TextSelectionAnchor(value, target.source, ranges),
|
|
40
48
|
};
|
|
41
49
|
} catch (error) {
|
|
42
50
|
return {
|
|
@@ -52,10 +60,14 @@ export function createResultTargetAnchors(
|
|
|
52
60
|
resources: {
|
|
53
61
|
id: "result-target-sources",
|
|
54
62
|
async tryResolve(value, context) {
|
|
55
|
-
if (!value
|
|
63
|
+
if (!ownsReference(value)) return { kind: "not-handled" };
|
|
56
64
|
try {
|
|
57
|
-
const selected = store.resolve(value, context.cwd
|
|
58
|
-
|
|
65
|
+
const selected = store.resolve(value, context.cwd, {
|
|
66
|
+
forEdit: context.edit !== undefined,
|
|
67
|
+
});
|
|
68
|
+
// Filesystem selections are mapped onto the text acquired by the consumer. Sources
|
|
69
|
+
// without filesystem tracking still need verification before their selections are used.
|
|
70
|
+
await store.verifyUnfollowed(selected, context.signal);
|
|
59
71
|
return selected.targets.length === 0
|
|
60
72
|
? {
|
|
61
73
|
kind: "rejected",
|
|
@@ -4,19 +4,25 @@ import type {
|
|
|
4
4
|
TextMutationContext,
|
|
5
5
|
TextMutationEdit,
|
|
6
6
|
} from "#src/api/mutation-tool.ts";
|
|
7
|
-
import { TextChangeDocument, type TextChange } from "./text-change-engine.ts";
|
|
8
|
-
import {
|
|
7
|
+
import { TextChangeDocument, type TextChange, type TextSpan } from "./text-change-engine.ts";
|
|
8
|
+
import {
|
|
9
|
+
resolveTextSpan,
|
|
10
|
+
transferToTextSelector,
|
|
11
|
+
selectionRange,
|
|
12
|
+
selectionSpan,
|
|
13
|
+
} from "#src/tools/text-selection.ts";
|
|
14
|
+
import { sourceTextSelector, targetTextSelector } from "#src/api/text-selector-fields.ts";
|
|
9
15
|
import { wholeFileResultSource } from "./result-input.ts";
|
|
16
|
+
import { resolveResultScope } from "./result-scope.ts";
|
|
17
|
+
import { SOURCE_CHANGED } from "./source-change-retry.ts";
|
|
10
18
|
|
|
11
19
|
/** Distinguish structured source authority from ordinary paths and legacy anchors. */
|
|
12
20
|
export function isResultInput(value: unknown): boolean {
|
|
13
21
|
return value !== undefined && (typeof value !== "string" || value.startsWith("RESULT#"));
|
|
14
22
|
}
|
|
15
23
|
|
|
16
|
-
interface TransferSpan {
|
|
24
|
+
interface TransferSpan extends TextSpan {
|
|
17
25
|
readonly source: string;
|
|
18
|
-
readonly from: number;
|
|
19
|
-
readonly to: number;
|
|
20
26
|
}
|
|
21
27
|
|
|
22
28
|
interface PreparedTransfer {
|
|
@@ -37,29 +43,42 @@ export async function prepareResultTransfer(
|
|
|
37
43
|
signal?: AbortSignal,
|
|
38
44
|
): Promise<PreparedTransfer> {
|
|
39
45
|
const input = { ...parameters };
|
|
40
|
-
|
|
46
|
+
/** One handle per selected range, in declared order, so every attempt can resolve them again. */
|
|
47
|
+
const handles = new Map<"path" | "target", readonly string[]>();
|
|
48
|
+
const sourceSelector = sourceTextSelector(input);
|
|
49
|
+
const targetSelector = targetTextSelector(input);
|
|
50
|
+
const resolve = (field: "path" | "target", hasSelector: boolean) => {
|
|
41
51
|
if (!isResultInput(input[field])) return undefined;
|
|
42
|
-
if (
|
|
43
|
-
|
|
52
|
+
if (hasSelector) {
|
|
53
|
+
// The anchors select the text, inside the result's selection: the result is their scope.
|
|
54
|
+
const scope = resolveResultScope(store, input[field], cwd);
|
|
55
|
+
if (!scope.complete)
|
|
56
|
+
throw new Error(
|
|
57
|
+
"Incomplete result targets cannot establish a complete transfer. Run Search again with a higher limit or a narrower query, then use the complete result.",
|
|
58
|
+
);
|
|
59
|
+
if (scope.targets.length === 0) throw new Error("Empty result target set.");
|
|
60
|
+
input[field] = store.register(scope.targets, cwd);
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
44
63
|
const selected = store.resolveOrdered(input[field], cwd);
|
|
45
64
|
if (!selected.complete)
|
|
46
65
|
throw new Error(
|
|
47
66
|
"Incomplete result targets cannot establish a complete transfer. Run Search again with a higher limit or a narrower query, then use the complete result.",
|
|
48
67
|
);
|
|
49
|
-
await store.verify(selected, signal);
|
|
50
68
|
input[field] = store.register(selected.targets, cwd);
|
|
69
|
+
handles.set(
|
|
70
|
+
field,
|
|
71
|
+
selected.targets.map((target) => store.register([target], cwd)),
|
|
72
|
+
);
|
|
51
73
|
return selected;
|
|
52
74
|
};
|
|
53
|
-
const source =
|
|
54
|
-
const destination =
|
|
75
|
+
const source = resolve("path", sourceSelector !== undefined);
|
|
76
|
+
const destination = resolve("target", targetSelector !== undefined);
|
|
55
77
|
if (source === undefined && destination === undefined) return { input, empty: false };
|
|
56
|
-
if (
|
|
57
|
-
source !== undefined &&
|
|
58
|
-
destination === undefined &&
|
|
59
|
-
input.targetStart === undefined &&
|
|
60
|
-
input.targetEnd === undefined
|
|
61
|
-
) {
|
|
78
|
+
if (source !== undefined && destination === undefined && targetSelector === undefined) {
|
|
62
79
|
// A structured source may use the byte-preserving file operation only when it really selects a whole file.
|
|
80
|
+
// A file operation uses the selected file right away, so its text is checked here.
|
|
81
|
+
await store.verify(source, signal);
|
|
63
82
|
input.path = wholeFileResultSource(store.resolve(parameters.path, cwd));
|
|
64
83
|
return { input, empty: false, verifyFileSource: () => store.verify(source, signal) };
|
|
65
84
|
}
|
|
@@ -90,6 +109,9 @@ export async function prepareResultTransfer(
|
|
|
90
109
|
const sources = spans(source);
|
|
91
110
|
const destinations = spans(destination);
|
|
92
111
|
if ([...sources, ...destinations].every((span) => span.from === span.to)) {
|
|
112
|
+
// Nothing is written, so the positions are checked against the file here.
|
|
113
|
+
await store.verify(source, signal);
|
|
114
|
+
await store.verify(destination, signal);
|
|
93
115
|
assertMoveTargets(sources, destinations);
|
|
94
116
|
return { input, empty: false, noOpTarget: store.register(destination.targets, cwd) };
|
|
95
117
|
}
|
|
@@ -98,38 +120,41 @@ export async function prepareResultTransfer(
|
|
|
98
120
|
input,
|
|
99
121
|
empty,
|
|
100
122
|
async mutate(context) {
|
|
123
|
+
// Each attempt takes the selections as the store has them now: moved to the file's current
|
|
124
|
+
// text when another process wrote it, or refused with their current lines when their own
|
|
125
|
+
// text changed.
|
|
126
|
+
const current = (field: "path" | "target"): ResolvedResultTargets => ({
|
|
127
|
+
targets: (handles.get(field) ?? []).flatMap((handle) => store.resolve(handle, cwd).targets),
|
|
128
|
+
complete: true,
|
|
129
|
+
});
|
|
101
130
|
const spans = (selected: ResolvedResultTargets): TransferSpan[] =>
|
|
102
131
|
selected.targets.map((target) => {
|
|
103
132
|
const document = context.documentFor(target.source);
|
|
104
133
|
if (document.content !== target.expectedContent)
|
|
105
|
-
throw
|
|
134
|
+
throw Object.assign(
|
|
135
|
+
new Error("The selected text's file changed before the transfer; run it again."),
|
|
136
|
+
{ code: SOURCE_CHANGED },
|
|
137
|
+
);
|
|
106
138
|
const range = target.ranges[0];
|
|
107
139
|
if (range === undefined) throw new Error("Transfer selection has no range.");
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
...document.range(
|
|
111
|
-
range.start.lineNumber,
|
|
112
|
-
range.start.column,
|
|
113
|
-
range.end.lineNumber,
|
|
114
|
-
range.end.column,
|
|
115
|
-
),
|
|
116
|
-
};
|
|
140
|
+
selectionRange(context, target.source, range);
|
|
141
|
+
return { source: target.source, ...selectionSpan(document, range) };
|
|
117
142
|
});
|
|
118
143
|
const sources =
|
|
119
144
|
source === undefined
|
|
120
145
|
? [
|
|
121
|
-
|
|
122
|
-
? {
|
|
123
|
-
|
|
124
|
-
context
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
146
|
+
sourceSelector === undefined
|
|
147
|
+
? {
|
|
148
|
+
source: context.sourceFor("path"),
|
|
149
|
+
...context.sourceDocument.charSpan({
|
|
150
|
+
from: 0,
|
|
151
|
+
to: context.sourceDocument.length,
|
|
152
|
+
}),
|
|
153
|
+
}
|
|
154
|
+
: await resolveTextSpan(context, sourceSelector),
|
|
130
155
|
]
|
|
131
|
-
: spans(
|
|
132
|
-
const destinations = destination === undefined ? undefined : spans(
|
|
156
|
+
: spans(current("path"));
|
|
157
|
+
const destinations = destination === undefined ? undefined : spans(current("target"));
|
|
133
158
|
if (sources.length !== (destinations?.length ?? 1))
|
|
134
159
|
throw new Error(
|
|
135
160
|
"Transfer source and destination selection counts must match; no broadcast or concatenation.",
|
|
@@ -146,50 +171,42 @@ export async function prepareResultTransfer(
|
|
|
146
171
|
};
|
|
147
172
|
const planned: { target: TransferSpan; change: TextChange }[] = [];
|
|
148
173
|
for (const [index, span] of sources.entries()) {
|
|
149
|
-
const copied = context.documentFor(span.source).
|
|
174
|
+
const copied = context.documentFor(span.source).transfer(span);
|
|
150
175
|
const destinationSpan = destinations?.[index];
|
|
151
176
|
if (destinationSpan !== undefined) {
|
|
152
177
|
planned.push({
|
|
153
178
|
target: destinationSpan,
|
|
154
|
-
change:
|
|
179
|
+
change: context.documentFor(destinationSpan.source).replace(destinationSpan, copied),
|
|
155
180
|
});
|
|
156
181
|
continue;
|
|
157
182
|
}
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
const [target, change] = insertionAfterAnchor(context, starts, "targetStart", copied);
|
|
161
|
-
planned.push({
|
|
162
|
-
target: { source: target, from: change.from, to: change.to },
|
|
163
|
-
change,
|
|
164
|
-
});
|
|
165
|
-
} else {
|
|
166
|
-
const target = anchorSpanRange(
|
|
167
|
-
context,
|
|
168
|
-
starts,
|
|
169
|
-
await context.resolveAnchors("targetEnd"),
|
|
170
|
-
"targetStart",
|
|
171
|
-
"targetEnd",
|
|
172
|
-
);
|
|
173
|
-
planned.push({
|
|
174
|
-
target,
|
|
175
|
-
change: { from: target.from, to: target.to, insert: copied },
|
|
176
|
-
});
|
|
177
|
-
}
|
|
183
|
+
const [target, change] = await transferToTextSelector(context, copied, targetSelector);
|
|
184
|
+
planned.push({ target, change });
|
|
178
185
|
}
|
|
179
186
|
if (operation === "move") {
|
|
187
|
+
const spansBySource = new Map<string, TransferSpan[]>();
|
|
188
|
+
for (const span of sources) {
|
|
189
|
+
const group = spansBySource.get(span.source);
|
|
190
|
+
if (group === undefined) spansBySource.set(span.source, [span]);
|
|
191
|
+
else group.push(span);
|
|
192
|
+
}
|
|
193
|
+
const deletions = [...spansBySource].flatMap(([source, spans]) =>
|
|
194
|
+
context
|
|
195
|
+
.documentFor(source)
|
|
196
|
+
.deleteSpans(spans)
|
|
197
|
+
.map((change) => ({ source, ...change })),
|
|
198
|
+
);
|
|
180
199
|
assertMoveTargets(
|
|
181
200
|
sources,
|
|
182
|
-
planned.map((
|
|
201
|
+
planned.map(({ target }) => target),
|
|
183
202
|
);
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
for (const transfer of planned)
|
|
188
|
-
append(
|
|
189
|
-
transfer.target,
|
|
190
|
-
operation === "copy" ? { ...transfer.change, allowUnchanged: true } : transfer.change,
|
|
191
|
-
true,
|
|
203
|
+
assertMoveTargets(
|
|
204
|
+
deletions,
|
|
205
|
+
planned.map(({ target, change }) => ({ source: target.source, ...change })),
|
|
192
206
|
);
|
|
207
|
+
for (const deletion of deletions) append(deletion, deletion, false);
|
|
208
|
+
}
|
|
209
|
+
for (const transfer of planned) append(transfer.target, transfer.change, true);
|
|
193
210
|
return { edits };
|
|
194
211
|
},
|
|
195
212
|
};
|