pi-agent-ide 0.6.4 → 0.7.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 +45 -0
- package/README.md +2 -2
- package/dist/{chunk-AWXVJ5AC.js → chunk-2RTCSZB3.js} +1 -1
- package/dist/chunk-2TRHFMCZ.js +11 -0
- package/dist/{chunk-WJTHY6AG.js → chunk-4GCWGE2C.js} +1 -1
- package/dist/chunk-4XMY4H4V.js +1 -0
- package/dist/{chunk-BSICWXMH.js → chunk-64M3SQPG.js} +1 -1
- package/dist/{chunk-QEJGED4V.js → chunk-76ZK5ODR.js} +2 -2
- package/dist/{chunk-3BBJZSMS.js → chunk-7LD2OQH3.js} +1 -1
- package/dist/{chunk-6CZO43OH.js → chunk-BU7IZLKB.js} +1 -1
- package/dist/chunk-CWD4O5PM.js +3 -0
- package/dist/chunk-D3WTDA6V.js +2 -0
- package/dist/chunk-EAZGN5ND.js +7 -0
- package/dist/chunk-GXEGY7GV.js +1 -0
- package/dist/chunk-HZEY4GT4.js +2 -0
- package/dist/chunk-LEEQIQ7D.js +28 -0
- package/dist/chunk-NRZO5KJT.js +9 -0
- package/dist/chunk-OMVRLWMX.js +5 -0
- package/dist/{chunk-VBICI5YA.js → chunk-PGIVHICI.js} +1 -1
- package/dist/{chunk-FBOW7XOV.js → chunk-PKKDDIWW.js} +1 -1
- package/dist/chunk-PNU3E7IO.js +3 -0
- package/dist/chunk-PS2B6THP.js +3 -0
- package/dist/{chunk-FUG2TEKI.js → chunk-QFTBY67N.js} +2 -2
- package/dist/{chunk-EDURPQAV.js → chunk-QRJLIV6P.js} +6 -6
- package/dist/{chunk-OBNING2A.js → chunk-S5PL5DFQ.js} +1 -1
- package/dist/chunk-VMTR74FF.js +2 -0
- package/dist/{chunk-HPUAIWIH.js → chunk-WMO6RNE2.js} +1 -1
- package/dist/chunk-WU6ZK6YD.js +1 -0
- package/dist/{chunk-GIRAEVUJ.js → chunk-XH5WN5XA.js} +1 -1
- package/dist/chunk-XYS4FSCC.js +12 -0
- package/dist/chunk-YP46DVVP.js +2 -0
- 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 +2 -2
- package/dist/entry-26.js +1 -1
- package/dist/entry-27.js +2 -2
- 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 +12 -9
- package/dist/entry-33.js +1 -1
- package/dist/entry-37.js +6 -6
- package/dist/entry-41.js +1 -1
- package/dist/entry-42.js +1 -1
- package/dist/entry-43.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +13 -14
- 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-57.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 +66 -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 +14 -9
- package/docs/agent-guides/editing.md +38 -33
- package/docs/agent-guides/git-changes.md +1 -1
- package/docs/agent-guides/read-resources.md +8 -4
- package/docs/agent-guides/search-code.md +34 -2
- package/docs/agent-guides/select-code.md +115 -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 +30 -38
- package/docs/tools.md +11 -11
- 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/index.ts +7 -6
- 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/index.ts +4 -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 +10 -5
- package/node_modules/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +142 -27
- 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 +268 -0
- package/node_modules/pi-agent-ide-changes/index.ts +6 -21
- 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 +5 -5
- 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 +92 -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/plugin-protocol.ts +1 -1
- package/node_modules/pi-agent-read/src/api/read-parameters.ts +40 -3
- package/node_modules/pi-agent-read/src/api/tools/read.ts +11 -1
- package/node_modules/pi-agent-read/src/core/extension.ts +18 -1
- package/node_modules/pi-agent-read/src/core/read-core.ts +50 -35
- 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 +5 -3
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +17 -3
- 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 +407 -0
- package/node_modules/pi-agent-resource/src/tool-result.ts +13 -1
- 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/index.ts +65 -4
- package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-exact/src/anchor.ts +12 -2
- package/node_modules/pi-agent-text-anchor-line-hash/index.ts +4 -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-result.ts +3 -1
- 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 +22 -5
- 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 +4 -14
- 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 +217 -30
- 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 +86 -154
- 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 +238 -244
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +9 -11
- 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-call-interception/src/index.ts +3 -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 +7 -3
- 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/composite/text-results.ts +221 -0
- package/src/documentation/extension.ts +11 -9
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +7 -6
- 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/index.ts +4 -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 +7 -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-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/plugin-protocol.ts +1 -1
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +40 -3
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +11 -1
- package/src/extensions/pi-agent-read/src/core/extension.ts +18 -1
- package/src/extensions/pi-agent-read/src/core/read-core.ts +50 -35
- 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 +5 -3
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +17 -3
- 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/index.ts +65 -4
- 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-exact/src/anchor.ts +12 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +4 -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-result.ts +3 -1
- 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 +22 -5
- 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 +4 -14
- 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 +217 -30
- 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 +86 -154
- 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 +238 -244
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +9 -11
- 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 +4 -7
- 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 +10 -5
- package/src/plugins/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +142 -27
- 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 +268 -0
- package/src/plugins/pi-agent-ide-changes/index.ts +6 -21
- 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-debugger/index.ts +5 -3
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +5 -3
- 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 +5 -5
- 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 +92 -45
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +8 -6
- 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 +31 -4
- package/dist/chunk-2P2OGO3G.js +0 -2
- package/dist/chunk-5J43L2RL.js +0 -11
- 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-KUPHNMUK.js +0 -2
- package/dist/chunk-MIZAFRDR.js +0 -1
- package/dist/chunk-PJPA5EEE.js +0 -2
- package/dist/chunk-PXWDDBBC.js +0 -0
- package/dist/chunk-SILJ3OL4.js +0 -9
- 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
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
import {
|
|
4
|
+
sourceRows,
|
|
5
|
+
type ResultPanelModel,
|
|
6
|
+
type ResultPanelRow,
|
|
7
|
+
type SourcePreview,
|
|
8
|
+
} from "pi-agent-tool-ui";
|
|
9
|
+
import type { SelectedRegion } from "./selection-region.js";
|
|
10
|
+
|
|
11
|
+
/** Render verified snapshot context separately from agent previews and target authority. */
|
|
12
|
+
export function selectPresentation(
|
|
13
|
+
regions: readonly SelectedRegion[],
|
|
14
|
+
complete: boolean,
|
|
15
|
+
missingInputs: number,
|
|
16
|
+
cwd: string,
|
|
17
|
+
): ResultPanelModel {
|
|
18
|
+
const groups = new Map<string, SelectedRegion[]>();
|
|
19
|
+
for (const region of regions) {
|
|
20
|
+
const group = groups.get(region.target.source);
|
|
21
|
+
if (group) group.push(region);
|
|
22
|
+
else groups.set(region.target.source, [region]);
|
|
23
|
+
}
|
|
24
|
+
const rows: ResultPanelRow[] = [];
|
|
25
|
+
if (!regions.length) rows.push({ kind: "note", text: "No selections" });
|
|
26
|
+
if (!complete) rows.push({ kind: "note", text: "Incomplete input; not a complete edit scope" });
|
|
27
|
+
if (missingInputs)
|
|
28
|
+
rows.push({ kind: "note", text: `${missingInputs} input(s) without a selection` });
|
|
29
|
+
let remaining = 100;
|
|
30
|
+
for (const [source, selected] of groups) {
|
|
31
|
+
if (!remaining) break;
|
|
32
|
+
const shown = selected.slice(0, remaining);
|
|
33
|
+
remaining -= shown.length;
|
|
34
|
+
const label = path.relative(cwd, source) || path.basename(source);
|
|
35
|
+
const previews: SourcePreview[] = [];
|
|
36
|
+
let shortened = false;
|
|
37
|
+
const content = selected[0]?.target.expectedContent.split(/\r\n|\n|\r/u) ?? [];
|
|
38
|
+
for (const region of shown) {
|
|
39
|
+
const { start, end } = region.range;
|
|
40
|
+
const point = start.lineNumber === end.lineNumber && start.column === end.column;
|
|
41
|
+
const last = point ? start.lineNumber : end.lineNumber - (end.column === 0 ? 1 : 0);
|
|
42
|
+
const through = Math.min(last, start.lineNumber + 19);
|
|
43
|
+
shortened ||= through < last;
|
|
44
|
+
for (let number = start.lineNumber; number <= through; number++) {
|
|
45
|
+
const text = content[number - 1] ?? "";
|
|
46
|
+
previews.push({
|
|
47
|
+
source,
|
|
48
|
+
label,
|
|
49
|
+
link: pathToFileURL(source).href,
|
|
50
|
+
lineNumber: number,
|
|
51
|
+
text,
|
|
52
|
+
ranges: [
|
|
53
|
+
{
|
|
54
|
+
from: number === start.lineNumber ? start.column : 0,
|
|
55
|
+
to: number === end.lineNumber ? end.column : text.length,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const groupRows = sourceRows(previews);
|
|
62
|
+
rows.push(
|
|
63
|
+
...groupRows.map((row) => (row.kind === "source" ? { ...row, count: selected.length } : row)),
|
|
64
|
+
);
|
|
65
|
+
if (shortened)
|
|
66
|
+
rows.push({ kind: "note", text: "… selection preview shortened · full target retained" });
|
|
67
|
+
for (const region of shown) {
|
|
68
|
+
if (
|
|
69
|
+
region.range.start.lineNumber === region.range.end.lineNumber &&
|
|
70
|
+
region.range.start.column === region.range.end.column
|
|
71
|
+
)
|
|
72
|
+
rows.push({
|
|
73
|
+
kind: "note",
|
|
74
|
+
text: `zero-width · ${region.range.start.lineNumber}:${region.range.start.column}`,
|
|
75
|
+
});
|
|
76
|
+
const { start, end } = region.range;
|
|
77
|
+
rows.push({
|
|
78
|
+
kind: "note",
|
|
79
|
+
expandedOnly: true,
|
|
80
|
+
text: `${region.syntax ? `${region.syntax.object}${region.syntax.part ? `/${region.syntax.part}` : ""} · ` : ""}${start.lineNumber}:${start.column}–${end.lineNumber}:${end.column} · ${region.origins.length} origin(s)${region.origins.some((o) => o.expanded) ? " · expanded" : ""}`,
|
|
81
|
+
});
|
|
82
|
+
for (const origin of region.origins.slice(0, 20)) {
|
|
83
|
+
const r = origin.range;
|
|
84
|
+
rows.push({
|
|
85
|
+
kind: "note",
|
|
86
|
+
expandedOnly: true,
|
|
87
|
+
text: `from ${r.startLine}:${r.startColumn}–${r.endLine}:${r.endColumn}`,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
if (region.origins.length > 20)
|
|
91
|
+
rows.push({
|
|
92
|
+
kind: "note",
|
|
93
|
+
expandedOnly: true,
|
|
94
|
+
text: "… more origins retained in this result reference",
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (regions.length > 100)
|
|
99
|
+
rows.push({ kind: "note", text: "… more selections · consume the complete result target" });
|
|
100
|
+
return {
|
|
101
|
+
summary: `${regions.length} ${regions.length === 1 ? "selection" : "selections"} in ${groups.size} ${groups.size === 1 ? "file" : "files"}${complete ? "" : " · incomplete"}`,
|
|
102
|
+
rows,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
import { Type, type Static } from "typebox";
|
|
2
|
+
import { resultInputSchema, structuredResultSchema } from "pi-agent-resource";
|
|
3
|
+
|
|
4
|
+
const textOperationSchema = Type.Union([
|
|
5
|
+
Type.Object(
|
|
6
|
+
{
|
|
7
|
+
kind: Type.Literal("range"),
|
|
8
|
+
startLine: Type.Integer({ minimum: 1 }),
|
|
9
|
+
startColumn: Type.Integer({ minimum: 0 }),
|
|
10
|
+
endLine: Type.Integer({ minimum: 1 }),
|
|
11
|
+
endColumn: Type.Integer({ minimum: 0 }),
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
additionalProperties: false,
|
|
15
|
+
description:
|
|
16
|
+
"Use absolute one-based lines and exclusive UTF-16 columns in one source. Require full containment in an input region.",
|
|
17
|
+
},
|
|
18
|
+
),
|
|
19
|
+
Type.Object(
|
|
20
|
+
{
|
|
21
|
+
kind: Type.Literal("lines"),
|
|
22
|
+
first: Type.Integer({ minimum: 1 }),
|
|
23
|
+
last: Type.Integer({ minimum: 1 }),
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
additionalProperties: false,
|
|
27
|
+
description:
|
|
28
|
+
"Use inclusive absolute line numbers in one source. Include existing line endings; require full containment in an input region.",
|
|
29
|
+
},
|
|
30
|
+
),
|
|
31
|
+
Type.Object(
|
|
32
|
+
{
|
|
33
|
+
kind: Type.Literal("between"),
|
|
34
|
+
start: Type.String({ minLength: 1 }),
|
|
35
|
+
end: Type.String({ minLength: 1 }),
|
|
36
|
+
extent: Type.Union([Type.Literal("inside"), Type.Literal("around"), Type.Literal("lines")]),
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
additionalProperties: false,
|
|
40
|
+
description:
|
|
41
|
+
"Pair non-empty literal opening markers with the next closing marker per region, without nesting. Resume after each pair; unmatched openings are errors. inside excludes markers, around includes them, lines explicitly expands to complete containing lines.",
|
|
42
|
+
},
|
|
43
|
+
),
|
|
44
|
+
Type.Object(
|
|
45
|
+
{
|
|
46
|
+
kind: Type.Literal("sliceText"),
|
|
47
|
+
from: Type.Integer({ minimum: 0 }),
|
|
48
|
+
to: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
additionalProperties: false,
|
|
52
|
+
description:
|
|
53
|
+
"Slice each region by non-negative relative UTF-16 offsets. The exclusive to defaults to its end. Equal offsets select a zero-width point.",
|
|
54
|
+
},
|
|
55
|
+
),
|
|
56
|
+
Type.Object(
|
|
57
|
+
{
|
|
58
|
+
kind: Type.Literal("trim"),
|
|
59
|
+
side: Type.Union([Type.Literal("start"), Type.Literal("end"), Type.Literal("both")]),
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
additionalProperties: false,
|
|
63
|
+
description:
|
|
64
|
+
"Trim Unicode whitespace from the requested edges of each region. A whitespace-only region selects a zero-width point at its end.",
|
|
65
|
+
},
|
|
66
|
+
),
|
|
67
|
+
Type.Object(
|
|
68
|
+
{
|
|
69
|
+
kind: Type.Literal("split"),
|
|
70
|
+
delimiter: Type.String({ minLength: 1 }),
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
additionalProperties: false,
|
|
74
|
+
description:
|
|
75
|
+
"Split each region by a non-empty literal delimiter, excluding delimiters and retaining empty segments as zero-width points.",
|
|
76
|
+
},
|
|
77
|
+
),
|
|
78
|
+
Type.Object(
|
|
79
|
+
{
|
|
80
|
+
kind: Type.Literal("linesOf"),
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
additionalProperties: false,
|
|
84
|
+
description:
|
|
85
|
+
"Expand each region to complete containing lines, preserving line endings and reporting expansion. An exclusive end at next-line column zero does not include that next line.",
|
|
86
|
+
},
|
|
87
|
+
),
|
|
88
|
+
Type.Object(
|
|
89
|
+
{
|
|
90
|
+
kind: Type.Literal("position"),
|
|
91
|
+
edge: Type.Union([Type.Literal("before"), Type.Literal("after")]),
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
additionalProperties: false,
|
|
95
|
+
description:
|
|
96
|
+
"Select the zero-width start or end of each region. Use a whole-file Read for file edges.",
|
|
97
|
+
},
|
|
98
|
+
),
|
|
99
|
+
Type.Object(
|
|
100
|
+
{
|
|
101
|
+
kind: Type.Literal("columns"),
|
|
102
|
+
from: Type.Integer({ minimum: 0 }),
|
|
103
|
+
to: Type.Integer({ minimum: 0 }),
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
additionalProperties: false,
|
|
107
|
+
description:
|
|
108
|
+
"Select an exclusive UTF-16 column interval on each touched line, excluding line endings. Every interval must fit its line and original input region; no clipping.",
|
|
109
|
+
},
|
|
110
|
+
),
|
|
111
|
+
]);
|
|
112
|
+
|
|
113
|
+
function scopedOperation<const Kind extends "within" | "intersection" | "difference">(
|
|
114
|
+
kind: Kind,
|
|
115
|
+
description: string,
|
|
116
|
+
) {
|
|
117
|
+
return Type.Object(
|
|
118
|
+
{
|
|
119
|
+
kind: Type.Literal(kind),
|
|
120
|
+
scopes: {
|
|
121
|
+
...resultInputSchema,
|
|
122
|
+
description:
|
|
123
|
+
"Comparison scopes: unchanged results, issued UUIDs or item references, arrays of those strings, or a readable source path. Match sets by source, not array position.",
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
{ additionalProperties: false, description },
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const geometryOperationSchema = Type.Union([
|
|
131
|
+
scopedOperation(
|
|
132
|
+
"within",
|
|
133
|
+
"Retain each candidate whole only when one comparison scope contains it. Never clip or join scopes for containment.",
|
|
134
|
+
),
|
|
135
|
+
scopedOperation(
|
|
136
|
+
"intersection",
|
|
137
|
+
"Clip each candidate to the union of comparison scopes in its source. Touching text ranges do not create a point.",
|
|
138
|
+
),
|
|
139
|
+
scopedOperation(
|
|
140
|
+
"difference",
|
|
141
|
+
"Subtract comparison scopes from each candidate, retaining separate surviving fragments. Point scopes do not cut text.",
|
|
142
|
+
),
|
|
143
|
+
Type.Object(
|
|
144
|
+
{
|
|
145
|
+
kind: Type.Literal("merge"),
|
|
146
|
+
adjacent: Type.Optional(
|
|
147
|
+
Type.Boolean({
|
|
148
|
+
description:
|
|
149
|
+
"Also merge touching nonempty ranges. Default false; never fill a gap or extend text for a point.",
|
|
150
|
+
}),
|
|
151
|
+
),
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
additionalProperties: false,
|
|
155
|
+
description:
|
|
156
|
+
"Explicitly merge overlapping ranges by source, retaining every contributing origin. Covered points are absorbed; other points remain separate.",
|
|
157
|
+
},
|
|
158
|
+
),
|
|
159
|
+
]);
|
|
160
|
+
|
|
161
|
+
const astObjectSchema = Type.Union([
|
|
162
|
+
Type.Literal("function"),
|
|
163
|
+
Type.Literal("call"),
|
|
164
|
+
Type.Literal("class"),
|
|
165
|
+
Type.Literal("if"),
|
|
166
|
+
Type.Literal("switch"),
|
|
167
|
+
Type.Literal("loop"),
|
|
168
|
+
Type.Literal("try"),
|
|
169
|
+
Type.Literal("catch"),
|
|
170
|
+
Type.Literal("binding"),
|
|
171
|
+
Type.Literal("assignment"),
|
|
172
|
+
Type.Literal("object"),
|
|
173
|
+
Type.Literal("property"),
|
|
174
|
+
Type.Literal("array"),
|
|
175
|
+
Type.Literal("return"),
|
|
176
|
+
Type.Literal("throw"),
|
|
177
|
+
]);
|
|
178
|
+
const astPartSchema = Type.Union([
|
|
179
|
+
Type.Literal("name"),
|
|
180
|
+
Type.Literal("body"),
|
|
181
|
+
Type.Literal("parameters"),
|
|
182
|
+
Type.Literal("returnType"),
|
|
183
|
+
Type.Literal("type"),
|
|
184
|
+
Type.Literal("callee"),
|
|
185
|
+
Type.Literal("arguments"),
|
|
186
|
+
Type.Literal("condition"),
|
|
187
|
+
Type.Literal("then"),
|
|
188
|
+
Type.Literal("else"),
|
|
189
|
+
Type.Literal("initializer"),
|
|
190
|
+
Type.Literal("update"),
|
|
191
|
+
Type.Literal("iterable"),
|
|
192
|
+
Type.Literal("left"),
|
|
193
|
+
Type.Literal("right"),
|
|
194
|
+
Type.Literal("value"),
|
|
195
|
+
Type.Literal("key"),
|
|
196
|
+
Type.Literal("handler"),
|
|
197
|
+
Type.Literal("finalizer"),
|
|
198
|
+
Type.Literal("parameter"),
|
|
199
|
+
]);
|
|
200
|
+
const objectFilter = Type.Optional({
|
|
201
|
+
...astObjectSchema,
|
|
202
|
+
description:
|
|
203
|
+
"Filter results by construct category after navigation. The filter does not change parent/child/sibling relationships.",
|
|
204
|
+
});
|
|
205
|
+
const structuralOperationSchema = Type.Union([
|
|
206
|
+
Type.Object(
|
|
207
|
+
{
|
|
208
|
+
kind: Type.Literal("elementExtent"),
|
|
209
|
+
extent: Type.Union([Type.Literal("inside"), Type.Literal("around")]),
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
additionalProperties: false,
|
|
213
|
+
description:
|
|
214
|
+
"Select an exact direct JS/TS call argument or parenthesized function parameter. inside keeps the element; around includes owned comma/whitespace. Prefer the following separator; last without a trailing comma uses the preceding gap; only elements own the list interior. Adjacent boundary comments reject around. No destination syntax repair.",
|
|
215
|
+
},
|
|
216
|
+
),
|
|
217
|
+
Type.Object(
|
|
218
|
+
{
|
|
219
|
+
kind: Type.Literal("object"),
|
|
220
|
+
object: astObjectSchema,
|
|
221
|
+
relation: Type.Optional(Type.Literal("enclosing")),
|
|
222
|
+
level: Type.Optional(
|
|
223
|
+
Type.Integer({
|
|
224
|
+
minimum: 1,
|
|
225
|
+
description: "Default 1 (nearest). Count only constructs of the requested category.",
|
|
226
|
+
}),
|
|
227
|
+
),
|
|
228
|
+
extent: Type.Optional(Type.Literal("around")),
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
additionalProperties: false,
|
|
232
|
+
description:
|
|
233
|
+
"Select the requested containing construct. level=1 is nearest and includes an exact seed; higher levels count only that category. Match the entire seed, not its first character.",
|
|
234
|
+
},
|
|
235
|
+
),
|
|
236
|
+
Type.Object(
|
|
237
|
+
{ kind: Type.Literal("part"), part: astPartSchema },
|
|
238
|
+
{
|
|
239
|
+
additionalProperties: false,
|
|
240
|
+
description:
|
|
241
|
+
"Select an exact supported construct's named part, including delimiters belonging to its syntax node. A supported optional part may be absent; unsupported parts are errors with available names. Use an enclosing object first for partial input.",
|
|
242
|
+
},
|
|
243
|
+
),
|
|
244
|
+
Type.Object(
|
|
245
|
+
{
|
|
246
|
+
kind: Type.Literal("navigate"),
|
|
247
|
+
relation: Type.Union([
|
|
248
|
+
Type.Literal("parent"),
|
|
249
|
+
Type.Literal("ancestors"),
|
|
250
|
+
Type.Literal("children"),
|
|
251
|
+
Type.Literal("descendants"),
|
|
252
|
+
]),
|
|
253
|
+
object: objectFilter,
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
additionalProperties: false,
|
|
257
|
+
description:
|
|
258
|
+
"Navigate from an exact named syntax node, including constructs, part targets and the document root. Skip parser-only wrappers in results. Exclude the starting node; ancestors/descendants return results in source order. parent/children never skip recognized constructs to satisfy a filter. Use enclosing first for ranges that cut through a node.",
|
|
259
|
+
},
|
|
260
|
+
),
|
|
261
|
+
Type.Object(
|
|
262
|
+
{
|
|
263
|
+
kind: Type.Literal("navigate"),
|
|
264
|
+
relation: Type.Literal("siblings"),
|
|
265
|
+
object: objectFilter,
|
|
266
|
+
direction: Type.Optional(
|
|
267
|
+
Type.Union([Type.Literal("previous"), Type.Literal("next"), Type.Literal("all")], {
|
|
268
|
+
description:
|
|
269
|
+
"Default all. previous/next select the immediate sibling before category filtering, not the next matching category.",
|
|
270
|
+
}),
|
|
271
|
+
),
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
additionalProperties: false,
|
|
275
|
+
description:
|
|
276
|
+
"Select siblings of an exact supported construct under the same normalized parent. Exclude the input; return source order. A missing neighbor is valid absence.",
|
|
277
|
+
},
|
|
278
|
+
),
|
|
279
|
+
]);
|
|
280
|
+
/** Normalized JS/TS constructs, independent of parser-only wrapper nodes. */
|
|
281
|
+
export type AstObject = Static<typeof astObjectSchema>;
|
|
282
|
+
/** Named construct parts. Availability depends on the actual node form. */
|
|
283
|
+
export type AstPart = Static<typeof astPartSchema>;
|
|
284
|
+
/** Callable text and structural transformations; future catalog entries are not exposed here. */
|
|
285
|
+
export const selectSchema = Type.Object(
|
|
286
|
+
{
|
|
287
|
+
path: {
|
|
288
|
+
...resultInputSchema,
|
|
289
|
+
description:
|
|
290
|
+
"File path, unchanged Read/Search/Select/edit result, its UUID, or an array of such results. Pass the whole result; do not rebuild it from preview text.",
|
|
291
|
+
},
|
|
292
|
+
operation: Type.Union([
|
|
293
|
+
structuralOperationSchema,
|
|
294
|
+
textOperationSchema,
|
|
295
|
+
geometryOperationSchema,
|
|
296
|
+
]),
|
|
297
|
+
},
|
|
298
|
+
{ additionalProperties: false },
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
/** Inputs accepted by the Select tool. */
|
|
302
|
+
export type SelectParameters = Static<typeof selectSchema>;
|
|
303
|
+
/** Supported source transformations. */
|
|
304
|
+
export type SelectOperation = SelectParameters["operation"];
|
|
305
|
+
/** AST operations require the existing syntax provider. */
|
|
306
|
+
export type StructuralSelectOperation = Static<typeof structuralOperationSchema>;
|
|
307
|
+
/** Geometry operations compare verified source-local sets. */
|
|
308
|
+
export type GeometrySelectOperation = Static<typeof geometryOperationSchema>;
|
|
309
|
+
/** Text operations work independently of a source language or parser. */
|
|
310
|
+
export type TextSelectOperation = Exclude<
|
|
311
|
+
SelectOperation,
|
|
312
|
+
StructuralSelectOperation | GeometrySelectOperation
|
|
313
|
+
>;
|
|
314
|
+
|
|
315
|
+
const rangeSchema = Type.Object(
|
|
316
|
+
{
|
|
317
|
+
startLine: Type.Integer({ minimum: 1 }),
|
|
318
|
+
startColumn: Type.Integer({ minimum: 0 }),
|
|
319
|
+
endLine: Type.Integer({ minimum: 1 }),
|
|
320
|
+
endColumn: Type.Integer({ minimum: 0 }),
|
|
321
|
+
},
|
|
322
|
+
{ additionalProperties: false },
|
|
323
|
+
);
|
|
324
|
+
|
|
325
|
+
/** Source-backed selection set with bounded previews and retained input associations. */
|
|
326
|
+
export const selectionDataSchema = Type.Object(
|
|
327
|
+
{
|
|
328
|
+
kind: Type.Literal("selection"),
|
|
329
|
+
target: Type.String({
|
|
330
|
+
description: "Stored target for every selected range, including items beyond the preview.",
|
|
331
|
+
}),
|
|
332
|
+
complete: Type.Boolean({
|
|
333
|
+
description:
|
|
334
|
+
"Execution completeness inherited from all inputs, independent of preview limits.",
|
|
335
|
+
}),
|
|
336
|
+
totalItems: Type.Integer({ minimum: 0 }),
|
|
337
|
+
missingInputs: Type.Integer({ minimum: 0 }),
|
|
338
|
+
truncated: Type.Boolean(),
|
|
339
|
+
items: Type.Array(
|
|
340
|
+
Type.Object(
|
|
341
|
+
{
|
|
342
|
+
target: Type.String(),
|
|
343
|
+
source: Type.String(),
|
|
344
|
+
range: rangeSchema,
|
|
345
|
+
syntax: Type.Optional(
|
|
346
|
+
Type.Object(
|
|
347
|
+
{
|
|
348
|
+
object: astObjectSchema,
|
|
349
|
+
part: Type.Optional(astPartSchema),
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
additionalProperties: false,
|
|
353
|
+
description:
|
|
354
|
+
"Parser-derived normalized construct category and selected part. This describes the target; it is not edit authority.",
|
|
355
|
+
},
|
|
356
|
+
),
|
|
357
|
+
),
|
|
358
|
+
origins: Type.Array(
|
|
359
|
+
Type.Object(
|
|
360
|
+
{
|
|
361
|
+
source: Type.String(),
|
|
362
|
+
range: rangeSchema,
|
|
363
|
+
expanded: Type.Boolean(),
|
|
364
|
+
},
|
|
365
|
+
{ additionalProperties: false },
|
|
366
|
+
),
|
|
367
|
+
),
|
|
368
|
+
preview: Type.String({ maxLength: 1000 }),
|
|
369
|
+
textTruncated: Type.Boolean(),
|
|
370
|
+
},
|
|
371
|
+
{ additionalProperties: false },
|
|
372
|
+
),
|
|
373
|
+
{ maxItems: 100 },
|
|
374
|
+
),
|
|
375
|
+
},
|
|
376
|
+
{ additionalProperties: false },
|
|
377
|
+
);
|
|
378
|
+
|
|
379
|
+
/** Structured output; editable authority is stored in its targets, not these coordinates. */
|
|
380
|
+
export type SelectionData = Static<typeof selectionDataSchema>;
|
|
381
|
+
/** One individually consumable selection and the inputs that produced it. */
|
|
382
|
+
export type SelectionItem = SelectionData["items"][number];
|
|
383
|
+
/** Public structured success/error envelope for Select. */
|
|
384
|
+
export const selectOutputSchema = structuredResultSchema(selectionDataSchema);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ResultRange, ResultSourceTarget } from "pi-agent-resource";
|
|
2
|
+
import type { SelectionItem } from "./select-schema.js";
|
|
3
|
+
|
|
4
|
+
/** A structural or text refusal is distinct from valid absence. */
|
|
5
|
+
export class SelectionError extends Error {
|
|
6
|
+
public constructor(
|
|
7
|
+
public readonly code: string,
|
|
8
|
+
message: string,
|
|
9
|
+
) {
|
|
10
|
+
super(message);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Verified geometry and original seed associations before handles and previews are added. */
|
|
15
|
+
export interface SelectedRegion {
|
|
16
|
+
readonly target: ResultSourceTarget;
|
|
17
|
+
readonly range: ResultRange;
|
|
18
|
+
readonly text: string;
|
|
19
|
+
readonly origins: SelectionItem["origins"];
|
|
20
|
+
readonly syntax?: SelectionItem["syntax"];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Coordinates use one-based lines and exclusive UTF-16 character ends. */
|
|
24
|
+
export function publicRange(range: ResultRange): SelectionItem["range"] {
|
|
25
|
+
return {
|
|
26
|
+
startLine: range.start.lineNumber,
|
|
27
|
+
startColumn: range.start.column,
|
|
28
|
+
endLine: range.end.lineNumber,
|
|
29
|
+
endColumn: range.end.column,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Deduplicate output geometry without losing any original input association. */
|
|
34
|
+
export function retainRegion(selected: Map<string, SelectedRegion>, region: SelectedRegion): void {
|
|
35
|
+
const identity = JSON.stringify([region.target.source, region.range]);
|
|
36
|
+
const previous = selected.get(identity);
|
|
37
|
+
selected.set(
|
|
38
|
+
identity,
|
|
39
|
+
previous ? { ...region, origins: [...previous.origins, ...region.origins] } : region,
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { createTextDocument } from "pi-agent-text";
|
|
2
|
+
import type { ResultRange } from "pi-agent-resource";
|
|
3
|
+
import { SelectionError } from "./selection-region.js";
|
|
4
|
+
|
|
5
|
+
interface SourceLine {
|
|
6
|
+
readonly start: number;
|
|
7
|
+
readonly length: number;
|
|
8
|
+
readonly end: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Map retained text coordinates without normalizing line endings or splitting source characters. */
|
|
12
|
+
export class SourceText {
|
|
13
|
+
public readonly lines: readonly SourceLine[];
|
|
14
|
+
public constructor(public readonly content: string) {
|
|
15
|
+
let start = 0;
|
|
16
|
+
const document = createTextDocument("", content);
|
|
17
|
+
const lines = document.lines.map((line) => {
|
|
18
|
+
const from = start;
|
|
19
|
+
start += line.content.length + line.lineEnding.length;
|
|
20
|
+
return { start: from, length: line.content.length, end: start };
|
|
21
|
+
});
|
|
22
|
+
if (lines.length === 0 || document.lines.at(-1)?.lineEnding)
|
|
23
|
+
lines.push({ start, length: 0, end: start });
|
|
24
|
+
this.lines = lines;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Validate one exact character boundary, including CRLF and surrogate-pair integrity. */
|
|
28
|
+
public boundary(offset: number): void {
|
|
29
|
+
if (!Number.isSafeInteger(offset) || offset < 0 || offset > this.content.length)
|
|
30
|
+
throw new SelectionError("INVALID_RANGE", "Text bounds are outside the retained snapshot.");
|
|
31
|
+
const left = this.content.charCodeAt(offset - 1);
|
|
32
|
+
const right = this.content.charCodeAt(offset);
|
|
33
|
+
if (
|
|
34
|
+
(left >= 0xd800 && left <= 0xdbff && right >= 0xdc00 && right <= 0xdfff) ||
|
|
35
|
+
(left === 13 && right === 10)
|
|
36
|
+
)
|
|
37
|
+
throw new SelectionError(
|
|
38
|
+
"INVALID_BOUNDARY",
|
|
39
|
+
"Text boundary splits a surrogate pair or CRLF separator.",
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Resolve absolute source coordinates; columns do not include line-ending characters. */
|
|
44
|
+
public offset(position: ResultRange["start"]): number {
|
|
45
|
+
const line = this.lines[position.lineNumber - 1];
|
|
46
|
+
if (
|
|
47
|
+
!Number.isSafeInteger(position.lineNumber) ||
|
|
48
|
+
!line ||
|
|
49
|
+
!Number.isSafeInteger(position.column) ||
|
|
50
|
+
position.column < 0 ||
|
|
51
|
+
position.column > line.length
|
|
52
|
+
)
|
|
53
|
+
throw new SelectionError("INVALID_RANGE", "Source bounds are outside the retained snapshot.");
|
|
54
|
+
const offset = line.start + position.column;
|
|
55
|
+
this.boundary(offset);
|
|
56
|
+
return offset;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Find the physical containing line, including separator bytes, without creating a boundary. */
|
|
60
|
+
public lineIndex(offset: number): number {
|
|
61
|
+
let low = 0;
|
|
62
|
+
let high = this.lines.length - 1;
|
|
63
|
+
while (low < high) {
|
|
64
|
+
const middle = Math.ceil((low + high) / 2);
|
|
65
|
+
if ((this.lines[middle]?.start ?? 0) <= offset) low = middle;
|
|
66
|
+
else high = middle - 1;
|
|
67
|
+
}
|
|
68
|
+
return low;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Convert a validated offset to an exclusive source position. */
|
|
72
|
+
public position(offset: number): ResultRange["start"] {
|
|
73
|
+
this.boundary(offset);
|
|
74
|
+
const index = this.lineIndex(offset);
|
|
75
|
+
return { lineNumber: index + 1, column: offset - (this.lines[index]?.start ?? 0) };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Build canonical character ranges; line endings remain represented by next-line column zero. */
|
|
79
|
+
public range(from: number, to: number): ResultRange {
|
|
80
|
+
if (to < from) throw new SelectionError("INVALID_RANGE", "Text bounds are reversed.");
|
|
81
|
+
return { start: this.position(from), end: this.position(to) };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Return the complete physical lines touched by a half-open range or caret. */
|
|
85
|
+
public fullLines(from: number, to: number): { from: number; to: number } {
|
|
86
|
+
const first = this.lines[this.lineIndex(from)];
|
|
87
|
+
const last = this.lines[this.lineIndex(to > from ? to - 1 : from)];
|
|
88
|
+
if (!first || !last)
|
|
89
|
+
throw new SelectionError("INVALID_RANGE", "Source line bounds are unavailable.");
|
|
90
|
+
return { from: first.start, to: last.end };
|
|
91
|
+
}
|
|
92
|
+
}
|