pi-agent-ide 0.6.2 → 0.6.4
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 +66 -0
- package/README.md +8 -1
- package/dist/chunk-2P2OGO3G.js +2 -0
- package/dist/{chunk-5QQABP47.js → chunk-3BBJZSMS.js} +1 -1
- package/dist/chunk-5J43L2RL.js +11 -0
- package/dist/{chunk-ITSNK5YG.js → chunk-7AVXUV4A.js} +2 -2
- package/dist/chunk-BAYETTZZ.js +16 -0
- package/dist/{chunk-VCTK4JSN.js → chunk-BSICWXMH.js} +1 -1
- package/dist/chunk-BVK5A7ED.js +28 -0
- package/dist/{chunk-ZM4L5AGN.js → chunk-EDURPQAV.js} +3 -2
- package/dist/{chunk-L7JMDDSD.js → chunk-FBOW7XOV.js} +1 -1
- package/dist/{chunk-25CZ5ZIU.js → chunk-FUG2TEKI.js} +1 -1
- package/dist/chunk-FZBCKIJJ.js +1 -0
- package/dist/chunk-HPUAIWIH.js +25 -0
- package/dist/chunk-I5JLCFUX.js +1 -0
- package/dist/chunk-KUPHNMUK.js +2 -0
- package/dist/{chunk-NTYXZ3EL.js → chunk-KVHDMIZS.js} +1 -1
- package/dist/{chunk-QDST6VIU.js → chunk-KZC7TI5M.js} +1 -1
- package/dist/chunk-MIZAFRDR.js +1 -0
- package/dist/chunk-PJPA5EEE.js +2 -0
- package/dist/{chunk-GUTQ3PWL.js → chunk-PLKYHUNT.js} +1 -1
- package/dist/chunk-QEJGED4V.js +28 -0
- package/dist/chunk-SILJ3OL4.js +9 -0
- package/dist/{chunk-VXD6FZP5.js → chunk-TQZBVOTT.js} +3 -3
- package/dist/chunk-VBICI5YA.js +1 -0
- package/dist/chunk-VWW3RLUX.js +12 -0
- package/dist/{chunk-O6LE42GK.js → chunk-WJTHY6AG.js} +1 -1
- package/dist/chunk-YGGKGZO2.js +1 -0
- package/dist/chunk-ZODCBFBL.js +2 -0
- package/dist/chunk-ZPT5D4VP.js +2 -0
- package/dist/entry-0.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-16.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 +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 +11 -11
- package/dist/entry-33.js +1 -1
- package/dist/entry-37.js +2 -2
- package/dist/entry-42.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +13 -12
- package/dist/entry-46.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +4 -4
- package/dist/entry-51.js +9 -9
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-55.js +1 -1
- package/dist/entry-56.js +1 -1
- package/dist/entry-57.js +1 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-59.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-61.js +1 -1
- package/dist/entry-63.js +1 -1
- package/dist/entry-66.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 +1 -0
- package/dist/entry-72.js +0 -1
- package/dist/entry-73.js +1 -0
- package/dist/entry-74.js +0 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-76.js +1 -1
- package/dist/entry-77.js +1 -315
- package/dist/entry-78.js +324 -25
- package/dist/entry-79.js +18 -2
- package/dist/entry-80.js +2 -1
- package/dist/entry-81.js +1 -1
- package/dist/entry-82.js +1 -3
- package/dist/entry-83.js +5 -3
- package/dist/entry-84.js +3 -1
- package/dist/entry-85.js +1 -1
- package/dist/entry-86.js +1 -1
- package/dist/entry-87.js +1 -0
- package/dist/pi-agent-ide.js +15 -3
- package/docs/agent-guides/apply.md +1 -1
- package/docs/agent-guides/editing.md +16 -0
- package/docs/agent-guides/json-reading.md +19 -3
- package/docs/agent-guides/read-resources.md +6 -0
- package/docs/agent-guides/search-code.md +5 -1
- package/docs/agent-guides/terminal.md +1 -1
- package/docs/code-review.md +99 -0
- package/docs/configuration.md +34 -0
- package/docs/development.md +15 -19
- package/docs/nightly.md +7 -0
- package/docs/releases.md +42 -0
- package/docs/research/native-codemode-batch-decision.md +27 -0
- package/docs/research/native-codemode-batching.md +65 -0
- package/docs/structured-results.md +59 -0
- package/docs/tools.md +18 -2
- 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-documentation/src/index.ts +1 -1
- package/node_modules/pi-agent-filesystem/index.ts +6 -1
- package/node_modules/pi-agent-filesystem/package.json +7 -6
- package/node_modules/pi-agent-filesystem/src/path-recovery.ts +109 -0
- 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 +10 -10
- package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +6 -1
- package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +6 -2
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +17 -0
- package/node_modules/pi-agent-ide-changes/index.ts +3 -9
- package/node_modules/pi-agent-ide-changes/package.json +8 -7
- package/node_modules/pi-agent-ide-changes/src/current-change-presenter.ts +5 -0
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +125 -47
- 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/package.json +9 -9
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +19 -0
- 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/tools/read.ts +31 -2
- package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +9 -10
- package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +28 -15
- package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +216 -0
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +119 -72
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/index.ts +12 -0
- package/node_modules/pi-agent-resource/src/resource-access.ts +55 -0
- package/node_modules/pi-agent-resource/src/resource-scheduler.ts +204 -0
- package/node_modules/pi-agent-resource/src/tool-result.ts +125 -0
- package/node_modules/pi-agent-search/package.json +5 -4
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +6 -5
- package/node_modules/pi-agent-search/src/api/search.ts +11 -0
- package/node_modules/pi-agent-search/src/api/structured-result.ts +93 -0
- package/node_modules/pi-agent-search/src/core/extension.ts +40 -14
- package/node_modules/pi-agent-search/src/core/search-core.ts +136 -77
- package/node_modules/pi-agent-search-text/index.ts +3 -0
- package/node_modules/pi-agent-search-text/package.json +6 -6
- package/node_modules/pi-agent-search-text/src/resolvers.ts +17 -0
- package/node_modules/pi-agent-search-text/src/search-backend.ts +104 -8
- package/node_modules/pi-agent-search-text/src/search-query.ts +42 -34
- package/node_modules/pi-agent-search-text/src/search-recipe.ts +18 -4
- package/node_modules/pi-agent-search-text/src/search-renderer.ts +37 -3
- package/node_modules/pi-agent-search-text/src/search-session.ts +21 -13
- package/node_modules/pi-agent-text/package.json +2 -2
- package/node_modules/pi-agent-text/src/text-document.ts +15 -10
- 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-exact/src/anchor.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 +4 -2
- package/node_modules/pi-agent-text-editor/package.json +21 -17
- package/node_modules/pi-agent-text-editor/runtime/entry-77.js +0 -1
- package/node_modules/pi-agent-text-editor/src/api/mutation-preview.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +6 -0
- package/node_modules/pi-agent-text-editor/src/api/native-edit-batch-event.ts +12 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +4 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +95 -34
- package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/apply/results.ts +4 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +20 -11
- package/node_modules/pi-agent-text-editor/src/core/apply/structured-result.ts +251 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +32 -12
- package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +154 -132
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit.ts +16 -0
- package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +74 -18
- package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +8 -0
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +6 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +640 -0
- package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +20 -6
- package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +314 -0
- package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +52 -11
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +143 -138
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +242 -116
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +109 -47
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +25 -5
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +8 -4
- package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +7 -4
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +24 -3
- package/node_modules/pi-agent-text-editor-renderer/index.ts +8 -1
- package/node_modules/pi-agent-text-editor-renderer/package.json +7 -6
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +262 -129
- package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +36 -2
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +28 -2
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-projection.ts +40 -10
- package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +16 -1
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +2 -0
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-82.js +1 -0
- package/node_modules/pi-agent-web/index.ts +20 -0
- package/node_modules/pi-agent-web/package.json +8 -7
- package/node_modules/pi-agent-web/src/search.ts +112 -0
- 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/node_modules/pi-agent-web-text/runtime/entry-87.js +2 -0
- package/package.json +42 -36
- package/skills/capture-code-review-rule/SKILL.md +60 -0
- package/src/code-review/config.ts +68 -0
- package/src/code-review/extension.ts +105 -0
- package/src/code-review/fragments.ts +26 -0
- package/src/code-review/reviewer.ts +198 -0
- package/src/composite/host-version.ts +13 -0
- package/src/composite/nested-tool-rendering.ts +298 -0
- package/src/composite/tool-availability.ts +90 -0
- package/src/core/extension.ts +2 -0
- package/src/documentation/extension.ts +81 -145
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +6 -1
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/path-recovery.ts +109 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +20 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -7
- 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-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/plugins/pi-agent-web-text/runtime/entry-87.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-83.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/search.ts +112 -0
- package/src/extensions/pi-agent-read/package.json +7 -7
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +31 -2
- package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +9 -10
- package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +28 -15
- package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +216 -0
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +119 -72
- package/src/extensions/pi-agent-search/package.json +5 -4
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +3 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +6 -6
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +17 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +104 -8
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-query.ts +42 -34
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +18 -4
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +37 -3
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +21 -13
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +6 -5
- package/src/extensions/pi-agent-search/src/api/search.ts +11 -0
- package/src/extensions/pi-agent-search/src/api/structured-result.ts +93 -0
- package/src/extensions/pi-agent-search/src/core/extension.ts +40 -14
- package/src/extensions/pi-agent-search/src/core/search-core.ts +136 -77
- package/src/extensions/pi-agent-text-editor/index.ts +4 -2
- package/src/extensions/pi-agent-text-editor/package.json +21 -17
- 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-exact/src/anchor.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 +8 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +7 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +262 -129
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +36 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +28 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-projection.ts +40 -10
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/index.ts +16 -1
- 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/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +2 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-77.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-78.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-preview.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +6 -0
- package/src/extensions/pi-agent-text-editor/src/api/native-edit-batch-event.ts +12 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +4 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +95 -34
- package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/apply/results.ts +4 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +20 -11
- package/src/extensions/pi-agent-text-editor/src/core/apply/structured-result.ts +251 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +32 -12
- package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +154 -132
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit.ts +16 -0
- package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +74 -18
- package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +8 -0
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +6 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +640 -0
- package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +20 -6
- package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +314 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +52 -11
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +143 -138
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +242 -116
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +109 -47
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +25 -5
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +8 -4
- package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +7 -4
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +24 -3
- package/src/pi-agent-ide.ts +61 -2
- package/src/plugins/pi-agent-ide-ast/package.json +10 -10
- package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +6 -1
- package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +6 -2
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +17 -0
- package/src/plugins/pi-agent-ide-changes/index.ts +3 -9
- package/src/plugins/pi-agent-ide-changes/package.json +8 -7
- package/src/plugins/pi-agent-ide-changes/src/current-change-presenter.ts +5 -0
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +125 -47
- package/src/plugins/pi-agent-ide-debugger/index.ts +63 -17
- package/src/plugins/pi-agent-ide-debugger/src/catalog.ts +18 -2
- package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +24 -4
- package/src/plugins/pi-agent-ide-debugger/src/doctor-plugin.ts +68 -2
- package/src/plugins/pi-agent-ide-debugger/src/java-runtime.ts +357 -0
- package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +55 -3
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +13 -13
- 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/package.json +9 -9
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +19 -0
- package/src/plugins/pi-agent-ide-terminal/index.ts +12 -2
- package/src/plugins/pi-agent-ide-terminal/src/output-limits.ts +1 -1
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +65 -30
- package/src/plugins/pi-agent-ide-terminal/src/search.ts +13 -8
- package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +1 -0
- package/src/plugins/pi-agent-ide-terminal/src/shell-result.ts +100 -0
- package/src/plugins/pi-agent-ide-terminal/src/steering.ts +62 -0
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +97 -45
- package/src/plugins/pi-agent-ide-terminal/src/types.ts +3 -1
- package/src/plugins/pi-agent-ide-terminal/src/ui.ts +15 -6
- package/src/plugins/pi-agent-ide-vision/index.ts +16 -1
- package/dist/chunk-3E2NTWCN.js +0 -2
- package/dist/chunk-4LUW26BX.js +0 -10
- package/dist/chunk-5VSE5X5R.js +0 -2
- package/dist/chunk-CEX3VOJ7.js +0 -2
- package/dist/chunk-FA6BKC5Y.js +0 -1
- package/dist/chunk-FEDVTZJG.js +0 -1
- package/dist/chunk-HMLH43ZS.js +0 -4
- package/dist/chunk-KII2JQC5.js +0 -1
- package/dist/chunk-LVWMWWWF.js +0 -28
- package/dist/chunk-P7XO5CIP.js +0 -2
- package/dist/chunk-PZFOOHY2.js +0 -15
- package/dist/chunk-S3ZPXWX7.js +0 -2
- package/dist/chunk-T7CZIACQ.js +0 -27
- package/dist/chunk-YT42LKFV.js +0 -16
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +0 -52
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-80.js +0 -1
- package/node_modules/pi-agent-web/runtime/entry-82.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-83.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-82.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-78.js +0 -2
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +0 -52
- /package/dist/{chunk-4U2GUKNJ.js → chunk-F7NVAC4Q.js} +0 -0
- /package/dist/{chunk-ROXXK6TW.js → chunk-PXWDDBBC.js} +0 -0
- /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor}/runtime/entry-78.js +0 -0
- /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-79.js +0 -0
- /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-81.js +0 -0
- /package/node_modules/{pi-agent-web-html → pi-agent-web}/runtime/entry-83.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-84.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-85.js +0 -0
- /package/node_modules/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-86.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-84.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-85.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-86.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-79.js +0 -0
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { Type, type Static } from "typebox";
|
|
2
|
+
import { Value } from "typebox/value";
|
|
3
|
+
import {
|
|
4
|
+
resultError,
|
|
5
|
+
resultErrorSchema,
|
|
6
|
+
structuredResultSchema,
|
|
7
|
+
withStructuredResult,
|
|
8
|
+
type StructuredResult,
|
|
9
|
+
type ResultError,
|
|
10
|
+
} from "pi-agent-resource";
|
|
11
|
+
import type { AgentToolResult } from "@earendil-works/pi-coding-agent";
|
|
12
|
+
import type { FileMutationBatchResult } from "#src/api/mutation-result.js";
|
|
13
|
+
import type { TextEditCompletion } from "#src/api/edit-completion.js";
|
|
14
|
+
|
|
15
|
+
const effect = Type.Union([
|
|
16
|
+
Type.Literal("pending"),
|
|
17
|
+
Type.Literal("applied"),
|
|
18
|
+
Type.Literal("not-applied"),
|
|
19
|
+
Type.Literal("unknown"),
|
|
20
|
+
]);
|
|
21
|
+
const file = Type.Object(
|
|
22
|
+
{ source: Type.String(), effect, action: Type.Optional(Type.String()) },
|
|
23
|
+
{ additionalProperties: false },
|
|
24
|
+
);
|
|
25
|
+
const operation = Type.Object(
|
|
26
|
+
{
|
|
27
|
+
id: Type.String(),
|
|
28
|
+
operation: Type.String(),
|
|
29
|
+
effect,
|
|
30
|
+
errors: Type.Array(resultErrorSchema),
|
|
31
|
+
status: Type.Optional(
|
|
32
|
+
Type.Union([
|
|
33
|
+
Type.Literal("success"),
|
|
34
|
+
Type.Literal("error"),
|
|
35
|
+
Type.Literal("warning"),
|
|
36
|
+
Type.Literal("unknown"),
|
|
37
|
+
]),
|
|
38
|
+
),
|
|
39
|
+
sources: Type.Optional(Type.Array(Type.String())),
|
|
40
|
+
warnings: Type.Optional(Type.Array(resultErrorSchema)),
|
|
41
|
+
},
|
|
42
|
+
{ additionalProperties: false },
|
|
43
|
+
);
|
|
44
|
+
export const mutationDataSchema = Type.Object(
|
|
45
|
+
{
|
|
46
|
+
operation: Type.String(),
|
|
47
|
+
effect,
|
|
48
|
+
operationId: Type.Optional(Type.String()),
|
|
49
|
+
files: Type.Array(file),
|
|
50
|
+
operations: Type.Optional(Type.Array(operation)),
|
|
51
|
+
parentToolCallId: Type.Optional(Type.String()),
|
|
52
|
+
transaction: Type.Optional(Type.String()),
|
|
53
|
+
transactions: Type.Optional(Type.Array(Type.String())),
|
|
54
|
+
recovery: Type.Optional(
|
|
55
|
+
Type.Array(
|
|
56
|
+
Type.Object({
|
|
57
|
+
source: Type.String(),
|
|
58
|
+
field: Type.String(),
|
|
59
|
+
anchor: Type.String(),
|
|
60
|
+
total: Type.Integer(),
|
|
61
|
+
candidates: Type.Array(
|
|
62
|
+
Type.Object({
|
|
63
|
+
rank: Type.Integer(),
|
|
64
|
+
range: Type.Object({
|
|
65
|
+
start: Type.Object({ lineNumber: Type.Integer(), column: Type.Integer() }),
|
|
66
|
+
end: Type.Object({ lineNumber: Type.Integer(), column: Type.Integer() }),
|
|
67
|
+
}),
|
|
68
|
+
}),
|
|
69
|
+
),
|
|
70
|
+
}),
|
|
71
|
+
),
|
|
72
|
+
),
|
|
73
|
+
action: Type.Optional(
|
|
74
|
+
Type.Object(
|
|
75
|
+
{
|
|
76
|
+
source: Type.String(),
|
|
77
|
+
kind: Type.Optional(Type.String()),
|
|
78
|
+
status: Type.Optional(Type.String()),
|
|
79
|
+
command: Type.Optional(Type.String()),
|
|
80
|
+
deleted: Type.Optional(Type.Boolean()),
|
|
81
|
+
session: Type.Optional(Type.String()),
|
|
82
|
+
file: Type.Optional(Type.String()),
|
|
83
|
+
line: Type.Optional(Type.Integer()),
|
|
84
|
+
verified: Type.Optional(Type.Boolean()),
|
|
85
|
+
evaluation: Type.Optional(
|
|
86
|
+
Type.Object(
|
|
87
|
+
{
|
|
88
|
+
expression: Type.String(),
|
|
89
|
+
result: Type.String(),
|
|
90
|
+
type: Type.Optional(Type.String()),
|
|
91
|
+
variablesReference: Type.Integer(),
|
|
92
|
+
},
|
|
93
|
+
{ additionalProperties: false },
|
|
94
|
+
),
|
|
95
|
+
),
|
|
96
|
+
breakpoints: Type.Optional(
|
|
97
|
+
Type.Array(
|
|
98
|
+
Type.Object(
|
|
99
|
+
{
|
|
100
|
+
source: Type.String(),
|
|
101
|
+
file: Type.String(),
|
|
102
|
+
line: Type.Integer(),
|
|
103
|
+
verified: Type.Boolean(),
|
|
104
|
+
},
|
|
105
|
+
{ additionalProperties: false },
|
|
106
|
+
),
|
|
107
|
+
),
|
|
108
|
+
),
|
|
109
|
+
},
|
|
110
|
+
{ additionalProperties: false },
|
|
111
|
+
),
|
|
112
|
+
),
|
|
113
|
+
},
|
|
114
|
+
{ additionalProperties: false },
|
|
115
|
+
);
|
|
116
|
+
export const mutationOutputSchema = structuredResultSchema(mutationDataSchema);
|
|
117
|
+
/** Public receipt fields are defined by the native output schema. */
|
|
118
|
+
export type MutationData = Static<typeof mutationDataSchema>;
|
|
119
|
+
type MutationFile = MutationData["files"][number];
|
|
120
|
+
function record(value: unknown): value is Record<string, unknown> {
|
|
121
|
+
return typeof value === "object" && value !== null;
|
|
122
|
+
}
|
|
123
|
+
/** Use observed completion events for effects; errors do not prove a rollback. */
|
|
124
|
+
export function mutationOutcome(
|
|
125
|
+
result: AgentToolResult<FileMutationBatchResult>,
|
|
126
|
+
operation: string,
|
|
127
|
+
completions: readonly TextEditCompletion[] = [],
|
|
128
|
+
): StructuredResult<MutationData> {
|
|
129
|
+
const details = result.details;
|
|
130
|
+
const detailRecord: Record<string, unknown> = record(details) ? details : {};
|
|
131
|
+
const native =
|
|
132
|
+
record(details) && record(details.nativeEditBatch) ? details.nativeEditBatch : undefined;
|
|
133
|
+
if (native?.state === "accepted")
|
|
134
|
+
return {
|
|
135
|
+
status: "success",
|
|
136
|
+
errors: [],
|
|
137
|
+
data: {
|
|
138
|
+
operation,
|
|
139
|
+
effect: "pending",
|
|
140
|
+
files:
|
|
141
|
+
typeof detailRecord.source === "string"
|
|
142
|
+
? [{ source: detailRecord.source, effect: "pending" }]
|
|
143
|
+
: [],
|
|
144
|
+
...(typeof native.parentToolCallId === "string"
|
|
145
|
+
? { parentToolCallId: native.parentToolCallId }
|
|
146
|
+
: {}),
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
const observed = new Set(completions.map((completion) => completion.resourceSource));
|
|
150
|
+
const errors: ResultError[] = [];
|
|
151
|
+
const files: MutationFile[] = [];
|
|
152
|
+
const results = details.results;
|
|
153
|
+
for (const value of results ?? []) {
|
|
154
|
+
const data = value.data;
|
|
155
|
+
const sources = [
|
|
156
|
+
...new Set([
|
|
157
|
+
...(data.files ?? []).map((file) => file.path),
|
|
158
|
+
...(data.path ? [data.path] : []),
|
|
159
|
+
]),
|
|
160
|
+
];
|
|
161
|
+
for (const source of sources)
|
|
162
|
+
files.push({
|
|
163
|
+
source,
|
|
164
|
+
effect:
|
|
165
|
+
observed.has(source) ||
|
|
166
|
+
(data.ok === true && data.files?.some((file) => file.path === source))
|
|
167
|
+
? "applied"
|
|
168
|
+
: (details.effect ?? "unknown"),
|
|
169
|
+
});
|
|
170
|
+
for (const error of data.errors ?? [])
|
|
171
|
+
errors.push({
|
|
172
|
+
code: error.code ?? "MUTATION_FAILED",
|
|
173
|
+
message: error.reason ?? "Mutation failed",
|
|
174
|
+
source: error.path,
|
|
175
|
+
});
|
|
176
|
+
if (data.ok === false && (data.errors?.length ?? 0) === 0)
|
|
177
|
+
errors.push({
|
|
178
|
+
code: "MUTATION_FAILED",
|
|
179
|
+
message: "Mutation failed",
|
|
180
|
+
...(data.path ? { source: data.path } : {}),
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
for (const source of observed)
|
|
184
|
+
if (!files.some((file) => file.source === source)) files.push({ source, effect: "applied" });
|
|
185
|
+
const semantic =
|
|
186
|
+
record(details.metadata) && record(details.metadata.semanticAction)
|
|
187
|
+
? details.metadata.semanticAction
|
|
188
|
+
: undefined;
|
|
189
|
+
if (semantic) {
|
|
190
|
+
const semanticEffect =
|
|
191
|
+
semantic.effect === "not-applied" || semantic.effect === "unknown"
|
|
192
|
+
? semantic.effect
|
|
193
|
+
: semantic.ok === false
|
|
194
|
+
? "unknown"
|
|
195
|
+
: "applied";
|
|
196
|
+
const source = typeof semantic.source === "string" ? semantic.source : undefined;
|
|
197
|
+
if (source && !Array.isArray(semantic.restored))
|
|
198
|
+
files.push({
|
|
199
|
+
source,
|
|
200
|
+
effect:
|
|
201
|
+
operation === "copy" && typeof semantic.target === "string" && semantic.target !== source
|
|
202
|
+
? "not-applied"
|
|
203
|
+
: semanticEffect,
|
|
204
|
+
});
|
|
205
|
+
if (Array.isArray(semantic.restored))
|
|
206
|
+
for (const source of semantic.restored)
|
|
207
|
+
if (typeof source === "string") files.push({ source, effect: semanticEffect });
|
|
208
|
+
if (typeof semantic.target === "string")
|
|
209
|
+
files.push({ source: semantic.target, effect: semanticEffect });
|
|
210
|
+
if (record(semantic.error))
|
|
211
|
+
errors.push(
|
|
212
|
+
resultError(
|
|
213
|
+
semantic.error.message,
|
|
214
|
+
typeof semantic.error.code === "string" ? semantic.error.code : "MUTATION_FAILED",
|
|
215
|
+
source,
|
|
216
|
+
),
|
|
217
|
+
);
|
|
218
|
+
if (typeof semantic.postProcessingError === "string")
|
|
219
|
+
errors.push(resultError(semantic.postProcessingError, "POST_EDIT_FAILED", source));
|
|
220
|
+
if (semantic.ok === false && errors.length === 0)
|
|
221
|
+
errors.push(resultError("Resource operation failed", "MUTATION_FAILED", source));
|
|
222
|
+
}
|
|
223
|
+
const unique = [...new Map(files.map((file) => [file.source, file])).values()];
|
|
224
|
+
const known = unique.some((file) => file.effect === "applied");
|
|
225
|
+
if (result.isError && errors.length === 0)
|
|
226
|
+
errors.push({ code: "MUTATION_FAILED", message: "Mutation failed" });
|
|
227
|
+
if ((results?.length ?? 0) === 0 && !semantic && observed.size === 0 && errors.length === 0)
|
|
228
|
+
errors.push({ code: "UNKNOWN_RESULT", message: "Mutation effects were not reported" });
|
|
229
|
+
const effect =
|
|
230
|
+
unique.some((file) => file.effect === "unknown") ||
|
|
231
|
+
errors.some((error) => error.code === "UNKNOWN_RESULT")
|
|
232
|
+
? "unknown"
|
|
233
|
+
: known
|
|
234
|
+
? "applied"
|
|
235
|
+
: "not-applied";
|
|
236
|
+
const action =
|
|
237
|
+
semantic && typeof semantic.source === "string"
|
|
238
|
+
? {
|
|
239
|
+
source: semantic.source,
|
|
240
|
+
...(typeof semantic.kind === "string" ? { kind: semantic.kind } : {}),
|
|
241
|
+
...(typeof semantic.status === "string" ? { status: semantic.status } : {}),
|
|
242
|
+
...(typeof semantic.command === "string" ? { command: semantic.command } : {}),
|
|
243
|
+
...(typeof semantic.deleted === "boolean" ? { deleted: semantic.deleted } : {}),
|
|
244
|
+
...(typeof semantic.session === "string" ? { session: semantic.session } : {}),
|
|
245
|
+
...(typeof semantic.file === "string" ? { file: semantic.file } : {}),
|
|
246
|
+
...(typeof semantic.line === "number" ? { line: semantic.line } : {}),
|
|
247
|
+
...(typeof semantic.verified === "boolean" ? { verified: semantic.verified } : {}),
|
|
248
|
+
...(record(semantic.evaluation)
|
|
249
|
+
? {
|
|
250
|
+
evaluation: {
|
|
251
|
+
expression: semantic.evaluation.expression,
|
|
252
|
+
result: semantic.evaluation.result,
|
|
253
|
+
variablesReference: semantic.evaluation.variablesReference,
|
|
254
|
+
...(typeof semantic.evaluation.type === "string"
|
|
255
|
+
? { type: semantic.evaluation.type }
|
|
256
|
+
: {}),
|
|
257
|
+
},
|
|
258
|
+
}
|
|
259
|
+
: {}),
|
|
260
|
+
...(Array.isArray(semantic.breakpoints)
|
|
261
|
+
? {
|
|
262
|
+
breakpoints: semantic.breakpoints.filter(record).map((breakpoint) => ({
|
|
263
|
+
source: breakpoint.source,
|
|
264
|
+
file: breakpoint.file,
|
|
265
|
+
line: breakpoint.line,
|
|
266
|
+
verified: breakpoint.verified,
|
|
267
|
+
})),
|
|
268
|
+
}
|
|
269
|
+
: {}),
|
|
270
|
+
}
|
|
271
|
+
: undefined;
|
|
272
|
+
const checkedAction =
|
|
273
|
+
action && Value.Check(mutationDataSchema.properties.action, action) ? action : undefined;
|
|
274
|
+
if (action && !checkedAction)
|
|
275
|
+
errors.push(resultError("Action adapter returned invalid fields", "INVALID_STRUCTURED_RESULT"));
|
|
276
|
+
return {
|
|
277
|
+
status:
|
|
278
|
+
errors.length === 0
|
|
279
|
+
? "success"
|
|
280
|
+
: !semantic && known && unique.some((file) => file.effect !== "applied")
|
|
281
|
+
? "partial"
|
|
282
|
+
: "error",
|
|
283
|
+
data: {
|
|
284
|
+
operation,
|
|
285
|
+
effect,
|
|
286
|
+
files: unique,
|
|
287
|
+
...(details.anchorRecoveries === undefined
|
|
288
|
+
? {}
|
|
289
|
+
: {
|
|
290
|
+
recovery: details.anchorRecoveries.map((item) => ({
|
|
291
|
+
source: item.path,
|
|
292
|
+
field: item.field,
|
|
293
|
+
anchor: item.anchor,
|
|
294
|
+
total: item.total,
|
|
295
|
+
candidates: [...item.candidates],
|
|
296
|
+
})),
|
|
297
|
+
}),
|
|
298
|
+
...(typeof semantic?.transaction === "string" ? { transaction: semantic.transaction } : {}),
|
|
299
|
+
...(checkedAction ? { action: checkedAction } : {}),
|
|
300
|
+
},
|
|
301
|
+
errors,
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
/** Attach one validated public mutation receipt without copying before/after contents. */
|
|
305
|
+
export function structuredMutation(
|
|
306
|
+
result: AgentToolResult<FileMutationBatchResult>,
|
|
307
|
+
operation: string,
|
|
308
|
+
completions: readonly TextEditCompletion[] = [],
|
|
309
|
+
operationId?: string,
|
|
310
|
+
) {
|
|
311
|
+
const outcome = mutationOutcome(result, operation, completions);
|
|
312
|
+
if (outcome.data && operationId !== undefined) outcome.data.operationId = operationId;
|
|
313
|
+
return withStructuredResult(result, mutationDataSchema, outcome);
|
|
314
|
+
}
|
|
@@ -24,6 +24,8 @@ export interface TextChangeResult {
|
|
|
24
24
|
readonly changes: readonly AppliedTextChange[];
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
export type LineSeparation = "line" | "blank-line";
|
|
28
|
+
|
|
27
29
|
export class TextChangeDocument {
|
|
28
30
|
readonly #lineStarts: readonly number[];
|
|
29
31
|
readonly #separator: "\n" | "\r\n";
|
|
@@ -85,18 +87,34 @@ export class TextChangeDocument {
|
|
|
85
87
|
return { ...range, insert: "" };
|
|
86
88
|
}
|
|
87
89
|
|
|
88
|
-
public insertBeforeLine(
|
|
90
|
+
public insertBeforeLine(
|
|
91
|
+
lineNumber: number,
|
|
92
|
+
text: string,
|
|
93
|
+
separation: LineSeparation = "line",
|
|
94
|
+
): TextChange {
|
|
89
95
|
this.#assertLine(lineNumber);
|
|
90
96
|
const from = requiredValue(this.#lineStarts[lineNumber - 1]);
|
|
91
|
-
return {
|
|
97
|
+
return {
|
|
98
|
+
from,
|
|
99
|
+
to: from,
|
|
100
|
+
insert: this.#lineInsertion(from, text, separation, from < this.content.length),
|
|
101
|
+
};
|
|
92
102
|
}
|
|
93
103
|
|
|
94
|
-
public insertAfterLine(
|
|
104
|
+
public insertAfterLine(
|
|
105
|
+
lineNumber: number,
|
|
106
|
+
text: string,
|
|
107
|
+
separation: LineSeparation = "line",
|
|
108
|
+
): TextChange {
|
|
95
109
|
this.#assertLine(lineNumber);
|
|
96
110
|
const nextLine = this.#lineStarts[lineNumber];
|
|
97
111
|
|
|
98
112
|
if (nextLine !== undefined) {
|
|
99
|
-
return {
|
|
113
|
+
return {
|
|
114
|
+
from: nextLine,
|
|
115
|
+
to: nextLine,
|
|
116
|
+
insert: this.#lineInsertion(nextLine, text, separation, nextLine < this.content.length),
|
|
117
|
+
};
|
|
100
118
|
}
|
|
101
119
|
|
|
102
120
|
const prefix =
|
|
@@ -104,7 +122,7 @@ export class TextChangeDocument {
|
|
|
104
122
|
return {
|
|
105
123
|
from: this.content.length,
|
|
106
124
|
to: this.content.length,
|
|
107
|
-
insert:
|
|
125
|
+
insert: this.#lineInsertion(this.content.length, text, separation, false, prefix),
|
|
108
126
|
};
|
|
109
127
|
}
|
|
110
128
|
|
|
@@ -119,8 +137,35 @@ export class TextChangeDocument {
|
|
|
119
137
|
: text;
|
|
120
138
|
}
|
|
121
139
|
|
|
122
|
-
#
|
|
123
|
-
|
|
140
|
+
#lineInsertion(
|
|
141
|
+
from: number,
|
|
142
|
+
text: string,
|
|
143
|
+
separation: LineSeparation,
|
|
144
|
+
following: boolean,
|
|
145
|
+
prefix = "",
|
|
146
|
+
): string {
|
|
147
|
+
if (text.length === 0) throw new Error("Insert text must not be empty.");
|
|
148
|
+
if (separation === "blank-line") {
|
|
149
|
+
if (
|
|
150
|
+
from > 0 &&
|
|
151
|
+
!this.content.slice(0, from).endsWith(this.#separator + this.#separator) &&
|
|
152
|
+
!text.startsWith(this.#separator)
|
|
153
|
+
) {
|
|
154
|
+
prefix += this.#separator;
|
|
155
|
+
}
|
|
156
|
+
if (
|
|
157
|
+
following &&
|
|
158
|
+
!text.endsWith(this.#separator + this.#separator) &&
|
|
159
|
+
!this.content.slice(from).startsWith(this.#separator)
|
|
160
|
+
) {
|
|
161
|
+
return (
|
|
162
|
+
prefix +
|
|
163
|
+
text +
|
|
164
|
+
(endsWithLineBreak(text) ? this.#separator : this.#separator + this.#separator)
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return prefix + (following && !endsWithLineBreak(text) ? text + this.#separator : text);
|
|
124
169
|
}
|
|
125
170
|
|
|
126
171
|
#offsetAt(lineNumber: number, column: number): number {
|
|
@@ -242,10 +287,6 @@ function lineBreakOf(text: string): "\n" | "\r\n" | undefined {
|
|
|
242
287
|
return text.endsWith("\r\n") ? "\r\n" : text.endsWith("\n") ? "\n" : undefined;
|
|
243
288
|
}
|
|
244
289
|
|
|
245
|
-
function removeTrailingLineBreak(text: string): string {
|
|
246
|
-
return text.replace(/(?:\r\n|\n)$/u, "");
|
|
247
|
-
}
|
|
248
|
-
|
|
249
290
|
function previousLineBreakStart(text: string, offset: number): number {
|
|
250
291
|
return text[offset - 2] === "\r" && text[offset - 1] === "\n" ? offset - 2 : offset - 1;
|
|
251
292
|
}
|