pi-agent-ide 0.6.3 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +97 -0
- package/README.md +10 -3
- package/dist/{chunk-AWXVJ5AC.js → chunk-2RTCSZB3.js} +1 -1
- package/dist/chunk-3HYXQ4YA.js +28 -0
- package/dist/chunk-3JO7QFIL.js +1 -0
- package/dist/chunk-4NIFBFFR.js +11 -0
- package/dist/{chunk-VCTK4JSN.js → chunk-64M3SQPG.js} +1 -1
- package/dist/{chunk-5QQABP47.js → chunk-7LD2OQH3.js} +1 -1
- package/dist/chunk-7LZKOHH2.js +1 -0
- package/dist/chunk-AJRIASPQ.js +2 -0
- package/dist/chunk-EAZGN5ND.js +7 -0
- package/dist/{chunk-ZM4L5AGN.js → chunk-EDURPQAV.js} +3 -2
- package/dist/{chunk-GIRAEVUJ.js → chunk-F5YZG77W.js} +1 -1
- package/dist/chunk-FK42RSF4.js +1 -0
- package/dist/{chunk-O6LE42GK.js → chunk-FXNKMNSJ.js} +1 -1
- package/dist/chunk-GBLKIB6O.js +2 -0
- package/dist/chunk-KBP3QUDT.js +2 -0
- package/dist/chunk-KR36BT5E.js +1 -0
- package/dist/{chunk-NTYXZ3EL.js → chunk-KVHDMIZS.js} +1 -1
- package/dist/{chunk-QDST6VIU.js → chunk-KZC7TI5M.js} +1 -1
- package/dist/chunk-OE7QVAI2.js +5 -0
- package/dist/{chunk-GUTQ3PWL.js → chunk-PLKYHUNT.js} +1 -1
- package/dist/chunk-PNU3E7IO.js +3 -0
- package/dist/chunk-PS2B6THP.js +3 -0
- package/dist/chunk-PYPPV2F5.js +25 -0
- package/dist/{chunk-25CZ5ZIU.js → chunk-QFTBY67N.js} +3 -3
- package/dist/chunk-S5LXX32D.js +28 -0
- package/dist/chunk-SILJ3OL4.js +9 -0
- package/dist/chunk-SQKAXYIR.js +2 -0
- package/dist/chunk-VCGNVTXQ.js +1 -0
- package/dist/chunk-XYS4FSCC.js +12 -0
- package/dist/chunk-YGGKGZO2.js +1 -0
- package/dist/{chunk-L7JMDDSD.js → chunk-YRF7OATP.js} +1 -1
- 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 -9
- package/dist/entry-33.js +1 -1
- package/dist/entry-37.js +6 -6
- package/dist/entry-42.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +12 -11
- 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-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 +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-72.js +1 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-77.js +50 -307
- package/dist/entry-78.js +14 -26
- package/dist/entry-79.js +2 -2
- package/dist/entry-80.js +1 -1
- package/dist/entry-81.js +1 -1
- package/dist/entry-82.js +5 -3
- package/dist/entry-83.js +1 -1
- package/dist/entry-84.js +1 -1
- package/dist/entry-85.js +1 -1
- package/dist/entry-86.js +1 -1
- package/dist/pi-agent-ide.js +15 -3
- package/docs/agent-guides/editing.md +31 -3
- package/docs/agent-guides/git-changes.md +1 -1
- package/docs/agent-guides/json-reading.md +19 -3
- package/docs/agent-guides/read-resources.md +15 -1
- package/docs/agent-guides/search-code.md +43 -2
- package/docs/agent-guides/select-code.md +194 -0
- package/docs/agent-guides/terminal.md +1 -1
- package/docs/code-review.md +99 -0
- package/docs/configuration.md +36 -7
- package/docs/development.md +16 -19
- package/docs/nightly.md +7 -0
- package/docs/releases.md +42 -0
- 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 +29 -0
- package/docs/research/native-codemode-batching.md +65 -0
- package/docs/structured-results.md +86 -0
- package/docs/tools.md +24 -4
- 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-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 +15 -10
- package/node_modules/pi-agent-ide-ast/src/ast/constructs.ts +193 -0
- package/node_modules/pi-agent-ide-ast/src/ast/element-extent.ts +59 -0
- package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +5 -1
- package/node_modules/pi-agent-ide-ast/src/ast/selection.ts +204 -0
- package/node_modules/pi-agent-ide-ast/src/ast/syntax-tree.ts +2 -0
- package/node_modules/pi-agent-ide-ast/src/extension.ts +4 -2
- package/node_modules/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
- package/node_modules/pi-agent-ide-ast/src/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 +110 -7
- package/node_modules/pi-agent-ide-ast/src/select-presentation.ts +104 -0
- package/node_modules/pi-agent-ide-ast/src/select-schema.ts +384 -0
- package/node_modules/pi-agent-ide-ast/src/selection-region.ts +41 -0
- package/node_modules/pi-agent-ide-ast/src/source-text.ts +92 -0
- package/node_modules/pi-agent-ide-ast/src/text-selection.ts +214 -0
- package/node_modules/pi-agent-ide-ast/src/tool-select.ts +251 -0
- package/node_modules/pi-agent-ide-changes/index.ts +2 -24
- 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 +126 -48
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +11 -40
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-languages/package.json +2 -2
- package/node_modules/pi-agent-ide-lint/package.json +7 -7
- package/node_modules/pi-agent-ide-lsp/index.ts +2 -2
- package/node_modules/pi-agent-ide-lsp/package.json +9 -9
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +5 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +8 -2
- package/node_modules/pi-agent-ide-lsp/src/lsp/project.ts +19 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +204 -118
- package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +2 -17
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +92 -30
- package/node_modules/pi-agent-image/package.json +2 -2
- package/node_modules/pi-agent-invariant/package.json +1 -1
- package/node_modules/pi-agent-pdf/package.json +2 -2
- package/node_modules/pi-agent-read/package.json +7 -7
- package/node_modules/pi-agent-read/src/api/read-parameters.ts +2 -2
- package/node_modules/pi-agent-read/src/api/tools/read.ts +35 -2
- package/node_modules/pi-agent-read/src/core/extension.ts +11 -0
- 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/result-target.ts +93 -0
- package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +218 -0
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +127 -73
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/index.ts +22 -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/result-targets.ts +233 -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/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 +13 -6
- package/node_modules/pi-agent-search/src/api/search-scope.ts +22 -0
- package/node_modules/pi-agent-search/src/api/search.ts +39 -0
- package/node_modules/pi-agent-search/src/api/structured-result.ts +148 -0
- package/node_modules/pi-agent-search/src/core/extension.ts +90 -24
- package/node_modules/pi-agent-search/src/core/search-core.ts +145 -78
- package/node_modules/pi-agent-search-text/index.ts +6 -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 +174 -26
- package/node_modules/pi-agent-search-text/src/scoped-search.ts +103 -0
- package/node_modules/pi-agent-search-text/src/search-backend.ts +201 -18
- 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 +90 -259
- package/node_modules/pi-agent-search-text/src/search-result.ts +77 -0
- package/node_modules/pi-agent-search-text/src/search-session.ts +110 -17
- 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 -7
- package/node_modules/pi-agent-text-editor/package.json +20 -21
- 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/mutation-tool.ts +3 -1
- package/node_modules/pi-agent-text-editor/src/api/native-edit-batch-event.ts +12 -0
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +1 -20
- 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 +78 -41
- package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +8 -0
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +12 -2
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +35 -4
- package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/file-result-targets.ts +76 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
- 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 +820 -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/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 +412 -0
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +149 -139
- 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 +236 -185
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +253 -203
- 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-tool-schema-properties.ts +9 -6
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +5 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -7
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +8 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +8 -3
- package/node_modules/pi-agent-text-editor-renderer/index.ts +9 -73
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -5
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +276 -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-renderer/src/renderer.ts +19 -45
- package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +16 -1
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +4 -4
- package/node_modules/pi-agent-tool-call-interception/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/package.json +1 -1
- 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 +23 -0
- package/node_modules/pi-agent-web/package.json +7 -6
- package/node_modules/pi-agent-web/src/search.ts +221 -0
- package/node_modules/pi-agent-web-html/package.json +2 -2
- package/node_modules/pi-agent-web-image/package.json +3 -3
- package/node_modules/pi-agent-web-pdf/package.json +3 -3
- package/node_modules/pi-agent-web-text/package.json +3 -3
- package/package.json +42 -37
- 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/module-labels.ts +1 -1
- package/src/composite/nested-tool-rendering.ts +298 -0
- package/src/composite/preferences.ts +0 -5
- 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 +23 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +2 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/search.ts +221 -0
- package/src/extensions/pi-agent-read/package.json +7 -7
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +2 -2
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +35 -2
- package/src/extensions/pi-agent-read/src/core/extension.ts +11 -0
- 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/result-target.ts +93 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +218 -0
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +127 -73
- package/src/extensions/pi-agent-search/package.json +5 -4
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +6 -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 +174 -26
- 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 +201 -18
- 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 +90 -259
- 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 +110 -17
- 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 +13 -6
- package/src/extensions/pi-agent-search/src/api/search-scope.ts +22 -0
- package/src/extensions/pi-agent-search/src/api/search.ts +39 -0
- package/src/extensions/pi-agent-search/src/api/structured-result.ts +148 -0
- package/src/extensions/pi-agent-search/src/core/extension.ts +90 -24
- package/src/extensions/pi-agent-search/src/core/search-core.ts +145 -78
- package/src/extensions/pi-agent-text-editor/index.ts +4 -7
- package/src/extensions/pi-agent-text-editor/package.json +20 -21
- 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 +9 -73
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +276 -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-renderer/src/renderer.ts +19 -45
- 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 +4 -4
- 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/mutation-tool.ts +3 -1
- package/src/extensions/pi-agent-text-editor/src/api/native-edit-batch-event.ts +12 -0
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +1 -20
- 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 +78 -41
- package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +8 -0
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +12 -2
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +35 -4
- package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/file-result-targets.ts +76 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
- 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 +820 -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/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 +412 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +149 -139
- 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 +236 -185
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +253 -203
- 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-tool-schema-properties.ts +9 -6
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +5 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -7
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +8 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +8 -3
- package/src/pi-agent-ide.ts +61 -8
- package/src/plugins/pi-agent-ide-ast/package.json +15 -10
- package/src/plugins/pi-agent-ide-ast/src/ast/constructs.ts +193 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/element-extent.ts +59 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +5 -1
- package/src/plugins/pi-agent-ide-ast/src/ast/selection.ts +204 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/syntax-tree.ts +2 -0
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +4 -2
- package/src/plugins/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
- package/src/plugins/pi-agent-ide-ast/src/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 +110 -7
- package/src/plugins/pi-agent-ide-ast/src/select-presentation.ts +104 -0
- package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +384 -0
- package/src/plugins/pi-agent-ide-ast/src/selection-region.ts +41 -0
- package/src/plugins/pi-agent-ide-ast/src/source-text.ts +92 -0
- package/src/plugins/pi-agent-ide-ast/src/text-selection.ts +214 -0
- package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +251 -0
- package/src/plugins/pi-agent-ide-changes/index.ts +2 -24
- 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 +126 -48
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +11 -40
- 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/index.ts +2 -2
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +5 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +8 -2
- package/src/plugins/pi-agent-ide-lsp/src/lsp/project.ts +19 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +204 -118
- package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +2 -17
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +92 -30
- 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 +16 -37
- 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 +98 -46
- 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 +35 -1
- package/dist/chunk-3E2NTWCN.js +0 -2
- package/dist/chunk-4LUW26BX.js +0 -10
- package/dist/chunk-4U2GUKNJ.js +0 -0
- package/dist/chunk-5VSE5X5R.js +0 -2
- package/dist/chunk-6EYWFBNG.js +0 -0
- package/dist/chunk-7WCZOO5I.js +0 -1
- 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-ITSNK5YG.js +0 -7
- 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-ROXXK6TW.js +0 -0
- package/dist/chunk-S3ZPXWX7.js +0 -2
- package/dist/chunk-T7CZIACQ.js +0 -27
- package/dist/chunk-VXD6FZP5.js +0 -5
- package/dist/chunk-YHUTTZC6.js +0 -2
- package/dist/chunk-YT42LKFV.js +0 -16
- 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 -155
- package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +0 -344
- 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 -133
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +0 -369
- package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +0 -148
- package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +0 -920
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +0 -52
- 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 -155
- package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +0 -344
- 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 -133
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +0 -369
- package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +0 -148
- package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +0 -920
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +0 -52
|
@@ -13,6 +13,8 @@ import {
|
|
|
13
13
|
type TextEditorPlugin,
|
|
14
14
|
} from "pi-agent-text-editor/api/plugin-protocol";
|
|
15
15
|
import type { AgentContent, ResourceResolver } from "pi-agent-resource";
|
|
16
|
+
import { withStructuredResult, resultError } from "pi-agent-resource";
|
|
17
|
+
import { mutationDataSchema } from "pi-agent-text-editor/api/mutation-result";
|
|
16
18
|
|
|
17
19
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
18
20
|
|
|
@@ -166,6 +168,7 @@ export async function registerTerminalResources(
|
|
|
166
168
|
kind: "return",
|
|
167
169
|
result: {
|
|
168
170
|
content,
|
|
171
|
+
script: { kind: "native" as const, source: session.source, blocks: content },
|
|
169
172
|
details: {
|
|
170
173
|
source: session.source,
|
|
171
174
|
resolvedBy: "terminal",
|
|
@@ -259,16 +262,23 @@ export async function registerTerminalResources(
|
|
|
259
262
|
typeof requestedSource === "string" &&
|
|
260
263
|
isShellSource(requestedSource)
|
|
261
264
|
) {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
265
|
+
const message = `replace is unsupported for ${requestedSource}; use write for text, insert for keys, or delete to terminate and remove the session.`;
|
|
266
|
+
return withStructuredResult(
|
|
267
|
+
{
|
|
268
|
+
content: [{ type: "text", text: message }],
|
|
269
|
+
details: event.details,
|
|
270
|
+
},
|
|
271
|
+
mutationDataSchema,
|
|
272
|
+
{
|
|
273
|
+
status: "error",
|
|
274
|
+
errors: [resultError(message, "UNSUPPORTED_OPERATION", requestedSource)],
|
|
275
|
+
data: {
|
|
276
|
+
operation: "replace",
|
|
277
|
+
effect: "not-applied",
|
|
278
|
+
files: [{ source: requestedSource, effect: "not-applied" }],
|
|
267
279
|
},
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
isError: true,
|
|
271
|
-
};
|
|
280
|
+
},
|
|
281
|
+
);
|
|
272
282
|
}
|
|
273
283
|
if (
|
|
274
284
|
event.toolName === "delete" &&
|
|
@@ -279,27 +289,49 @@ export async function registerTerminalResources(
|
|
|
279
289
|
if (session === undefined) return;
|
|
280
290
|
const snapshot = manager.snapshot(session);
|
|
281
291
|
return manager.delete(requestedSource).then(
|
|
282
|
-
() =>
|
|
283
|
-
|
|
284
|
-
{
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
292
|
+
() =>
|
|
293
|
+
withStructuredResult(
|
|
294
|
+
{
|
|
295
|
+
content: [{ type: "text", text: `Deleted terminal session ${requestedSource}.` }],
|
|
296
|
+
details: {
|
|
297
|
+
source: requestedSource,
|
|
298
|
+
deleted: true,
|
|
299
|
+
snapshot,
|
|
300
|
+
action: "delete",
|
|
301
|
+
input: "session",
|
|
302
|
+
changedLines: [],
|
|
303
|
+
} satisfies TerminalActionDetails,
|
|
304
|
+
},
|
|
305
|
+
mutationDataSchema,
|
|
306
|
+
{
|
|
307
|
+
status: "success",
|
|
308
|
+
errors: [],
|
|
309
|
+
data: {
|
|
310
|
+
operation: "delete",
|
|
311
|
+
effect: "applied",
|
|
312
|
+
files: [{ source: requestedSource, effect: "applied" }],
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
),
|
|
316
|
+
(error: unknown) =>
|
|
317
|
+
withStructuredResult(
|
|
318
|
+
{
|
|
319
|
+
content: [
|
|
320
|
+
{ type: "text", text: error instanceof Error ? error.message : String(error) },
|
|
321
|
+
],
|
|
322
|
+
details: { source: requestedSource, deleted: false },
|
|
323
|
+
},
|
|
324
|
+
mutationDataSchema,
|
|
325
|
+
{
|
|
326
|
+
status: "error",
|
|
327
|
+
errors: [resultError(error, "TERMINAL_DELETE_FAILED", requestedSource)],
|
|
328
|
+
data: {
|
|
329
|
+
operation: "delete",
|
|
330
|
+
effect: "unknown",
|
|
331
|
+
files: [{ source: requestedSource, effect: "unknown" }],
|
|
332
|
+
},
|
|
333
|
+
},
|
|
334
|
+
),
|
|
303
335
|
);
|
|
304
336
|
}
|
|
305
337
|
if (event.toolName !== "write" && event.toolName !== "insert") return;
|
|
@@ -342,6 +374,9 @@ export async function registerTerminalResources(
|
|
|
342
374
|
changedLines: region.lines,
|
|
343
375
|
} satisfies TerminalActionDetails,
|
|
344
376
|
isError: event.isError,
|
|
377
|
+
...(event.structuredContent === undefined
|
|
378
|
+
? {}
|
|
379
|
+
: { structuredContent: event.structuredContent }),
|
|
345
380
|
};
|
|
346
381
|
});
|
|
347
382
|
}
|
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
type SearchPlugin,
|
|
6
6
|
} from "pi-agent-search/api/plugin-protocol";
|
|
7
7
|
import type { SearchRequest, SearchSelectionMatch } from "pi-agent-search/api/search";
|
|
8
|
+
import { selectionData, renderSearchMatches } from "pi-agent-search/api/search";
|
|
9
|
+
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
8
10
|
|
|
9
11
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
10
|
-
import type { Component } from "@earendil-works/pi-tui";
|
|
11
12
|
|
|
12
|
-
import { renderTerminalAction } from "#src/plugins/pi-agent-ide-terminal/src/renderer.js";
|
|
13
13
|
import type { TerminalSessionManager } from "#src/plugins/pi-agent-ide-terminal/src/session-manager.js";
|
|
14
14
|
import type { TerminalSessionSnapshot } from "#src/plugins/pi-agent-ide-terminal/src/types.js";
|
|
15
15
|
|
|
@@ -40,7 +40,13 @@ export async function registerTerminalSearch(
|
|
|
40
40
|
|
|
41
41
|
function terminalSearchResolver(manager: TerminalSessionManager) {
|
|
42
42
|
return {
|
|
43
|
+
readResources: (request: SearchRequest) =>
|
|
44
|
+
request.path?.startsWith("shell:") ? [request.path] : [],
|
|
43
45
|
id: "terminal",
|
|
46
|
+
toScriptData(payload: unknown) {
|
|
47
|
+
const result = parsePayload(payload);
|
|
48
|
+
return selectionData(result.matches, false);
|
|
49
|
+
},
|
|
44
50
|
async tryResolve(request: SearchRequest) {
|
|
45
51
|
if (request.path === undefined || !request.path.startsWith("shell:")) {
|
|
46
52
|
return { kind: "not-handled" as const };
|
|
@@ -84,50 +90,23 @@ function terminalSearchResolver(manager: TerminalSessionManager) {
|
|
|
84
90
|
renderResult(
|
|
85
91
|
result: { details: unknown },
|
|
86
92
|
options: { readonly expanded?: boolean },
|
|
87
|
-
theme:
|
|
93
|
+
theme: Theme,
|
|
88
94
|
) {
|
|
89
95
|
const details = result.details;
|
|
90
96
|
const payload = isRecord(details) ? parsePayload(details.payload) : parsePayload(undefined);
|
|
91
|
-
|
|
92
|
-
payload.
|
|
93
|
-
|
|
94
|
-
JSON.stringify(payload.query),
|
|
95
|
-
payload.matches.slice(-6).map((match) => `${match.lineNumber}: ${match.lineText}`),
|
|
97
|
+
return renderSearchMatches(
|
|
98
|
+
payload.matches,
|
|
99
|
+
false,
|
|
96
100
|
theme,
|
|
101
|
+
options.expanded === true,
|
|
102
|
+
undefined,
|
|
103
|
+
[`Retained terminal output · ${payload.snapshot.status} · read-only`],
|
|
97
104
|
);
|
|
98
|
-
return new TerminalSearchPanel(content, options.expanded === true, theme);
|
|
99
105
|
},
|
|
100
106
|
};
|
|
101
107
|
}
|
|
102
108
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
/** Keep terminal search readable without changing the complete agent-facing result. */
|
|
106
|
-
export class TerminalSearchPanel implements Component {
|
|
107
|
-
public constructor(
|
|
108
|
-
private readonly content: Component,
|
|
109
|
-
private readonly expanded: boolean,
|
|
110
|
-
private readonly theme: Parameters<typeof renderTerminalAction>[4],
|
|
111
|
-
) {}
|
|
112
|
-
|
|
113
|
-
public render(width: number): string[] {
|
|
114
|
-
const rows = this.content.render(width);
|
|
115
|
-
if (this.expanded || rows.length <= COMPACT_TERMINAL_SEARCH_ROWS) return rows;
|
|
116
|
-
const shown = COMPACT_TERMINAL_SEARCH_ROWS - 1;
|
|
117
|
-
return [
|
|
118
|
-
...rows.slice(0, shown),
|
|
119
|
-
this.theme.fg(
|
|
120
|
-
"muted",
|
|
121
|
-
`… ${String(rows.length - shown)} visual rows omitted · ctrl+o to expand`,
|
|
122
|
-
),
|
|
123
|
-
];
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
public invalidate(): void {
|
|
127
|
-
this.content.invalidate();
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
109
|
+
/** Find literal matches in retained output without claiming a complete source scope. */
|
|
131
110
|
export function findTerminalMatches(
|
|
132
111
|
snapshot: TerminalSessionSnapshot,
|
|
133
112
|
request: SearchRequest,
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { open } from "node:fs/promises";
|
|
2
|
+
import { Type } from "typebox";
|
|
3
|
+
import type { TerminalSessionSnapshot } from "#src/plugins/pi-agent-ide-terminal/src/types.js";
|
|
4
|
+
|
|
5
|
+
const MAX_OUTPUT_BYTES = 1024 * 1024;
|
|
6
|
+
|
|
7
|
+
/** Native shell fields plus IDE session lifecycle and exact UTF-8 log ranges. */
|
|
8
|
+
export const shellOutputSchema = Type.Object({
|
|
9
|
+
output: Type.String({
|
|
10
|
+
description:
|
|
11
|
+
"ANSI-free PTY output, up to 1 MiB. Longer output joins the first and last 512 KiB without adding labels or an omission marker. See output_ranges for the gap.",
|
|
12
|
+
}),
|
|
13
|
+
truncated: Type.Boolean({
|
|
14
|
+
description:
|
|
15
|
+
"Whether output omits bytes from the retained log. This is independent of whether the process has finished.",
|
|
16
|
+
}),
|
|
17
|
+
full_output_path: Type.String({
|
|
18
|
+
description:
|
|
19
|
+
"UTF-8 log of all output received so far. Available until the shell session is deleted.",
|
|
20
|
+
}),
|
|
21
|
+
output_ranges: Type.Array(Type.Object({ start: Type.Integer(), end: Type.Integer() }), {
|
|
22
|
+
description:
|
|
23
|
+
"Zero-based, end-exclusive UTF-8 byte ranges in the log, concatenated into output.",
|
|
24
|
+
}),
|
|
25
|
+
exit_code: Type.Optional(Type.Number({ description: "Process exit code, only when known." })),
|
|
26
|
+
wall_time_seconds: Type.Number(),
|
|
27
|
+
session: Type.String({ description: "Session ID." }),
|
|
28
|
+
source: Type.String({ description: "Persistent shell: source for Read, input and termination." }),
|
|
29
|
+
status: Type.Union(
|
|
30
|
+
["running", "completed", "failed", "stopping", "stopped", "cancelled", "lost"].map((value) =>
|
|
31
|
+
Type.Literal(value),
|
|
32
|
+
),
|
|
33
|
+
),
|
|
34
|
+
background: Type.Boolean(),
|
|
35
|
+
wait_reason: Type.Optional(
|
|
36
|
+
Type.Union([Type.Literal("timeout"), Type.Literal("interactive"), Type.Literal("steering")]),
|
|
37
|
+
),
|
|
38
|
+
completion_reason: Type.Optional(Type.Literal("timeout")),
|
|
39
|
+
signal: Type.Optional(Type.Number()),
|
|
40
|
+
error: Type.Optional(Type.String()),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
/** Read a bounded point-in-time result from the existing log, not the rolling preview. */
|
|
44
|
+
export async function structuredShellResult(snapshot: TerminalSessionSnapshot) {
|
|
45
|
+
const file = await open(snapshot.fullOutputPath, "r");
|
|
46
|
+
try {
|
|
47
|
+
const size = (await file.stat()).size;
|
|
48
|
+
const readRange = async (start: number, length: number) => {
|
|
49
|
+
const buffer = Buffer.alloc(length);
|
|
50
|
+
let read = 0;
|
|
51
|
+
while (read < length) {
|
|
52
|
+
const chunk = await file.read(buffer, read, length - read, start + read);
|
|
53
|
+
if (chunk.bytesRead === 0)
|
|
54
|
+
throw new Error("Shell output log ended before its snapshot size");
|
|
55
|
+
read += chunk.bytesRead;
|
|
56
|
+
}
|
|
57
|
+
return buffer;
|
|
58
|
+
};
|
|
59
|
+
let output: string;
|
|
60
|
+
let outputRanges: { start: number; end: number }[];
|
|
61
|
+
const truncated = size > MAX_OUTPUT_BYTES;
|
|
62
|
+
if (!truncated) {
|
|
63
|
+
output = (await readRange(0, size)).toString("utf8");
|
|
64
|
+
outputRanges = [{ start: 0, end: size }];
|
|
65
|
+
} else {
|
|
66
|
+
const half = MAX_OUTPUT_BYTES / 2;
|
|
67
|
+
const head = await readRange(0, half);
|
|
68
|
+
const tail = await readRange(size - half, half);
|
|
69
|
+
const headText = new TextDecoder().decode(head, { stream: true });
|
|
70
|
+
let tailStart = 0;
|
|
71
|
+
while (tailStart < tail.length && (tail.readUInt8(tailStart) & 0xc0) === 0x80) tailStart++;
|
|
72
|
+
const tailText = tail.subarray(tailStart).toString("utf8");
|
|
73
|
+
output = headText + tailText;
|
|
74
|
+
outputRanges = [
|
|
75
|
+
{ start: 0, end: Buffer.byteLength(headText) },
|
|
76
|
+
{ start: size - half + tailStart, end: size },
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
output,
|
|
81
|
+
truncated,
|
|
82
|
+
full_output_path: snapshot.fullOutputPath,
|
|
83
|
+
output_ranges: outputRanges,
|
|
84
|
+
...(snapshot.exitCode === undefined ? {} : { exit_code: snapshot.exitCode }),
|
|
85
|
+
wall_time_seconds: snapshot.elapsedMs / 1000,
|
|
86
|
+
session: snapshot.id,
|
|
87
|
+
source: snapshot.source,
|
|
88
|
+
status: snapshot.status,
|
|
89
|
+
background: snapshot.background,
|
|
90
|
+
...(snapshot.waitReason === undefined ? {} : { wait_reason: snapshot.waitReason }),
|
|
91
|
+
...(snapshot.completionReason === undefined
|
|
92
|
+
? {}
|
|
93
|
+
: { completion_reason: snapshot.completionReason }),
|
|
94
|
+
...(snapshot.signal === undefined ? {} : { signal: snapshot.signal }),
|
|
95
|
+
...(snapshot.error === undefined ? {} : { error: snapshot.error }),
|
|
96
|
+
};
|
|
97
|
+
} finally {
|
|
98
|
+
await file.close();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { AgentSession } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
|
|
3
|
+
type SteeringObserver = (session: AgentSession) => void;
|
|
4
|
+
const observersKey = Symbol.for("pi-agent-ide.terminal-steering-observers");
|
|
5
|
+
interface SteeringObservers {
|
|
6
|
+
readonly listeners: Set<SteeringObserver>;
|
|
7
|
+
readonly restore: () => void;
|
|
8
|
+
}
|
|
9
|
+
type ObservedPrototype = typeof AgentSession.prototype & {
|
|
10
|
+
[observersKey]?: SteeringObservers;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/** Observe accepted user steering after Pi queues it, without bypassing its input handlers. */
|
|
14
|
+
export function observeQueuedSteering(observer: SteeringObserver): () => void {
|
|
15
|
+
const prototype = AgentSession.prototype as ObservedPrototype;
|
|
16
|
+
const observers = prototype[observersKey] ?? installObservers(prototype);
|
|
17
|
+
observers.listeners.add(observer);
|
|
18
|
+
return () => {
|
|
19
|
+
observers.listeners.delete(observer);
|
|
20
|
+
if (observers.listeners.size === 0) observers.restore();
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function installObservers(prototype: ObservedPrototype): SteeringObservers {
|
|
25
|
+
const originalPrompt = prototype.prompt;
|
|
26
|
+
const originalSteer = prototype.steer;
|
|
27
|
+
const listeners = new Set<SteeringObserver>();
|
|
28
|
+
const notify = (session: AgentSession): void => {
|
|
29
|
+
for (const listener of [...listeners]) listener(session);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// TUI Enter calls prompt, while RPC and queue editing call steer directly.
|
|
33
|
+
// The preflight hook runs after queue insertion and distinguishes consumed input.
|
|
34
|
+
const prompt: AgentSession["prompt"] = function (this: AgentSession, text, options) {
|
|
35
|
+
if (options?.streamingBehavior !== "steer") return originalPrompt.call(this, text, options);
|
|
36
|
+
return originalPrompt.call(this, text, {
|
|
37
|
+
...options,
|
|
38
|
+
preflightResult: (disposition) => {
|
|
39
|
+
options.preflightResult?.(disposition);
|
|
40
|
+
if (disposition === "queued") notify(this);
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
const steer: AgentSession["steer"] = async function (this: AgentSession, ...args) {
|
|
45
|
+
const disposition = await originalSteer.apply(this, args);
|
|
46
|
+
if (disposition === "queued") notify(this);
|
|
47
|
+
return disposition;
|
|
48
|
+
};
|
|
49
|
+
prototype.prompt = prompt;
|
|
50
|
+
prototype.steer = steer;
|
|
51
|
+
const observers: SteeringObservers = {
|
|
52
|
+
listeners,
|
|
53
|
+
restore: () => {
|
|
54
|
+
if (prototype[observersKey] !== observers) return;
|
|
55
|
+
if (prototype.prompt === prompt) prototype.prompt = originalPrompt;
|
|
56
|
+
if (prototype.steer === steer) prototype.steer = originalSteer;
|
|
57
|
+
delete prototype[observersKey];
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
prototype[observersKey] = observers;
|
|
61
|
+
return observers;
|
|
62
|
+
}
|
|
@@ -6,7 +6,14 @@ import { Type } from "typebox";
|
|
|
6
6
|
import { Text } from "@earendil-works/pi-tui";
|
|
7
7
|
|
|
8
8
|
import { COMPACT_READ_ROWS } from "#src/extensions/pi-agent-read/src/core/tools/read/read-renderer.js";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
formatAgentTerminalSnapshot,
|
|
11
|
+
terminalOutputTail,
|
|
12
|
+
} from "#src/plugins/pi-agent-ide-terminal/src/output-limits.js";
|
|
13
|
+
import {
|
|
14
|
+
shellOutputSchema,
|
|
15
|
+
structuredShellResult,
|
|
16
|
+
} from "#src/plugins/pi-agent-ide-terminal/src/shell-result.js";
|
|
10
17
|
import { renderRunCall, renderRunResult } from "#src/plugins/pi-agent-ide-terminal/src/renderer.js";
|
|
11
18
|
|
|
12
19
|
import { shellSyntaxGuidance } from "#src/plugins/pi-agent-ide-terminal/src/shell-profile.js";
|
|
@@ -17,59 +24,76 @@ import type {
|
|
|
17
24
|
TerminalSessionSnapshot,
|
|
18
25
|
} from "#src/plugins/pi-agent-ide-terminal/src/types.js";
|
|
19
26
|
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
background: Type.Optional(
|
|
27
|
-
Type.Boolean({
|
|
28
|
-
description: "Return immediately while the terminal session continues. Defaults to false.",
|
|
29
|
-
}),
|
|
30
|
-
),
|
|
31
|
-
timeoutSeconds: Type.Optional(
|
|
32
|
-
Type.Number({
|
|
33
|
-
minimum: 0.1,
|
|
34
|
-
maximum: 86_400,
|
|
35
|
-
description:
|
|
36
|
-
"Maximum foreground wait in seconds before returning the live session as background. Defaults to 60.",
|
|
27
|
+
const createRunParameters = (profile: ShellProfile) =>
|
|
28
|
+
Type.Object(
|
|
29
|
+
{
|
|
30
|
+
command: Type.String({
|
|
31
|
+
minLength: 1,
|
|
32
|
+
description: `Command for ${profile.displayName} (${profile.executable}). ${shellSyntaxGuidance(profile)}`,
|
|
37
33
|
}),
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
34
|
+
background: Type.Optional(
|
|
35
|
+
Type.Boolean({
|
|
36
|
+
description:
|
|
37
|
+
"Return immediately while the terminal session continues. Defaults to false.",
|
|
38
|
+
}),
|
|
39
|
+
),
|
|
40
|
+
timeoutSeconds: Type.Optional(
|
|
41
|
+
Type.Number({
|
|
42
|
+
minimum: 0.1,
|
|
43
|
+
maximum: 86_400,
|
|
44
|
+
description:
|
|
45
|
+
"Maximum foreground wait in seconds before returning the live session as background. Defaults to 60.",
|
|
46
|
+
}),
|
|
47
|
+
),
|
|
48
|
+
cwd: Type.Optional(
|
|
49
|
+
Type.String({
|
|
50
|
+
description: "Working directory. Relative paths resolve from the current workspace.",
|
|
51
|
+
}),
|
|
52
|
+
),
|
|
53
|
+
cols: Type.Optional(
|
|
54
|
+
Type.Integer({ minimum: 20, maximum: 300, description: "Virtual terminal width in cells" }),
|
|
55
|
+
),
|
|
56
|
+
rows: Type.Optional(
|
|
57
|
+
Type.Integer({ minimum: 5, maximum: 120, description: "Virtual terminal height in cells" }),
|
|
58
|
+
),
|
|
59
|
+
},
|
|
60
|
+
{ additionalProperties: false },
|
|
61
|
+
);
|
|
53
62
|
|
|
54
|
-
/** Register
|
|
63
|
+
/** Register shell tools and return a callback that releases their active waits on steering. */
|
|
55
64
|
export function registerTerminalTools(
|
|
56
|
-
pi: ExtensionAPI,
|
|
65
|
+
pi: Pick<ExtensionAPI, "registerTool">,
|
|
57
66
|
manager: TerminalSessionManager,
|
|
58
67
|
profile: ShellProfile,
|
|
59
68
|
ui: Pick<TerminalUi, "bind" | "notifyWaitTransition">,
|
|
60
69
|
presentation: "full" | "compact" | "disabled" = "compact",
|
|
61
|
-
): void {
|
|
70
|
+
): () => void {
|
|
71
|
+
// Keep wait cancellation in this registration, not in a PTY manager retained from older code.
|
|
72
|
+
const foregroundWaits = new Set<AbortController>();
|
|
62
73
|
const toolName = process.platform === "win32" ? "powershell" : "bash";
|
|
74
|
+
const runParameters = createRunParameters(profile);
|
|
63
75
|
pi.registerTool(
|
|
64
76
|
defineTool<typeof runParameters, TerminalSessionSnapshot>({
|
|
65
77
|
name: toolName,
|
|
78
|
+
exposure: "direct",
|
|
79
|
+
namespace: {
|
|
80
|
+
name: "ide_terminal",
|
|
81
|
+
description: "Run shell commands in persistent terminal sessions.",
|
|
82
|
+
},
|
|
83
|
+
annotations: {
|
|
84
|
+
readOnlyHint: false,
|
|
85
|
+
destructiveHint: true,
|
|
86
|
+
idempotentHint: false,
|
|
87
|
+
openWorldHint: true,
|
|
88
|
+
},
|
|
66
89
|
label: profile.displayName,
|
|
67
90
|
promptSnippet: `Execute ${profile.displayName} commands in synchronous or background terminal sessions`,
|
|
68
91
|
promptGuidelines: [
|
|
69
|
-
`Do not use ${toolName} commands or scripts to edit files. Use
|
|
92
|
+
`Do not use ${toolName} commands or scripts to edit files. Use the standalone editing tools instead. Commands that inherently generate files, such as formatters and code generators, are allowed.`,
|
|
70
93
|
],
|
|
71
|
-
description: `Use ${toolName} to execute a command in the user's configured ${profile.displayName} shell (${profile.executable}). Every call creates an addressable terminal session. Set background to true to continue without waiting. A foreground wait automatically returns the live session as background on timeout, a stable interactive prompt, or turn abort. Background completion is delivered automatically and wakes the agent. Silent background sessions
|
|
94
|
+
description: `Use ${toolName} to execute a command in the user's configured ${profile.displayName} shell (${profile.executable}). Every call creates an addressable terminal session. Set background to true to continue without waiting. A foreground wait automatically returns the live session as background on timeout, a stable interactive prompt, or turn abort. Background completion is delivered automatically and wakes the agent. Silent background sessions wake an idle agent once for inspection after two minutes, with no further stale reminders for that session. Sessions survive extension reloads and keep the same shell: source. Output uses the shared Read limits, keeps the tail, and links a complete log file when truncated.`,
|
|
72
95
|
parameters: runParameters,
|
|
96
|
+
outputSchema: shellOutputSchema,
|
|
73
97
|
async execute(_toolCallId, input, signal, onUpdate, context) {
|
|
74
98
|
ui.bind(context);
|
|
75
99
|
const cwd = input.cwd === undefined ? context.cwd : path.resolve(context.cwd, input.cwd);
|
|
@@ -87,10 +111,22 @@ export function registerTerminalTools(
|
|
|
87
111
|
return terminalResult(manager.snapshot(session));
|
|
88
112
|
}
|
|
89
113
|
if (session.status === "failed") return terminalResult(manager.snapshot(session));
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
114
|
+
const steering = new AbortController();
|
|
115
|
+
foregroundWaits.add(steering);
|
|
116
|
+
let outcome;
|
|
117
|
+
try {
|
|
118
|
+
outcome = await manager.waitForForeground(session.source, {
|
|
119
|
+
signal:
|
|
120
|
+
signal === undefined ? steering.signal : AbortSignal.any([signal, steering.signal]),
|
|
121
|
+
timeoutMs: (input.timeoutSeconds ?? 60) * 1_000,
|
|
122
|
+
});
|
|
123
|
+
} finally {
|
|
124
|
+
foregroundWaits.delete(steering);
|
|
125
|
+
}
|
|
126
|
+
if (outcome.reason === "aborted" && steering.signal.aborted && signal?.aborted !== true) {
|
|
127
|
+
outcome.session.waitReason = "steering";
|
|
128
|
+
return terminalResult(manager.snapshot(outcome.session));
|
|
129
|
+
}
|
|
94
130
|
if (outcome.reason === "aborted") ui.notifyWaitTransition(outcome.session);
|
|
95
131
|
return terminalResult(manager.snapshot(outcome.session));
|
|
96
132
|
},
|
|
@@ -111,19 +147,35 @@ export function registerTerminalTools(
|
|
|
111
147
|
},
|
|
112
148
|
}),
|
|
113
149
|
);
|
|
150
|
+
return () => {
|
|
151
|
+
for (const wait of foregroundWaits) wait.abort();
|
|
152
|
+
};
|
|
114
153
|
}
|
|
115
154
|
|
|
116
|
-
function
|
|
155
|
+
function terminalPreview(snapshot: TerminalSessionSnapshot) {
|
|
156
|
+
const output = terminalOutputTail(snapshot.output).content;
|
|
117
157
|
return {
|
|
118
158
|
content: [{ type: "text" as const, text: formatAgentTerminalSnapshot(snapshot) }],
|
|
119
|
-
details:
|
|
159
|
+
details: {
|
|
160
|
+
...snapshot,
|
|
161
|
+
output,
|
|
162
|
+
outputStart: snapshot.outputEnd - output.length,
|
|
163
|
+
truncated: snapshot.truncated || output.length < snapshot.output.length,
|
|
164
|
+
},
|
|
120
165
|
isError: snapshot.status === "failed" || snapshot.status === "lost",
|
|
121
166
|
};
|
|
122
167
|
}
|
|
168
|
+
|
|
169
|
+
async function terminalResult(snapshot: TerminalSessionSnapshot) {
|
|
170
|
+
return {
|
|
171
|
+
...terminalPreview(snapshot),
|
|
172
|
+
structuredContent: await structuredShellResult(snapshot),
|
|
173
|
+
};
|
|
174
|
+
}
|
|
123
175
|
async function captureInitialBackgroundPreview(
|
|
124
176
|
manager: TerminalSessionManager,
|
|
125
177
|
session: ReturnType<TerminalSessionManager["start"]>,
|
|
126
|
-
onUpdate: ((result: ReturnType<typeof
|
|
178
|
+
onUpdate: ((result: ReturnType<typeof terminalPreview>) => void) | undefined,
|
|
127
179
|
): Promise<void> {
|
|
128
180
|
await new Promise<void>((resolve) => {
|
|
129
181
|
let settled = false;
|
|
@@ -138,7 +190,7 @@ async function captureInitialBackgroundPreview(
|
|
|
138
190
|
};
|
|
139
191
|
const publish = (): void => {
|
|
140
192
|
const snapshot = manager.snapshot(session);
|
|
141
|
-
onUpdate?.(
|
|
193
|
+
onUpdate?.(terminalPreview(snapshot));
|
|
142
194
|
const rows = stripVTControlCharacters(snapshot.output)
|
|
143
195
|
.replaceAll("\r", "")
|
|
144
196
|
.split("\n")
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IPty } from "node-pty";
|
|
2
2
|
import type { Terminal } from "@xterm/headless";
|
|
3
3
|
|
|
4
|
-
export type TerminalWaitReason = "timeout" | "interactive";
|
|
4
|
+
export type TerminalWaitReason = "timeout" | "interactive" | "steering";
|
|
5
5
|
export type TerminalWaitOutcomeReason = TerminalWaitReason | "aborted";
|
|
6
6
|
export type TerminalCompletionReason = "timeout";
|
|
7
7
|
|
|
@@ -45,6 +45,8 @@ export interface TerminalSession {
|
|
|
45
45
|
completion: Promise<TerminalSession>;
|
|
46
46
|
resolveCompletion: (session: TerminalSession) => void;
|
|
47
47
|
completionDelivered: boolean;
|
|
48
|
+
/** Keep the one-time stale reminder state when this session survives a reload. */
|
|
49
|
+
staleReminderDelivered: boolean;
|
|
48
50
|
waitReason?: TerminalWaitReason;
|
|
49
51
|
completionReason?: TerminalCompletionReason;
|
|
50
52
|
lastActivityAt: number;
|
|
@@ -96,7 +96,13 @@ export class TerminalUi {
|
|
|
96
96
|
|
|
97
97
|
#refreshStaleTimer(session: TerminalSession, checkNow = false): void {
|
|
98
98
|
this.#clearStaleTimer(session.id);
|
|
99
|
-
if (
|
|
99
|
+
if (
|
|
100
|
+
this.#closed ||
|
|
101
|
+
session.staleReminderDelivered ||
|
|
102
|
+
!session.background ||
|
|
103
|
+
session.status !== "running"
|
|
104
|
+
)
|
|
105
|
+
return;
|
|
100
106
|
const snapshot = this.manager.snapshot(session);
|
|
101
107
|
const remaining = Math.max(0, this.staleIntervalMs - snapshot.idleMs);
|
|
102
108
|
if (checkNow && remaining === 0) {
|
|
@@ -111,11 +117,18 @@ export class TerminalUi {
|
|
|
111
117
|
|
|
112
118
|
#handleStale(session: TerminalSession): void {
|
|
113
119
|
this.#staleTimers.delete(session.id);
|
|
114
|
-
if (
|
|
120
|
+
if (
|
|
121
|
+
this.#closed ||
|
|
122
|
+
session.staleReminderDelivered ||
|
|
123
|
+
session.status !== "running" ||
|
|
124
|
+
!session.background
|
|
125
|
+
)
|
|
126
|
+
return;
|
|
115
127
|
if (this.#context?.isIdle() !== true) {
|
|
116
128
|
this.#overdue.add(session.id);
|
|
117
129
|
return;
|
|
118
130
|
}
|
|
131
|
+
session.staleReminderDelivered = true;
|
|
119
132
|
const snapshot = this.manager.snapshot(session);
|
|
120
133
|
this.pi.sendMessage(
|
|
121
134
|
{
|
|
@@ -126,10 +139,6 @@ export class TerminalUi {
|
|
|
126
139
|
},
|
|
127
140
|
{ triggerTurn: true, deliverAs: "followUp" },
|
|
128
141
|
);
|
|
129
|
-
this.#staleTimers.set(
|
|
130
|
-
session.id,
|
|
131
|
-
setTimeout(() => this.#handleStale(session), this.staleIntervalMs),
|
|
132
|
-
);
|
|
133
142
|
}
|
|
134
143
|
|
|
135
144
|
#clearStaleTimer(id: string): void {
|