pi-agent-ide 0.6.4 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/README.md +2 -2
- package/dist/{chunk-AWXVJ5AC.js → chunk-2RTCSZB3.js} +1 -1
- package/dist/{chunk-QEJGED4V.js → chunk-3HYXQ4YA.js} +1 -1
- package/dist/chunk-3JO7QFIL.js +1 -0
- package/dist/{chunk-5J43L2RL.js → chunk-4NIFBFFR.js} +1 -1
- package/dist/{chunk-BSICWXMH.js → chunk-64M3SQPG.js} +1 -1
- package/dist/{chunk-3BBJZSMS.js → chunk-7LD2OQH3.js} +1 -1
- package/dist/chunk-7LZKOHH2.js +1 -0
- package/dist/chunk-AJRIASPQ.js +2 -0
- package/dist/chunk-EAZGN5ND.js +7 -0
- package/dist/{chunk-GIRAEVUJ.js → chunk-F5YZG77W.js} +1 -1
- package/dist/chunk-FK42RSF4.js +1 -0
- package/dist/{chunk-WJTHY6AG.js → chunk-FXNKMNSJ.js} +1 -1
- package/dist/chunk-GBLKIB6O.js +2 -0
- package/dist/{chunk-KUPHNMUK.js → chunk-KBP3QUDT.js} +1 -1
- package/dist/{chunk-VBICI5YA.js → chunk-KR36BT5E.js} +1 -1
- package/dist/chunk-OE7QVAI2.js +5 -0
- package/dist/chunk-PNU3E7IO.js +3 -0
- package/dist/chunk-PS2B6THP.js +3 -0
- package/dist/{chunk-HPUAIWIH.js → chunk-PYPPV2F5.js} +1 -1
- package/dist/{chunk-FUG2TEKI.js → chunk-QFTBY67N.js} +2 -2
- package/dist/chunk-S5LXX32D.js +28 -0
- package/dist/chunk-SQKAXYIR.js +2 -0
- package/dist/chunk-VCGNVTXQ.js +1 -0
- package/dist/chunk-XYS4FSCC.js +12 -0
- package/dist/{chunk-FBOW7XOV.js → chunk-YRF7OATP.js} +1 -1
- package/dist/entry-11.js +1 -1
- package/dist/entry-13.js +1 -1
- package/dist/entry-14.js +1 -1
- package/dist/entry-15.js +1 -1
- package/dist/entry-17.js +1 -1
- package/dist/entry-25.js +1 -1
- package/dist/entry-26.js +1 -1
- package/dist/entry-28.js +1 -1
- package/dist/entry-29.js +1 -1
- package/dist/entry-30.js +1 -1
- package/dist/entry-31.js +13 -11
- package/dist/entry-33.js +1 -1
- package/dist/entry-37.js +6 -6
- package/dist/entry-42.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +13 -13
- package/dist/entry-46.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +3 -6
- package/dist/entry-51.js +11 -9
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-54.js +1 -1
- package/dist/entry-56.js +1 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-61.js +0 -1
- package/dist/entry-62.js +1 -0
- package/dist/entry-63.js +0 -1
- package/dist/entry-64.js +1 -0
- 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 -1
- package/dist/entry-69.js +1 -1
- package/dist/entry-70.js +1 -1
- package/dist/entry-71.js +0 -1
- package/dist/entry-72.js +1 -0
- package/dist/entry-73.js +0 -1
- package/dist/entry-74.js +1 -0
- package/dist/entry-75.js +1 -1
- package/dist/entry-76.js +1 -1
- package/dist/entry-77.js +67 -1
- package/dist/entry-78.js +14 -325
- package/dist/entry-79.js +2 -18
- package/dist/entry-80.js +1 -2
- package/dist/entry-81.js +1 -1
- package/dist/entry-82.js +5 -1
- package/dist/entry-83.js +3 -5
- package/dist/entry-84.js +1 -3
- package/dist/entry-85.js +1 -1
- package/dist/entry-86.js +1 -1
- package/dist/pi-agent-ide.js +5 -5
- package/docs/agent-guides/editing.md +20 -4
- package/docs/agent-guides/git-changes.md +1 -1
- package/docs/agent-guides/read-resources.md +9 -1
- package/docs/agent-guides/search-code.md +38 -1
- package/docs/agent-guides/select-code.md +194 -0
- package/docs/configuration.md +12 -17
- package/docs/development.md +2 -1
- package/docs/releases.md +1 -1
- package/docs/research/apply-native-capability-matrix.md +174 -0
- package/docs/research/apply-read-latency.md +2 -0
- package/docs/research/lpt-393-fuzzy-results/file.json +152 -0
- package/docs/research/lpt-393-fuzzy-results/repo.json +122 -0
- package/docs/research/lpt-393-search-fuzzy-fallback.md +97 -0
- package/docs/research/native-codemode-batch-decision.md +2 -0
- package/docs/research/native-codemode-batching.md +1 -1
- package/docs/structured-results.md +32 -5
- package/docs/tools.md +6 -2
- package/docs/user-hooks.md +1 -1
- package/node_modules/pi-agent-doctor/package.json +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-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 +15 -10
- package/node_modules/pi-agent-ide-ast/src/ast/constructs.ts +193 -0
- package/node_modules/pi-agent-ide-ast/src/ast/element-extent.ts +59 -0
- package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +5 -1
- package/node_modules/pi-agent-ide-ast/src/ast/selection.ts +204 -0
- package/node_modules/pi-agent-ide-ast/src/ast/syntax-tree.ts +2 -0
- package/node_modules/pi-agent-ide-ast/src/extension.ts +4 -2
- package/node_modules/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +107 -21
- package/node_modules/pi-agent-ide-ast/src/select-presentation.ts +104 -0
- package/node_modules/pi-agent-ide-ast/src/select-schema.ts +384 -0
- package/node_modules/pi-agent-ide-ast/src/selection-region.ts +41 -0
- package/node_modules/pi-agent-ide-ast/src/source-text.ts +92 -0
- package/node_modules/pi-agent-ide-ast/src/text-selection.ts +214 -0
- package/node_modules/pi-agent-ide-ast/src/tool-select.ts +251 -0
- package/node_modules/pi-agent-ide-changes/index.ts +2 -18
- package/node_modules/pi-agent-ide-changes/package.json +8 -8
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +2 -2
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +11 -40
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- 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-lsp/index.ts +2 -2
- package/node_modules/pi-agent-ide-lsp/package.json +9 -9
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +5 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +8 -2
- package/node_modules/pi-agent-ide-lsp/src/lsp/project.ts +19 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +204 -118
- package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +2 -17
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +88 -45
- package/node_modules/pi-agent-image/package.json +2 -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/read-parameters.ts +2 -2
- package/node_modules/pi-agent-read/src/api/tools/read.ts +4 -0
- package/node_modules/pi-agent-read/src/core/extension.ts +11 -0
- package/node_modules/pi-agent-read/src/core/tools/read/result-target.ts +93 -0
- package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +2 -0
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +8 -1
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/index.ts +10 -0
- package/node_modules/pi-agent-resource/src/result-targets.ts +233 -0
- package/node_modules/pi-agent-search/package.json +5 -5
- package/node_modules/pi-agent-search/src/api/fuzzy.ts +208 -0
- package/node_modules/pi-agent-search/src/api/presentation.ts +68 -0
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +9 -3
- package/node_modules/pi-agent-search/src/api/search-scope.ts +22 -0
- package/node_modules/pi-agent-search/src/api/search.ts +28 -0
- package/node_modules/pi-agent-search/src/api/structured-result.ts +69 -14
- package/node_modules/pi-agent-search/src/core/extension.ts +56 -16
- package/node_modules/pi-agent-search/src/core/search-core.ts +9 -1
- package/node_modules/pi-agent-search-text/index.ts +3 -1
- package/node_modules/pi-agent-search-text/package.json +7 -6
- package/node_modules/pi-agent-search-text/src/fuzzy-search.ts +164 -0
- package/node_modules/pi-agent-search-text/src/resolvers.ts +161 -30
- package/node_modules/pi-agent-search-text/src/scoped-search.ts +103 -0
- package/node_modules/pi-agent-search-text/src/search-backend.ts +104 -17
- package/node_modules/pi-agent-search-text/src/search-renderer.ts +89 -292
- package/node_modules/pi-agent-search-text/src/search-result.ts +77 -0
- package/node_modules/pi-agent-search-text/src/search-session.ts +96 -11
- package/node_modules/pi-agent-text/package.json +2 -2
- package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/node_modules/pi-agent-text-editor/index.ts +0 -5
- package/node_modules/pi-agent-text-editor/package.json +26 -31
- package/node_modules/pi-agent-text-editor/runtime/entry-77.js +1 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +3 -1
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +1 -20
- package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +4 -23
- package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +2 -2
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +12 -2
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +29 -4
- package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/file-result-targets.ts +76 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/mutation-result-targets.ts +168 -0
- package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +199 -19
- package/node_modules/pi-agent-text-editor/src/core/result-input.ts +22 -0
- package/node_modules/pi-agent-text-editor/src/core/result-target-anchors.ts +78 -0
- package/node_modules/pi-agent-text-editor/src/core/result-transfer.ts +175 -0
- package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +109 -11
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +6 -1
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +0 -75
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +211 -223
- package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +9 -6
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +5 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -7
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +8 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +8 -3
- package/node_modules/pi-agent-text-editor-renderer/index.ts +1 -72
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +19 -5
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +19 -45
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-80.js +1 -0
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/src/index.ts +7 -0
- package/node_modules/pi-agent-tool-ui/src/result-panel.ts +298 -0
- package/node_modules/pi-agent-web/index.ts +3 -0
- package/node_modules/pi-agent-web/package.json +8 -8
- package/node_modules/pi-agent-web/runtime/entry-82.js +2 -0
- package/node_modules/pi-agent-web/src/search.ts +111 -2
- package/node_modules/pi-agent-web-html/package.json +3 -3
- package/node_modules/pi-agent-web-image/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/package.json +35 -36
- package/src/composite/module-labels.ts +1 -1
- package/src/composite/preferences.ts +0 -5
- 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-web/index.ts +3 -0
- 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-83.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-pdf/package.json +4 -4
- 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/runtime/entry-82.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/search.ts +111 -2
- package/src/extensions/pi-agent-read/package.json +7 -7
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +2 -2
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +4 -0
- package/src/extensions/pi-agent-read/src/core/extension.ts +11 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/result-target.ts +93 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +2 -0
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +8 -1
- package/src/extensions/pi-agent-search/package.json +5 -5
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +3 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +7 -6
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/fuzzy-search.ts +164 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +161 -30
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +103 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +104 -17
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +89 -292
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +77 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +96 -11
- package/src/extensions/pi-agent-search/src/api/fuzzy.ts +208 -0
- package/src/extensions/pi-agent-search/src/api/presentation.ts +68 -0
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +9 -3
- package/src/extensions/pi-agent-search/src/api/search-scope.ts +22 -0
- package/src/extensions/pi-agent-search/src/api/search.ts +28 -0
- package/src/extensions/pi-agent-search/src/api/structured-result.ts +69 -14
- package/src/extensions/pi-agent-search/src/core/extension.ts +56 -16
- package/src/extensions/pi-agent-search/src/core/search-core.ts +9 -1
- package/src/extensions/pi-agent-text-editor/index.ts +0 -5
- package/src/extensions/pi-agent-text-editor/package.json +26 -31
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +1 -72
- 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-78.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +19 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +19 -45
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/runtime/entry-77.js +1 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +3 -1
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +1 -20
- package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +4 -23
- package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +2 -2
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +12 -2
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +29 -4
- package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/file-result-targets.ts +76 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result-targets.ts +168 -0
- package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +199 -19
- package/src/extensions/pi-agent-text-editor/src/core/result-input.ts +22 -0
- package/src/extensions/pi-agent-text-editor/src/core/result-target-anchors.ts +78 -0
- package/src/extensions/pi-agent-text-editor/src/core/result-transfer.ts +175 -0
- package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +109 -11
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +6 -1
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +0 -75
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +211 -223
- package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +9 -6
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +5 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -7
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +8 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +8 -3
- package/src/pi-agent-ide.ts +0 -6
- package/src/plugins/pi-agent-ide-ast/package.json +15 -10
- package/src/plugins/pi-agent-ide-ast/src/ast/constructs.ts +193 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/element-extent.ts +59 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +5 -1
- package/src/plugins/pi-agent-ide-ast/src/ast/selection.ts +204 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/syntax-tree.ts +2 -0
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +4 -2
- package/src/plugins/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +107 -21
- package/src/plugins/pi-agent-ide-ast/src/select-presentation.ts +104 -0
- package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +384 -0
- package/src/plugins/pi-agent-ide-ast/src/selection-region.ts +41 -0
- package/src/plugins/pi-agent-ide-ast/src/source-text.ts +92 -0
- package/src/plugins/pi-agent-ide-ast/src/text-selection.ts +214 -0
- package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +251 -0
- package/src/plugins/pi-agent-ide-changes/index.ts +2 -18
- package/src/plugins/pi-agent-ide-changes/package.json +8 -8
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +2 -2
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +11 -40
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- 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-lsp/index.ts +2 -2
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +5 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +8 -2
- package/src/plugins/pi-agent-ide-lsp/src/lsp/project.ts +19 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +204 -118
- package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +2 -17
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +88 -45
- package/src/plugins/pi-agent-ide-terminal/src/search.ts +10 -36
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +1 -1
- package/src/plugins/pi-agent-ide-vision/index.ts +19 -0
- package/dist/chunk-2P2OGO3G.js +0 -2
- package/dist/chunk-6EYWFBNG.js +0 -0
- package/dist/chunk-7AVXUV4A.js +0 -7
- package/dist/chunk-7WCZOO5I.js +0 -1
- package/dist/chunk-BAYETTZZ.js +0 -16
- package/dist/chunk-BVK5A7ED.js +0 -28
- package/dist/chunk-F7NVAC4Q.js +0 -0
- package/dist/chunk-FZBCKIJJ.js +0 -1
- package/dist/chunk-I5JLCFUX.js +0 -1
- package/dist/chunk-MIZAFRDR.js +0 -1
- package/dist/chunk-PJPA5EEE.js +0 -2
- package/dist/chunk-PXWDDBBC.js +0 -0
- package/dist/chunk-TQZBVOTT.js +0 -5
- package/dist/chunk-VWW3RLUX.js +0 -12
- package/dist/chunk-YHUTTZC6.js +0 -2
- package/dist/chunk-ZODCBFBL.js +0 -2
- package/dist/entry-87.js +0 -1
- package/docs/agent-guides/apply.md +0 -333
- package/node_modules/pi-agent-text-editor/src/api/apply-renderer.ts +0 -3
- package/node_modules/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +0 -159
- package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +0 -405
- package/node_modules/pi-agent-text-editor/src/core/apply/final-mutations.ts +0 -50
- package/node_modules/pi-agent-text-editor/src/core/apply/format-source.ts +0 -11
- package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +0 -203
- package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +0 -55
- package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +0 -276
- package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +0 -13
- package/node_modules/pi-agent-text-editor/src/core/apply/queue.ts +0 -25
- package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +0 -405
- package/node_modules/pi-agent-text-editor/src/core/apply/results.ts +0 -137
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +0 -369
- package/node_modules/pi-agent-text-editor/src/core/apply/structured-result.ts +0 -251
- package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +0 -168
- package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +0 -942
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +0 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-82.js +0 -1
- package/node_modules/pi-agent-web-text/runtime/entry-87.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-87.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-83.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +0 -2
- package/src/extensions/pi-agent-text-editor/runtime/entry-78.js +0 -2
- package/src/extensions/pi-agent-text-editor/src/api/apply-renderer.ts +0 -3
- package/src/extensions/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +0 -159
- package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +0 -405
- package/src/extensions/pi-agent-text-editor/src/core/apply/final-mutations.ts +0 -50
- package/src/extensions/pi-agent-text-editor/src/core/apply/format-source.ts +0 -11
- package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +0 -203
- package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +0 -55
- package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +0 -276
- package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +0 -13
- package/src/extensions/pi-agent-text-editor/src/core/apply/queue.ts +0 -25
- package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +0 -405
- package/src/extensions/pi-agent-text-editor/src/core/apply/results.ts +0 -137
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +0 -369
- package/src/extensions/pi-agent-text-editor/src/core/apply/structured-result.ts +0 -251
- package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +0 -168
- package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +0 -942
- /package/node_modules/{pi-agent-text-editor → pi-agent-text-editor-renderer}/runtime/entry-78.js +0 -0
- /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-79.js +0 -0
- /package/node_modules/{pi-agent-tool-call-interception → pi-agent-tool-ui}/runtime/entry-81.js +0 -0
- /package/node_modules/{pi-agent-web → pi-agent-web-html}/runtime/entry-83.js +0 -0
- /package/node_modules/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-84.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-85.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-86.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-84.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-85.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-86.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-79.js +0 -0
|
@@ -1,72 +1,115 @@
|
|
|
1
1
|
import { searchSymbols } from "./lsp/symbol-search.js";
|
|
2
|
-
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { selectionData, renderSearchMatches } from "pi-agent-search/api/search";
|
|
3
4
|
import type { LspManager } from "./lsp/manager.js";
|
|
4
5
|
import type { SymbolHit } from "./lsp/symbol-search.js";
|
|
5
|
-
import type { SearchResolver } from "pi-agent-search/api/search";
|
|
6
|
+
import type { SearchPluginApi, SearchResolver } from "pi-agent-search/api/search";
|
|
6
7
|
|
|
8
|
+
/** Expose strict LSP discovery and explicit reference navigation as shared source targets. */
|
|
7
9
|
export function createLspSearchResolver(
|
|
8
10
|
managerFor: (cwd: string) => Promise<LspManager>,
|
|
11
|
+
registerSelection: SearchPluginApi["registerSelection"],
|
|
9
12
|
): SearchResolver {
|
|
10
13
|
return {
|
|
11
14
|
id: "symbols",
|
|
15
|
+
supportsResultScope: true,
|
|
12
16
|
// Workspace symbol backends may read beyond the requested path.
|
|
13
17
|
readResources: (request) => (request.query.startsWith("symbols:") ? undefined : []),
|
|
14
18
|
toScriptData(payload) {
|
|
15
|
-
|
|
16
|
-
return {
|
|
17
|
-
kind: "custom",
|
|
18
|
-
resolverId: "symbols",
|
|
19
|
-
value: {
|
|
20
|
-
query,
|
|
21
|
-
hits: hits.map((hit) => ({
|
|
22
|
-
source: hit.filePath,
|
|
23
|
-
lineNumber: hit.lineNumber,
|
|
24
|
-
column: hit.column,
|
|
25
|
-
kind: hit.kind,
|
|
26
|
-
name: hit.name,
|
|
27
|
-
})),
|
|
28
|
-
},
|
|
29
|
-
};
|
|
19
|
+
return (payload as { readonly data: unknown }).data;
|
|
30
20
|
},
|
|
31
21
|
async tryResolve(request, context) {
|
|
32
|
-
if (!request.query.startsWith("symbols:")) {
|
|
33
|
-
return { kind: "not-handled" };
|
|
34
|
-
}
|
|
35
|
-
|
|
22
|
+
if (!request.query.startsWith("symbols:")) return { kind: "not-handled" };
|
|
36
23
|
const query = request.query.slice("symbols:".length).trim();
|
|
37
|
-
|
|
38
|
-
if (query.length === 0) {
|
|
24
|
+
if (query.length === 0)
|
|
39
25
|
return { kind: "failed", error: new Error("symbols: query must not be empty") };
|
|
40
|
-
}
|
|
41
|
-
|
|
42
26
|
const manager = await managerFor(context.cwd);
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
27
|
+
const collect = (signal?: AbortSignal) =>
|
|
28
|
+
searchSymbols(
|
|
29
|
+
query,
|
|
30
|
+
context.cwd,
|
|
31
|
+
request.limit ?? 100,
|
|
32
|
+
signal,
|
|
33
|
+
{ ...request, ...(context.scope === undefined ? {} : { resultScope: context.scope }) },
|
|
34
|
+
manager,
|
|
35
|
+
);
|
|
36
|
+
const found = await collect(context.signal);
|
|
37
|
+
const session = await registerSelection(
|
|
38
|
+
{
|
|
39
|
+
request,
|
|
40
|
+
matches: found.hits,
|
|
41
|
+
complete: found.complete,
|
|
42
|
+
refresh: async (signal) => {
|
|
43
|
+
const refreshed = await collect(signal);
|
|
44
|
+
return { matches: refreshed.hits, complete: refreshed.complete };
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
context,
|
|
50
48
|
);
|
|
51
|
-
|
|
49
|
+
const data = selectionData(found.hits, found.complete, session.id, session);
|
|
50
|
+
return {
|
|
51
|
+
kind: "resolved",
|
|
52
|
+
payload: {
|
|
53
|
+
query,
|
|
54
|
+
hits: found.hits,
|
|
55
|
+
complete: found.complete,
|
|
56
|
+
navigation: request.navigation,
|
|
57
|
+
data: {
|
|
58
|
+
...data,
|
|
59
|
+
matches: data.matches.map((match, index) => ({
|
|
60
|
+
...match,
|
|
61
|
+
role: found.hits[index]?.role,
|
|
62
|
+
symbol: found.hits[index]?.symbol,
|
|
63
|
+
})),
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
};
|
|
52
67
|
},
|
|
53
|
-
|
|
54
|
-
const
|
|
68
|
+
renderResult(result, options, theme) {
|
|
69
|
+
const data = result.details as {
|
|
70
|
+
hits: readonly SymbolHit[];
|
|
71
|
+
complete: boolean;
|
|
72
|
+
navigation?: "references";
|
|
73
|
+
cwd: string;
|
|
74
|
+
};
|
|
75
|
+
return renderSearchMatches(
|
|
76
|
+
data.hits,
|
|
77
|
+
data.complete,
|
|
78
|
+
theme,
|
|
79
|
+
options.expanded,
|
|
80
|
+
data.cwd,
|
|
81
|
+
data.navigation === "references"
|
|
82
|
+
? ["LSP reference navigation · may leave input scope"]
|
|
83
|
+
: [],
|
|
84
|
+
data.hits.map((hit) => `${hit.role} ${hit.symbol.name}`),
|
|
85
|
+
);
|
|
86
|
+
},
|
|
87
|
+
format(payload, context) {
|
|
88
|
+
const result = payload as {
|
|
55
89
|
readonly query: string;
|
|
56
90
|
readonly hits: readonly SymbolHit[];
|
|
91
|
+
readonly complete: boolean;
|
|
92
|
+
readonly navigation?: "references";
|
|
57
93
|
};
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
? "
|
|
61
|
-
:
|
|
94
|
+
const heading =
|
|
95
|
+
result.navigation === "references"
|
|
96
|
+
? "LSP reference navigation (may leave input scope)"
|
|
97
|
+
: "LSP symbols inside scope";
|
|
98
|
+
const lines =
|
|
99
|
+
result.hits.length === 0
|
|
100
|
+
? ["No symbols found."]
|
|
101
|
+
: result.hits
|
|
102
|
+
.slice(0, 100)
|
|
62
103
|
.map(
|
|
63
104
|
(hit, index) =>
|
|
64
|
-
`${String(index + 1)}. ${hit.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
105
|
+
`${String(index + 1)}. ${path.relative(context.cwd, hit.source)}:${String(hit.lineNumber)}:${String(hit.startColumn + 1)} ${hit.role} ${hit.symbol.name}`,
|
|
106
|
+
);
|
|
107
|
+
if (!result.complete) lines.push("Incomplete results; not a complete edit scope.");
|
|
108
|
+
if (result.hits.length > 100) lines.push("Preview shortened; full source targets retained.");
|
|
109
|
+
return {
|
|
110
|
+
content: [{ type: "text", text: [heading, ...lines].join("\n") }],
|
|
111
|
+
details: { ...result, cwd: context.cwd },
|
|
112
|
+
};
|
|
70
113
|
},
|
|
71
114
|
};
|
|
72
115
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-image",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./src/index.ts",
|
|
6
6
|
"exports": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"pi-agent-resource": "0.
|
|
13
|
+
"pi-agent-resource": "0.7.0"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"@earendil-works/pi-coding-agent": "*"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-pdf",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./src/index.ts",
|
|
6
6
|
"exports": {
|
|
@@ -11,6 +11,6 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"pdfjs-dist": "^6.2.108",
|
|
14
|
-
"pi-agent-resource": "0.
|
|
14
|
+
"pi-agent-resource": "0.7.0"
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-read",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"pi-agent-documentation": "0.
|
|
28
|
-
"pi-agent-invariant": "0.
|
|
29
|
-
"pi-agent-resource": "0.
|
|
30
|
-
"pi-agent-text": "0.
|
|
31
|
-
"pi-agent-tool-call-interception": "0.
|
|
32
|
-
"pi-agent-tool-ui": "0.
|
|
27
|
+
"pi-agent-documentation": "0.7.0",
|
|
28
|
+
"pi-agent-invariant": "0.7.0",
|
|
29
|
+
"pi-agent-resource": "0.7.0",
|
|
30
|
+
"pi-agent-text": "0.7.0",
|
|
31
|
+
"pi-agent-tool-call-interception": "0.7.0",
|
|
32
|
+
"pi-agent-tool-ui": "0.7.0"
|
|
33
33
|
},
|
|
34
34
|
"pi": {
|
|
35
35
|
"extensions": [
|
|
@@ -5,13 +5,13 @@ export const readParameters = Type.Object({
|
|
|
5
5
|
path: Type.Optional(
|
|
6
6
|
Type.String({
|
|
7
7
|
description:
|
|
8
|
-
"What to read: a supported resource such as a file or directory path, URL, returned temp: reference, SEARCH# reference, or registered protocol source. Supply a path; an empty call cannot select a source.",
|
|
8
|
+
"What to read: a supported resource such as a file or directory path, URL, returned temp: reference, SEARCH# or RESULT# reference, or registered protocol source. Supply a path; an empty call cannot select a source.",
|
|
9
9
|
}),
|
|
10
10
|
),
|
|
11
11
|
offset: Type.Optional(
|
|
12
12
|
Type.Number({
|
|
13
13
|
description:
|
|
14
|
-
"For raw: sources, use a zero-based byte offset; negative offsets count from the file end. For other sources: first line to return, numbered from 1. Omit or use 0 to start at line 1; -1 starts at the last line, -10 at the tenth line from the end. For path#anchor or
|
|
14
|
+
"For raw: sources, use a zero-based byte offset; negative offsets count from the file end. For other sources: first line to return, numbered from 1. Omit or use 0 to start at line 1; -1 starts at the last line, -10 at the tenth line from the end. For path#anchor, SEARCH or RESULT# selections, count from its containing line instead: 0 or 1 starts there, 2 starts one line later, -1 one line earlier. For image and sequence views, offset is a zero-based row-major grid cell index and requires limit.",
|
|
15
15
|
}),
|
|
16
16
|
),
|
|
17
17
|
limit: Type.Optional(
|
|
@@ -144,6 +144,8 @@ export interface ReadPipelineContext {
|
|
|
144
144
|
/** Data execution keeps full requested content; presentation handlers must not compact it. */
|
|
145
145
|
readonly audience?: "agent" | "script";
|
|
146
146
|
readonly request: ReadRequest;
|
|
147
|
+
/** Original RESULT# scope bounds source authority even when Read shows surrounding lines. */
|
|
148
|
+
readonly sourceTarget?: string;
|
|
147
149
|
readonly resolverContext: ResourceResolverContext;
|
|
148
150
|
readonly state?: ReadState;
|
|
149
151
|
readonly result?: ReadToolResult;
|
|
@@ -199,6 +201,8 @@ export type ReadScriptData =
|
|
|
199
201
|
}
|
|
200
202
|
| {
|
|
201
203
|
readonly kind: "text";
|
|
204
|
+
/** Strict source-window handle, independent of preview truncation. */
|
|
205
|
+
readonly target?: string;
|
|
202
206
|
readonly source: string;
|
|
203
207
|
readonly content: string;
|
|
204
208
|
readonly lines: readonly ReadTextLine[];
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { connectResultTargets } from "pi-agent-resource";
|
|
3
|
+
import { createReadResultTargetHandler } from "#src/core/tools/read/result-target.js";
|
|
2
4
|
import { connectAgentDocumentation, loadPackagedAgentGuide } from "pi-agent-documentation";
|
|
3
5
|
import {
|
|
4
6
|
ToolCallInterceptionRenderStore,
|
|
@@ -35,6 +37,15 @@ export default async function registerReadCore(
|
|
|
35
37
|
}),
|
|
36
38
|
]);
|
|
37
39
|
const core = createReadCore(parsePresentation(context?.preferences["ui.read"]));
|
|
40
|
+
const targets = connectResultTargets(pi);
|
|
41
|
+
await core.registerPlugin({
|
|
42
|
+
protocol: READ_PROTOCOL,
|
|
43
|
+
apiVersion: READ_API_VERSION,
|
|
44
|
+
id: "result-targets",
|
|
45
|
+
setup(api) {
|
|
46
|
+
api.addHandler({ stage: "post-read", handler: createReadResultTargetHandler(targets) });
|
|
47
|
+
},
|
|
48
|
+
});
|
|
38
49
|
|
|
39
50
|
const unsubscribeRegistration = pi.events.on(READ_PLUGIN_REGISTER_EVENT, (request) => {
|
|
40
51
|
if (!isReadPluginRegistrationRequest(request)) {
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import type { ResultRange, ResultTargetStore } from "pi-agent-resource";
|
|
3
|
+
import type { ReadPostReadHandler } from "#src/api/tools/read.js";
|
|
4
|
+
|
|
5
|
+
/** Attach source authority only when the read still maps to exact filesystem text. */
|
|
6
|
+
export function createReadResultTargetHandler(store: ResultTargetStore): ReadPostReadHandler {
|
|
7
|
+
return async (context) => {
|
|
8
|
+
const state = context.state;
|
|
9
|
+
if (state?.contentKind !== "text" || state.resolvedBy !== "filesystem")
|
|
10
|
+
return { kind: "continue", context };
|
|
11
|
+
let content: string;
|
|
12
|
+
try {
|
|
13
|
+
content = await readFile(state.source, {
|
|
14
|
+
encoding: "utf8",
|
|
15
|
+
signal: context.resolverContext.signal,
|
|
16
|
+
});
|
|
17
|
+
} catch {
|
|
18
|
+
context.resolverContext.signal?.throwIfAborted();
|
|
19
|
+
return { kind: "continue", context };
|
|
20
|
+
}
|
|
21
|
+
if (content !== state.text.content) return { kind: "continue", context };
|
|
22
|
+
const input =
|
|
23
|
+
context.sourceTarget === undefined
|
|
24
|
+
? undefined
|
|
25
|
+
: store.resolve(context.sourceTarget, context.resolverContext.cwd);
|
|
26
|
+
const sources = input?.targets.filter((target) => target.source === state.source);
|
|
27
|
+
if (sources?.some((target) => target.expectedContent !== content))
|
|
28
|
+
return { kind: "continue", context };
|
|
29
|
+
return {
|
|
30
|
+
kind: "continue",
|
|
31
|
+
context,
|
|
32
|
+
transform(result) {
|
|
33
|
+
const script = result.script;
|
|
34
|
+
if (result.isError || script?.kind !== "text" || script.source !== state.source)
|
|
35
|
+
return result;
|
|
36
|
+
if (
|
|
37
|
+
!script.lines.every((line) => {
|
|
38
|
+
const original = state.text.lines[line.lineNumber - 1];
|
|
39
|
+
return original?.content === line.content && original.lineEnding === line.lineEnding;
|
|
40
|
+
})
|
|
41
|
+
)
|
|
42
|
+
return result;
|
|
43
|
+
const first = script.lines[0];
|
|
44
|
+
const last = script.lines.at(-1);
|
|
45
|
+
const window: ResultRange | undefined =
|
|
46
|
+
first === undefined || last === undefined
|
|
47
|
+
? content.length === 0
|
|
48
|
+
? {
|
|
49
|
+
start: { lineNumber: 1, column: 0 },
|
|
50
|
+
end: { lineNumber: 1, column: 0 },
|
|
51
|
+
}
|
|
52
|
+
: undefined
|
|
53
|
+
: {
|
|
54
|
+
start: { lineNumber: first.lineNumber, column: 0 },
|
|
55
|
+
end:
|
|
56
|
+
last.lineEnding.length > 0
|
|
57
|
+
? { lineNumber: last.lineNumber + 1, column: 0 }
|
|
58
|
+
: { lineNumber: last.lineNumber, column: last.content.length },
|
|
59
|
+
linewise: true,
|
|
60
|
+
};
|
|
61
|
+
const ranges =
|
|
62
|
+
window === undefined
|
|
63
|
+
? []
|
|
64
|
+
: sources === undefined
|
|
65
|
+
? [window]
|
|
66
|
+
: sources.flatMap((source) =>
|
|
67
|
+
source.ranges.flatMap((range) => intersectRange(range, window)),
|
|
68
|
+
);
|
|
69
|
+
const target = store.register(
|
|
70
|
+
ranges.length === 0 ? [] : [{ source: state.source, expectedContent: content, ranges }],
|
|
71
|
+
context.resolverContext.cwd,
|
|
72
|
+
input?.complete ?? true,
|
|
73
|
+
);
|
|
74
|
+
return { ...result, script: { ...script, target } };
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function comparePosition(left: ResultRange["start"], right: ResultRange["start"]): number {
|
|
81
|
+
return left.lineNumber - right.lineNumber || left.column - right.column;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function intersectRange(range: ResultRange, window: ResultRange): ResultRange[] {
|
|
85
|
+
const start = comparePosition(range.start, window.start) >= 0 ? range.start : window.start;
|
|
86
|
+
const end = comparePosition(range.end, window.end) <= 0 ? range.end : window.end;
|
|
87
|
+
if (
|
|
88
|
+
comparePosition(start, end) > 0 ||
|
|
89
|
+
(comparePosition(start, end) === 0 && comparePosition(range.start, range.end) !== 0)
|
|
90
|
+
)
|
|
91
|
+
return [];
|
|
92
|
+
return [{ start, end }];
|
|
93
|
+
}
|
|
@@ -30,6 +30,7 @@ const text = Type.Object(
|
|
|
30
30
|
{
|
|
31
31
|
...common,
|
|
32
32
|
kind: Type.Literal("text"),
|
|
33
|
+
target: Type.Optional(Type.String()),
|
|
33
34
|
lines: Type.Array(line),
|
|
34
35
|
startLine: Type.Integer(),
|
|
35
36
|
endLine: Type.Integer(),
|
|
@@ -161,6 +162,7 @@ function publicData(value: ReadScriptData): unknown {
|
|
|
161
162
|
endLine: lines.at(-1)?.lineNumber ?? 0,
|
|
162
163
|
totalLines: value.totalLines,
|
|
163
164
|
truncated,
|
|
165
|
+
...(value.target === undefined ? {} : { target: value.target }),
|
|
164
166
|
...(value.references === undefined ? {} : { references: value.references }),
|
|
165
167
|
...(truncated || endLine < value.totalLines
|
|
166
168
|
? { continuation: { path: value.source, offset: endLine + 1 } }
|
|
@@ -606,8 +606,15 @@ async function resolveTextTargets(
|
|
|
606
606
|
{ start: { lineNumber: 1, column: 0 }, end: { lineNumber: 1, column: 1 } },
|
|
607
607
|
];
|
|
608
608
|
return ranges.map(async (range): Promise<ReadToolResult> => {
|
|
609
|
-
const
|
|
609
|
+
const sourceTarget = request.path?.startsWith("RESULT#") ? request.path : undefined;
|
|
610
|
+
const rangeLimit = Math.max(
|
|
611
|
+
1,
|
|
612
|
+
range.end.lineNumber -
|
|
613
|
+
range.start.lineNumber +
|
|
614
|
+
(sourceTarget !== undefined && range.end.column > 0 ? 1 : 0),
|
|
615
|
+
);
|
|
610
616
|
let rangePipeline: ReadPipelineContext = {
|
|
617
|
+
sourceTarget,
|
|
611
618
|
request: {
|
|
612
619
|
...request,
|
|
613
620
|
path: target.source,
|
|
@@ -86,3 +86,13 @@ export {
|
|
|
86
86
|
isResourceResolutionAttempt,
|
|
87
87
|
isResourceResolver,
|
|
88
88
|
} from "./validation.js";
|
|
89
|
+
|
|
90
|
+
export {
|
|
91
|
+
connectResultTargets,
|
|
92
|
+
verifyResultTargets,
|
|
93
|
+
ResultTargetStore,
|
|
94
|
+
resultInputSchema,
|
|
95
|
+
type ResultRange,
|
|
96
|
+
type ResultSourceTarget,
|
|
97
|
+
type ResolvedResultTargets,
|
|
98
|
+
} from "./result-targets.js";
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { Type } from "typebox";
|
|
5
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
6
|
+
|
|
7
|
+
/** Serializable source coordinates. Lines are one-based; columns are UTF-16 offsets. */
|
|
8
|
+
export interface ResultRange {
|
|
9
|
+
readonly start: { readonly lineNumber: number; readonly column: number };
|
|
10
|
+
readonly end: { readonly lineNumber: number; readonly column: number };
|
|
11
|
+
readonly linewise?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Backend-owned text targets; never accepted directly from untrusted JSON. */
|
|
15
|
+
export interface ResultSourceTarget {
|
|
16
|
+
readonly source: string;
|
|
17
|
+
readonly expectedContent: string;
|
|
18
|
+
readonly ranges: readonly ResultRange[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** A resolved input keeps completeness separate from the size of its public preview. */
|
|
22
|
+
export interface ResolvedResultTargets {
|
|
23
|
+
readonly targets: readonly ResultSourceTarget[];
|
|
24
|
+
readonly complete: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Tool inputs allow returned result objects and JS-selected arrays. The store validates authority. */
|
|
28
|
+
export const resultInputSchema = Type.Union([
|
|
29
|
+
Type.String(),
|
|
30
|
+
Type.Object({}, { additionalProperties: true }),
|
|
31
|
+
Type.Array(Type.Unknown()),
|
|
32
|
+
]);
|
|
33
|
+
|
|
34
|
+
const prefix = "RESULT#";
|
|
35
|
+
const event = "pi-agent-resource:result-targets";
|
|
36
|
+
|
|
37
|
+
type ResultEntry = { readonly cwd: string } & (
|
|
38
|
+
| (ResolvedResultTargets & { readonly state: "ready" })
|
|
39
|
+
| { readonly state: "pending" }
|
|
40
|
+
| { readonly state: "rejected"; readonly reason: string }
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
/** Stores immutable source selections for one extension runtime, isolated by worktree. */
|
|
44
|
+
export class ResultTargetStore {
|
|
45
|
+
readonly #entries = new Map<string, ResultEntry>();
|
|
46
|
+
|
|
47
|
+
/** Forget results when the session closes or the extensions reload. */
|
|
48
|
+
public clear(): void {
|
|
49
|
+
this.#entries.clear();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Register trusted resolver data, not a live Resource or agent-supplied coordinates. */
|
|
53
|
+
public register(targets: readonly ResultSourceTarget[], cwd: string, complete = true): string {
|
|
54
|
+
const reference = `${prefix}${randomUUID()}`;
|
|
55
|
+
this.#entries.set(reference, {
|
|
56
|
+
state: "ready",
|
|
57
|
+
targets: combineTargets(targets),
|
|
58
|
+
complete,
|
|
59
|
+
cwd: path.resolve(cwd),
|
|
60
|
+
});
|
|
61
|
+
return reference;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Reserve an operation result before writing. It has no source authority until confirmed. */
|
|
65
|
+
public reserve(cwd: string): string {
|
|
66
|
+
const reference = `${prefix}${randomUUID()}`;
|
|
67
|
+
this.#entries.set(reference, { state: "pending", cwd: path.resolve(cwd) });
|
|
68
|
+
return reference;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Resolve one pending operation to an immutable committed snapshot, exactly once. */
|
|
72
|
+
public confirm(reference: string, targets: readonly ResultSourceTarget[], cwd: string): void {
|
|
73
|
+
const entry = this.#entries.get(reference);
|
|
74
|
+
if (entry?.state !== "pending" || entry.cwd !== path.resolve(cwd))
|
|
75
|
+
throw new Error("Only a pending result in this worktree can be confirmed.");
|
|
76
|
+
this.#entries.set(reference, {
|
|
77
|
+
state: "ready",
|
|
78
|
+
cwd: entry.cwd,
|
|
79
|
+
targets: combineTargets(targets),
|
|
80
|
+
complete: true,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Failed or cancelled operations cannot turn their reserved handle into live text. */
|
|
85
|
+
public reject(reference: string, reason: string): void {
|
|
86
|
+
const entry = this.#entries.get(reference);
|
|
87
|
+
if (entry?.state !== "pending") return;
|
|
88
|
+
this.#entries.set(reference, { state: "rejected", cwd: entry.cwd, reason });
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Traverse supported result shapes and resolve only registered source targets. */
|
|
92
|
+
public resolve(input: unknown, cwd: string): ResolvedResultTargets {
|
|
93
|
+
const references = this.#references(input);
|
|
94
|
+
const targets: ResultSourceTarget[] = [];
|
|
95
|
+
let complete = true;
|
|
96
|
+
for (const reference of references) {
|
|
97
|
+
const entry = this.#entries.get(reference);
|
|
98
|
+
if (entry === undefined)
|
|
99
|
+
throw new Error("Result target expired or unknown; repeat Read/Search.");
|
|
100
|
+
if (entry.cwd !== path.resolve(cwd))
|
|
101
|
+
throw new Error("Result target belongs to another worktree.");
|
|
102
|
+
if (entry.state === "pending")
|
|
103
|
+
throw new Error("Result target is pending; its write has not been confirmed.");
|
|
104
|
+
if (entry.state === "rejected") throw new Error(entry.reason);
|
|
105
|
+
complete &&= entry.complete;
|
|
106
|
+
targets.push(...entry.targets);
|
|
107
|
+
}
|
|
108
|
+
return { targets: combineTargets(targets), complete };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Resolve individual ranges in declared handle order for one-to-one source/destination pairs. */
|
|
112
|
+
public resolveOrdered(input: unknown, cwd: string): ResolvedResultTargets {
|
|
113
|
+
const resolved = this.resolve(input, cwd);
|
|
114
|
+
const targets: ResultSourceTarget[] = [];
|
|
115
|
+
const seen = new Set<string>();
|
|
116
|
+
for (const reference of new Set(this.#references(input))) {
|
|
117
|
+
for (const target of this.resolve(reference, cwd).targets) {
|
|
118
|
+
for (const range of target.ranges) {
|
|
119
|
+
const identity = JSON.stringify([target.source, range]);
|
|
120
|
+
if (seen.has(identity)) continue;
|
|
121
|
+
seen.add(identity);
|
|
122
|
+
targets.push({ ...target, ranges: [range] });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return { targets, complete: resolved.complete };
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Reject changed source bytes before a consumer uses a retained selection. */
|
|
130
|
+
public async verify(result: ResolvedResultTargets, signal?: AbortSignal): Promise<void> {
|
|
131
|
+
await verifyResultTargets(result, signal);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
#references(input: unknown): string[] {
|
|
135
|
+
if (typeof input === "string" && input.startsWith(prefix)) return [input];
|
|
136
|
+
if (Array.isArray(input)) return input.flatMap((child) => this.#references(child));
|
|
137
|
+
if (input === null || typeof input !== "object") throw new Error("Unsupported result input.");
|
|
138
|
+
const value = input as Record<string, unknown>;
|
|
139
|
+
if ("status" in value) {
|
|
140
|
+
if (value.status !== "success")
|
|
141
|
+
throw new Error("Only successful source results can be consumed.");
|
|
142
|
+
return this.#references(value.data);
|
|
143
|
+
}
|
|
144
|
+
if (typeof value.target === "string" && value.target.startsWith(prefix)) return [value.target];
|
|
145
|
+
if (value.kind === "resources" && Array.isArray(value.resources))
|
|
146
|
+
return this.#references(value.resources);
|
|
147
|
+
throw new Error(
|
|
148
|
+
"This result has no supported source target; do not use preview text as a source.",
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** Verify retained source snapshots for tools and provider refresh operations. */
|
|
154
|
+
export async function verifyResultTargets(
|
|
155
|
+
result: ResolvedResultTargets,
|
|
156
|
+
signal?: AbortSignal,
|
|
157
|
+
): Promise<void> {
|
|
158
|
+
const contents = new Map<string, string>();
|
|
159
|
+
for (const target of result.targets) {
|
|
160
|
+
signal?.throwIfAborted();
|
|
161
|
+
let current = contents.get(target.source);
|
|
162
|
+
if (current === undefined) {
|
|
163
|
+
current = await readFile(target.source, { encoding: "utf8", signal });
|
|
164
|
+
contents.set(target.source, current);
|
|
165
|
+
}
|
|
166
|
+
if (current !== target.expectedContent)
|
|
167
|
+
throw new Error("Result target is stale; repeat Read/Search.");
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function combineTargets(targets: readonly ResultSourceTarget[]): ResultSourceTarget[] {
|
|
171
|
+
const grouped = new Map<
|
|
172
|
+
string,
|
|
173
|
+
{ source: string; expectedContent: string; ranges: ResultRange[]; seen: Set<string> }
|
|
174
|
+
>();
|
|
175
|
+
for (const target of targets) {
|
|
176
|
+
const previous = grouped.get(target.source);
|
|
177
|
+
if (previous !== undefined && previous.expectedContent !== target.expectedContent)
|
|
178
|
+
throw new Error("Result targets refer to different snapshots of the same source.");
|
|
179
|
+
const combined = previous ?? {
|
|
180
|
+
source: target.source,
|
|
181
|
+
expectedContent: target.expectedContent,
|
|
182
|
+
ranges: [],
|
|
183
|
+
seen: new Set<string>(),
|
|
184
|
+
};
|
|
185
|
+
for (const range of target.ranges) {
|
|
186
|
+
const key = JSON.stringify(range);
|
|
187
|
+
if (combined.seen.has(key)) continue;
|
|
188
|
+
combined.seen.add(key);
|
|
189
|
+
combined.ranges.push(structuredClone(range));
|
|
190
|
+
}
|
|
191
|
+
grouped.set(target.source, combined);
|
|
192
|
+
}
|
|
193
|
+
return [...grouped.values()]
|
|
194
|
+
.filter((target) => target.ranges.length > 0)
|
|
195
|
+
.map(({ seen: _seen, ...target }) => ({
|
|
196
|
+
...target,
|
|
197
|
+
ranges: target.ranges.sort(
|
|
198
|
+
(left, right) =>
|
|
199
|
+
left.start.lineNumber - right.start.lineNumber ||
|
|
200
|
+
left.start.column - right.start.column ||
|
|
201
|
+
left.end.lineNumber - right.end.lineNumber ||
|
|
202
|
+
left.end.column - right.end.column,
|
|
203
|
+
),
|
|
204
|
+
}));
|
|
205
|
+
}
|
|
206
|
+
/** Share one backend store through Pi's extension event bus, without process-global state. */
|
|
207
|
+
export function connectResultTargets(pi: ExtensionAPI): ResultTargetStore {
|
|
208
|
+
let existing: ResultTargetStore | undefined;
|
|
209
|
+
pi.events.emit(event, {
|
|
210
|
+
accept: (store: ResultTargetStore) => {
|
|
211
|
+
existing = store;
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
if (existing !== undefined) return existing;
|
|
215
|
+
const store = new ResultTargetStore();
|
|
216
|
+
const unsubscribe = pi.events.on(event, (request) => {
|
|
217
|
+
if (
|
|
218
|
+
request !== null &&
|
|
219
|
+
typeof request === "object" &&
|
|
220
|
+
"accept" in request &&
|
|
221
|
+
typeof request.accept === "function"
|
|
222
|
+
)
|
|
223
|
+
(request.accept as (store: ResultTargetStore) => void)(store);
|
|
224
|
+
});
|
|
225
|
+
pi.on("session_start", () => {
|
|
226
|
+
store.clear();
|
|
227
|
+
});
|
|
228
|
+
pi.on("session_shutdown", () => {
|
|
229
|
+
store.clear();
|
|
230
|
+
unsubscribe();
|
|
231
|
+
});
|
|
232
|
+
return store;
|
|
233
|
+
}
|