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
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
|
|
3
|
+
interface ToolAvailability {
|
|
4
|
+
hide(): void;
|
|
5
|
+
restore(): void;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
type AvailabilityApi = Pick<
|
|
9
|
+
ExtensionAPI,
|
|
10
|
+
"registerTool" | "getSettings" | "getAllTools" | "getActiveTools" | "setActiveTools"
|
|
11
|
+
>;
|
|
12
|
+
|
|
13
|
+
/** Keep explicit settings exclusions out of every native IDE execution path. */
|
|
14
|
+
export function createIdeToolAvailability<TApi extends AvailabilityApi>(pi: TApi) {
|
|
15
|
+
const definitions = new Map<string, ToolAvailability>();
|
|
16
|
+
const hidden = new Set<string>();
|
|
17
|
+
const registerTool: ExtensionAPI["registerTool"] = (definition) => {
|
|
18
|
+
if (definition.namespace?.name.startsWith("ide_") === true) {
|
|
19
|
+
definitions.set(definition.name, {
|
|
20
|
+
hide: () =>
|
|
21
|
+
pi.registerTool({
|
|
22
|
+
...definition,
|
|
23
|
+
get description() {
|
|
24
|
+
return definition.description;
|
|
25
|
+
},
|
|
26
|
+
get promptGuidelines() {
|
|
27
|
+
return definition.promptGuidelines;
|
|
28
|
+
},
|
|
29
|
+
exposure: "hidden",
|
|
30
|
+
}),
|
|
31
|
+
restore: () => pi.registerTool(definition),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (hidden.has(definition.name)) definitions.get(definition.name)?.hide();
|
|
35
|
+
else pi.registerTool(definition);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
api: { ...pi, registerTool },
|
|
40
|
+
/** Enforce exclusions; activate configured or restored tools only at session startup. */
|
|
41
|
+
reconcile(activateDefaults = false, restoredTools: readonly string[] = []): void {
|
|
42
|
+
const excluded = new Set<string>();
|
|
43
|
+
const requested = new Set<string>();
|
|
44
|
+
for (const entry of pi.getSettings().defaultTools ?? []) {
|
|
45
|
+
if (entry.startsWith("-")) {
|
|
46
|
+
excluded.add(entry.slice(1));
|
|
47
|
+
requested.delete(entry.slice(1));
|
|
48
|
+
} else {
|
|
49
|
+
const name = entry.startsWith("+") ? entry.slice(1) : entry;
|
|
50
|
+
excluded.delete(name);
|
|
51
|
+
requested.add(name);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
for (const [name, definition] of definitions) {
|
|
55
|
+
if (excluded.has(name) === hidden.has(name)) continue;
|
|
56
|
+
if (excluded.has(name)) {
|
|
57
|
+
definition.hide();
|
|
58
|
+
hidden.add(name);
|
|
59
|
+
} else {
|
|
60
|
+
definition.restore();
|
|
61
|
+
hidden.delete(name);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// The host registry already applies CLI allowlists and exclusions. Never
|
|
65
|
+
// activate a tool absent from it, or infer deferred availability from active tools.
|
|
66
|
+
const available = pi.getAllTools().filter((tool) => tool.exposure !== "hidden");
|
|
67
|
+
const active = new Set(pi.getActiveTools());
|
|
68
|
+
for (const tool of available) {
|
|
69
|
+
if (
|
|
70
|
+
activateDefaults &&
|
|
71
|
+
definitions.has(tool.name) &&
|
|
72
|
+
(requested.has(tool.name) ||
|
|
73
|
+
(tool.exposure === "deferred" && restoredTools.includes(tool.name)))
|
|
74
|
+
)
|
|
75
|
+
active.add(tool.name);
|
|
76
|
+
}
|
|
77
|
+
if (
|
|
78
|
+
activateDefaults &&
|
|
79
|
+
!excluded.has("tool_search") &&
|
|
80
|
+
available.some((tool) => tool.name === "tool_search") &&
|
|
81
|
+
available.some((tool) => definitions.has(tool.name) && tool.exposure === "deferred")
|
|
82
|
+
)
|
|
83
|
+
active.add("tool_search");
|
|
84
|
+
const previous = pi.getActiveTools();
|
|
85
|
+
const next = [...active].filter((name) => !hidden.has(name));
|
|
86
|
+
if (next.length !== previous.length || next.some((name) => !previous.includes(name)))
|
|
87
|
+
pi.setActiveTools(next);
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
package/src/core/extension.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
} from "#src/core/diagnostic-entry.js";
|
|
15
15
|
import { runIdePostEditGate } from "#src/post-edit/gate.js";
|
|
16
16
|
import { resetRegistry } from "#src/toolchain/registry.js";
|
|
17
|
+
import registerCodeReview from "#src/code-review/extension.js";
|
|
17
18
|
import {
|
|
18
19
|
connectTextEditorPostEditHandler,
|
|
19
20
|
afterPostEditScope,
|
|
@@ -103,5 +104,6 @@ export default async function registerPiAgentIde(pi: ExtensionAPI): Promise<void
|
|
|
103
104
|
unsubscribeDiagnostics();
|
|
104
105
|
});
|
|
105
106
|
|
|
107
|
+
await registerCodeReview(pi);
|
|
106
108
|
await core.waitForPendingPlugins();
|
|
107
109
|
}
|
|
@@ -9,53 +9,29 @@ import {
|
|
|
9
9
|
type AgentDocumentation,
|
|
10
10
|
} from "#src/api/documentation.js";
|
|
11
11
|
import { AgentDocumentationRegistry } from "#src/documentation/registry.js";
|
|
12
|
-
import {
|
|
13
|
-
type InterceptResult,
|
|
14
|
-
registerToolCallInterceptor,
|
|
15
|
-
type ToolCallInterceptorHandler,
|
|
16
|
-
} from "pi-agent-text-editor/api/tool-call-interceptor";
|
|
17
12
|
|
|
18
13
|
interface RegistrationRequest {
|
|
19
14
|
readonly documents: readonly AgentDocumentation[];
|
|
20
15
|
}
|
|
21
16
|
|
|
22
|
-
|
|
17
|
+
const READ_RECORD = "agent-documentation-read";
|
|
18
|
+
|
|
19
|
+
/** Exposes packaged guides and adds unread guides to results without blocking tools. */
|
|
23
20
|
export default async function registerProgressiveDocumentation(pi: ExtensionAPI): Promise<void> {
|
|
24
21
|
const registry = new AgentDocumentationRegistry();
|
|
25
22
|
const claimed = new Set<string>();
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (context.toolCall.id.includes("-preflight-")) return;
|
|
35
|
-
const documents = claimMatchingGuides(
|
|
36
|
-
registry,
|
|
37
|
-
claimed,
|
|
38
|
-
context.toolCall.name,
|
|
39
|
-
context.partialArgs ?? context.args,
|
|
40
|
-
);
|
|
41
|
-
if (documents.length === 0) return;
|
|
42
|
-
fallbackGates.set(context.toolCall.id, documents);
|
|
43
|
-
sendGuideToAgent(pi, documents);
|
|
44
|
-
return guideGateResult(documents);
|
|
45
|
-
},
|
|
23
|
+
const parents = new Map<string, string>();
|
|
24
|
+
const pendingGuides = new Map<string, readonly AgentDocumentation[]>();
|
|
25
|
+
const remember = (ids: readonly string[]): void => {
|
|
26
|
+
const unread = ids.filter((id) => !claimed.has(id));
|
|
27
|
+
if (unread.length === 0) return;
|
|
28
|
+
// Separate records survive bounded nested-call metadata and stay on their own branch.
|
|
29
|
+
pi.appendEntry(READ_RECORD, { ids: unread });
|
|
30
|
+
for (const id of unread) claimed.add(id);
|
|
46
31
|
};
|
|
47
|
-
registerToolCallInterceptor(pi, gateHandler);
|
|
48
32
|
const unsubscribe = pi.events.on(DOCUMENTATION_REGISTER_EVENT, (value) => {
|
|
49
33
|
if (!isRegistrationRequest(value)) throw new Error("Invalid agent documentation registration");
|
|
50
34
|
registry.register(value.documents);
|
|
51
|
-
gatedToolNames.splice(
|
|
52
|
-
0,
|
|
53
|
-
gatedToolNames.length,
|
|
54
|
-
...new Set(
|
|
55
|
-
registry.list().flatMap((document) => document.triggers.map((trigger) => trigger.tool)),
|
|
56
|
-
),
|
|
57
|
-
);
|
|
58
|
-
registerToolCallInterceptor(pi, gateHandler);
|
|
59
35
|
});
|
|
60
36
|
pi.on("session_shutdown", unsubscribe);
|
|
61
37
|
|
|
@@ -101,54 +77,56 @@ export default async function registerProgressiveDocumentation(pi: ExtensionAPI)
|
|
|
101
77
|
pi.on("session_start", (_event, context) => {
|
|
102
78
|
restoreClaims(context.sessionManager.getBranch(), registry, claimed);
|
|
103
79
|
});
|
|
80
|
+
pi.on("session_tree", (_event, context) => {
|
|
81
|
+
restoreClaims(context.sessionManager.getBranch(), registry, claimed);
|
|
82
|
+
});
|
|
83
|
+
pi.on("session_compact", (_event, context) => {
|
|
84
|
+
restoreClaims(context.sessionManager.getBranch(), registry, claimed);
|
|
85
|
+
});
|
|
104
86
|
|
|
105
|
-
pi.on("tool_call", (event
|
|
106
|
-
if (process.env.PI_AGENT_IDE_TEST_SKIP_GUIDE_GATE === "1") return;
|
|
87
|
+
pi.on("tool_call", (event) => {
|
|
107
88
|
if (event.toolCallId.includes("-preflight-")) return;
|
|
108
|
-
|
|
109
|
-
const documents = claimMatchingGuides(registry, claimed, event.toolName, event.input);
|
|
110
|
-
if (documents.length === 0) return;
|
|
111
|
-
fallbackGates.set(event.toolCallId, documents);
|
|
112
|
-
sendGuideToAgent(pi, documents);
|
|
113
|
-
return { block: true, reason: guideNotice(documents) };
|
|
89
|
+
if (event.parentToolCallId !== undefined) parents.set(event.toolCallId, event.parentToolCallId);
|
|
114
90
|
});
|
|
115
|
-
pi.on("tool_result", (event
|
|
91
|
+
pi.on("tool_result", (event) => {
|
|
116
92
|
if (event.toolCallId.includes("-preflight-")) return;
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
details: documentationGateDetails(fallbackDocuments),
|
|
123
|
-
isError: true,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
restoreClaims(context.sessionManager.getBranch(), registry, claimed, event.toolCallId);
|
|
127
|
-
const docsSource = documentationSource(event.input);
|
|
93
|
+
const parent = parents.get(event.toolCallId);
|
|
94
|
+
parents.delete(event.toolCallId);
|
|
95
|
+
const inherited = pendingGuides.get(event.toolCallId) ?? [];
|
|
96
|
+
pendingGuides.delete(event.toolCallId);
|
|
97
|
+
const docsSource = event.toolName === "read" ? documentationSource(event.input) : undefined;
|
|
128
98
|
if (docsSource !== undefined) {
|
|
129
99
|
const id = docsSource.slice("docs:".length);
|
|
130
|
-
const available = registry.list();
|
|
131
100
|
const known = id.length === 0 || registry.get(id) !== undefined;
|
|
132
|
-
|
|
101
|
+
const document = registry.get(id);
|
|
102
|
+
if (document !== undefined && !event.isError && containsFullGuide(event.content, document))
|
|
103
|
+
remember([id]);
|
|
133
104
|
return {
|
|
134
105
|
content: event.content,
|
|
106
|
+
structuredContent: event.structuredContent,
|
|
135
107
|
details: {
|
|
136
108
|
...(isRecord(event.details) ? event.details : {}),
|
|
137
109
|
documentation: known
|
|
138
110
|
? id.length === 0
|
|
139
|
-
? { kind: "list", ids:
|
|
111
|
+
? { kind: "list", ids: registry.list().map((document) => document.id) }
|
|
140
112
|
: { kind: "document", id }
|
|
141
113
|
: { kind: "error", code: "UNKNOWN_DOCUMENTATION", id },
|
|
142
114
|
},
|
|
143
115
|
isError: event.isError,
|
|
144
116
|
};
|
|
145
117
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
118
|
+
const documents = [
|
|
119
|
+
...inherited,
|
|
120
|
+
...registry
|
|
121
|
+
.matching(event.toolName, event.input)
|
|
122
|
+
.filter((document) => !claimed.has(document.id)),
|
|
123
|
+
];
|
|
150
124
|
if (documents.length === 0) return;
|
|
151
|
-
|
|
125
|
+
remember(documents.map((document) => document.id));
|
|
126
|
+
// Native callers receive structured data, not this readable attachment.
|
|
127
|
+
// Keep the guide on the parent result so it reaches the agent even when data is filtered.
|
|
128
|
+
if (parent !== undefined && event.structuredContent !== undefined)
|
|
129
|
+
pendingGuides.set(parent, [...(pendingGuides.get(parent) ?? []), ...documents]);
|
|
152
130
|
return {
|
|
153
131
|
content: [
|
|
154
132
|
...event.content,
|
|
@@ -157,6 +135,7 @@ export default async function registerProgressiveDocumentation(pi: ExtensionAPI)
|
|
|
157
135
|
text: `\n\n---\n\n# Guide: ${document.id}\n\n${document.markdown.trim()}`,
|
|
158
136
|
})),
|
|
159
137
|
],
|
|
138
|
+
structuredContent: event.structuredContent,
|
|
160
139
|
details: {
|
|
161
140
|
...(isRecord(event.details) ? event.details : {}),
|
|
162
141
|
documentation: { kind: "attachment", ids: documents.map((document) => document.id) },
|
|
@@ -171,58 +150,6 @@ export default async function registerProgressiveDocumentation(pi: ExtensionAPI)
|
|
|
171
150
|
});
|
|
172
151
|
}
|
|
173
152
|
|
|
174
|
-
function claimMatchingGuides(
|
|
175
|
-
registry: AgentDocumentationRegistry,
|
|
176
|
-
claimed: Set<string>,
|
|
177
|
-
toolName: string,
|
|
178
|
-
input: unknown,
|
|
179
|
-
): readonly AgentDocumentation[] {
|
|
180
|
-
const documents = registry
|
|
181
|
-
.matching(toolName, input)
|
|
182
|
-
.filter((document) => !claimed.has(document.id));
|
|
183
|
-
for (const document of documents) claimed.add(document.id);
|
|
184
|
-
return documents;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
function renderGuideGate(documents: readonly AgentDocumentation[]): string {
|
|
188
|
-
return [
|
|
189
|
-
"[SYSTEM] Read the attached guide before using this tool. Repeat the tool call after reading it.",
|
|
190
|
-
...documents.map(
|
|
191
|
-
(document) => `\n\n---\n\n# Guide: ${document.id}\n\n${document.markdown.trim()}`,
|
|
192
|
-
),
|
|
193
|
-
].join("");
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function guideNotice(documents: readonly AgentDocumentation[]): string {
|
|
197
|
-
return `Guide sent to agent: ${documents.map((document) => document.id).join(", ")}. Repeat the tool call.`;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function sendGuideToAgent(pi: ExtensionAPI, documents: readonly AgentDocumentation[]): void {
|
|
201
|
-
pi.sendMessage({
|
|
202
|
-
customType: "agent-documentation-first-use",
|
|
203
|
-
content: renderGuideGate(documents),
|
|
204
|
-
display: false,
|
|
205
|
-
details: documentationGateDetails(documents),
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
function documentationGateDetails(documents: readonly AgentDocumentation[]): {
|
|
210
|
-
readonly documentation: { readonly kind: "gate"; readonly ids: readonly string[] };
|
|
211
|
-
} {
|
|
212
|
-
return { documentation: { kind: "gate", ids: documents.map((document) => document.id) } };
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function guideGateResult(documents: readonly AgentDocumentation[]): InterceptResult {
|
|
216
|
-
return {
|
|
217
|
-
annotation: { kind: "blocked", reason: "Read the first-use guide, then retry." },
|
|
218
|
-
message: {
|
|
219
|
-
customType: "agent-documentation-first-use",
|
|
220
|
-
content: guideNotice(documents),
|
|
221
|
-
display: false,
|
|
222
|
-
details: documentationGateDetails(documents),
|
|
223
|
-
},
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
153
|
function renderListing(documents: readonly AgentDocumentation[]): string {
|
|
227
154
|
if (documents.length === 0) return "No agent documentation is currently available.";
|
|
228
155
|
return [
|
|
@@ -235,7 +162,9 @@ function renderListing(documents: readonly AgentDocumentation[]): string {
|
|
|
235
162
|
function renderPromptGuideline(documents: readonly AgentDocumentation[]): string | undefined {
|
|
236
163
|
if (documents.length === 0) return undefined;
|
|
237
164
|
return [
|
|
238
|
-
"Read docs:<id>
|
|
165
|
+
"Read the matching docs:<id> before using any tool or feature with packaged guidance, including tools discovered later or called through Codemode. Read each guide once per branch. Tool descriptions and docs: listings do not replace the full guide.",
|
|
166
|
+
"If a result includes a Guide, read it before your next use. The call has already run: do not repeat it just to obtain documentation. Native structured child calls keep their guides on the parent result. Output readable-only child results to retain their guides; filtering those results can hide them.",
|
|
167
|
+
"Available documents:",
|
|
239
168
|
...documents.map((document) => ` - ${document.id} — ${document.description}`),
|
|
240
169
|
].join("\n");
|
|
241
170
|
}
|
|
@@ -244,48 +173,55 @@ function restoreClaims(
|
|
|
244
173
|
branch: readonly unknown[],
|
|
245
174
|
registry: AgentDocumentationRegistry,
|
|
246
175
|
claimed: Set<string>,
|
|
247
|
-
currentToolCallId?: string,
|
|
248
176
|
): void {
|
|
177
|
+
claimed.clear();
|
|
249
178
|
for (const entry of branch) {
|
|
250
|
-
if (!isRecord(entry)
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
if (typeof message.toolCallId === "string" && message.toolCallId.includes("-preflight-"))
|
|
179
|
+
if (!isRecord(entry)) continue;
|
|
180
|
+
if (entry.type === "custom" && entry.customType === READ_RECORD && isRecord(entry.data)) {
|
|
181
|
+
addIds(entry.data.ids);
|
|
254
182
|
continue;
|
|
255
|
-
if (message.role !== "toolResult" || typeof message.toolName !== "string") continue;
|
|
256
|
-
if (isRecord(message.details) && isRecord(message.details.documentation)) {
|
|
257
|
-
const documentation = message.details.documentation;
|
|
258
|
-
const ids = documentation.ids;
|
|
259
|
-
if (Array.isArray(ids)) {
|
|
260
|
-
for (const id of ids)
|
|
261
|
-
if (typeof id === "string" && registry.get(id) !== undefined) claimed.add(id);
|
|
262
|
-
continue;
|
|
263
|
-
}
|
|
264
|
-
if (
|
|
265
|
-
documentation.kind === "document" &&
|
|
266
|
-
typeof documentation.id === "string" &&
|
|
267
|
-
registry.get(documentation.id) !== undefined
|
|
268
|
-
) {
|
|
269
|
-
claimed.add(documentation.id);
|
|
270
|
-
continue;
|
|
271
|
-
}
|
|
272
183
|
}
|
|
273
|
-
|
|
274
|
-
|
|
184
|
+
if (entry.type !== "message" || !isRecord(entry.message)) continue;
|
|
185
|
+
const message = entry.message;
|
|
186
|
+
if (message.role !== "toolResult" || !isRecord(message.details)) continue;
|
|
187
|
+
const documentation = message.details.documentation;
|
|
188
|
+
if (!isRecord(documentation)) continue;
|
|
189
|
+
if (documentation.kind === "attachment") addIds(documentation.ids);
|
|
190
|
+
if (
|
|
191
|
+
documentation.kind === "document" &&
|
|
192
|
+
!message.isError &&
|
|
193
|
+
typeof documentation.id === "string"
|
|
194
|
+
) {
|
|
195
|
+
const document = registry.get(documentation.id);
|
|
196
|
+
if (document !== undefined && containsFullGuide(message.content, document))
|
|
197
|
+
addIds([document.id]);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
function addIds(ids: unknown): void {
|
|
201
|
+
if (!Array.isArray(ids)) return;
|
|
202
|
+
for (const id of ids)
|
|
203
|
+
if (typeof id === "string" && registry.get(id) !== undefined) claimed.add(id);
|
|
275
204
|
}
|
|
276
205
|
}
|
|
277
206
|
|
|
207
|
+
function containsFullGuide(content: unknown, document: AgentDocumentation): boolean {
|
|
208
|
+
return (
|
|
209
|
+
Array.isArray(content) &&
|
|
210
|
+
content.some(
|
|
211
|
+
(part: unknown) =>
|
|
212
|
+
isRecord(part) &&
|
|
213
|
+
part.type === "text" &&
|
|
214
|
+
typeof part.text === "string" &&
|
|
215
|
+
part.text.includes(document.markdown.trim()),
|
|
216
|
+
)
|
|
217
|
+
);
|
|
218
|
+
}
|
|
278
219
|
function documentationSource(input: unknown): string | undefined {
|
|
279
220
|
if (!isRecord(input) || typeof input.path !== "string" || !input.path.startsWith("docs:"))
|
|
280
221
|
return undefined;
|
|
281
222
|
return input.path;
|
|
282
223
|
}
|
|
283
224
|
|
|
284
|
-
function sourceInput(details: unknown): { readonly path: string } | undefined {
|
|
285
|
-
if (!isRecord(details) || typeof details.source !== "string") return undefined;
|
|
286
|
-
return { path: details.source };
|
|
287
|
-
}
|
|
288
|
-
|
|
289
225
|
function isRegistrationRequest(value: unknown): value is RegistrationRequest {
|
|
290
226
|
return isRecord(value) && Array.isArray(value.documents);
|
|
291
227
|
}
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
} from "pi-agent-text-editor/api/plugin-protocol";
|
|
16
16
|
|
|
17
17
|
import { createFilesystemReadResolver, createFilesystemWriteResolver } from "#src/resolver.js";
|
|
18
|
+
import { recoverFilesystemPath } from "#src/path-recovery.js";
|
|
18
19
|
|
|
19
20
|
const readTarget = { provider: "filesystem", capability: "read" } satisfies ContentTarget;
|
|
20
21
|
const writeTarget = { provider: "filesystem", capability: "write" } satisfies ContentTarget;
|
|
@@ -30,7 +31,11 @@ export default async function registerFilesystemPlugin(pi: ExtensionAPI): Promis
|
|
|
30
31
|
apiVersion: READ_API_VERSION,
|
|
31
32
|
id: "filesystem",
|
|
32
33
|
setup(api) {
|
|
33
|
-
api.addResolver({
|
|
34
|
+
api.addResolver({
|
|
35
|
+
resolver: readResolver,
|
|
36
|
+
renderResult: renderReadResult,
|
|
37
|
+
recoverFailure: recoverFilesystemPath,
|
|
38
|
+
});
|
|
34
39
|
api.describe(() =>
|
|
35
40
|
renderContentDescription(
|
|
36
41
|
"File path — file content; directory path — entry listing. Relative, absolute and file:// paths accepted.",
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-filesystem",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"pi-agent-image": "0.
|
|
10
|
-
"pi-agent-
|
|
11
|
-
"pi-agent-
|
|
12
|
-
"pi-agent-
|
|
13
|
-
"pi-agent-text
|
|
9
|
+
"pi-agent-image": "0.7.0",
|
|
10
|
+
"pi-agent-invariant": "0.7.0",
|
|
11
|
+
"pi-agent-read": "0.7.0",
|
|
12
|
+
"pi-agent-resource": "0.7.0",
|
|
13
|
+
"pi-agent-text": "0.7.0",
|
|
14
|
+
"pi-agent-text-editor": "0.7.0"
|
|
14
15
|
},
|
|
15
16
|
"pi": {
|
|
16
17
|
"extensions": [
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-filesystem-image",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#extension": "./index.ts"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"pi-agent-image": "0.
|
|
10
|
-
"pi-agent-resource": "0.
|
|
9
|
+
"pi-agent-image": "0.7.0",
|
|
10
|
+
"pi-agent-resource": "0.7.0"
|
|
11
11
|
},
|
|
12
12
|
"pi": {
|
|
13
13
|
"extensions": [
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-filesystem-jq",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"cross-spawn": "^7.0.6",
|
|
10
|
-
"pi-agent-doctor": "0.
|
|
11
|
-
"pi-agent-documentation": "0.
|
|
12
|
-
"pi-agent-read": "0.
|
|
13
|
-
"pi-agent-text": "0.
|
|
10
|
+
"pi-agent-doctor": "0.7.0",
|
|
11
|
+
"pi-agent-documentation": "0.7.0",
|
|
12
|
+
"pi-agent-read": "0.7.0",
|
|
13
|
+
"pi-agent-text": "0.7.0"
|
|
14
14
|
},
|
|
15
15
|
"pi": {
|
|
16
16
|
"extensions": [
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-filesystem-pdf",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"pi-agent-pdf": "0.
|
|
7
|
-
"pi-agent-resource": "0.
|
|
6
|
+
"pi-agent-pdf": "0.7.0",
|
|
7
|
+
"pi-agent-resource": "0.7.0"
|
|
8
8
|
},
|
|
9
9
|
"pi": {
|
|
10
10
|
"extensions": [
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-filesystem-text",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#extension": "./index.ts"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"pi-agent-resource": "0.
|
|
10
|
-
"pi-agent-text": "0.
|
|
9
|
+
"pi-agent-resource": "0.7.0",
|
|
10
|
+
"pi-agent-text": "0.7.0"
|
|
11
11
|
},
|
|
12
12
|
"pi": {
|
|
13
13
|
"extensions": [
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { realpath } from "node:fs/promises";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { requiredValue } from "pi-agent-invariant";
|
|
8
|
+
import type { ReadFailure } from "pi-agent-read/api/tools/read";
|
|
9
|
+
import type { ResourceResolverContext } from "pi-agent-resource";
|
|
10
|
+
|
|
11
|
+
/** Suggest exact workspace paths after a missing-file error; never open candidate content. */
|
|
12
|
+
export async function recoverFilesystemPath(
|
|
13
|
+
failure: ReadFailure,
|
|
14
|
+
context: ResourceResolverContext,
|
|
15
|
+
): Promise<ReadFailure["candidates"]> {
|
|
16
|
+
const cause = failure.cause;
|
|
17
|
+
const deadline = Date.now() + 500;
|
|
18
|
+
if (
|
|
19
|
+
context.signal?.aborted ||
|
|
20
|
+
failure.source === undefined ||
|
|
21
|
+
typeof cause !== "object" ||
|
|
22
|
+
cause === null ||
|
|
23
|
+
!("code" in cause) ||
|
|
24
|
+
cause.code !== "ENOENT"
|
|
25
|
+
)
|
|
26
|
+
return undefined;
|
|
27
|
+
const source = failure.source.startsWith("file://")
|
|
28
|
+
? fileURLToPath(failure.source)
|
|
29
|
+
: failure.source;
|
|
30
|
+
const relative = path.relative(context.cwd, path.resolve(context.cwd, source));
|
|
31
|
+
if (!insideWorkspace(relative) || relative.includes("#")) return undefined;
|
|
32
|
+
const name = path.basename(relative).toLowerCase();
|
|
33
|
+
if (name.length < 3 || name.length > 160) return undefined;
|
|
34
|
+
const bundled = path.join(
|
|
35
|
+
process.env.PI_CODING_AGENT_DIR ?? path.join(os.homedir(), ".pi", "agent"),
|
|
36
|
+
"bin",
|
|
37
|
+
process.platform === "win32" ? "rg.exe" : "rg",
|
|
38
|
+
);
|
|
39
|
+
const files = await new Promise<string[]>((resolve) => {
|
|
40
|
+
execFile(
|
|
41
|
+
existsSync(bundled) ? bundled : "rg",
|
|
42
|
+
["--files", "--hidden", "--no-config", "--no-ignore-parent", "--null", "--glob", "!.git/**"],
|
|
43
|
+
{
|
|
44
|
+
cwd: context.cwd,
|
|
45
|
+
timeout: 250,
|
|
46
|
+
maxBuffer: 2 * 1024 * 1024,
|
|
47
|
+
...(context.signal === undefined ? {} : { signal: context.signal }),
|
|
48
|
+
},
|
|
49
|
+
(error, stdout) => resolve(error ? [] : stdout.split("\0").filter(Boolean).slice(0, 20000)),
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
const maximumDistance = Math.min(3, Math.max(1, Math.floor(name.length * 0.2)));
|
|
53
|
+
const ranked = files
|
|
54
|
+
.flatMap((file) => {
|
|
55
|
+
if (context.signal?.aborted || Date.now() > deadline || !insideWorkspace(file)) return [];
|
|
56
|
+
const candidateName = path.basename(file).toLowerCase();
|
|
57
|
+
if (
|
|
58
|
+
candidateName.length > 160 ||
|
|
59
|
+
Math.abs(candidateName.length - name.length) > maximumDistance
|
|
60
|
+
)
|
|
61
|
+
return [];
|
|
62
|
+
const distance = editDistance(name, candidateName);
|
|
63
|
+
if (distance > maximumDistance) return [];
|
|
64
|
+
const directory = path.dirname(relative).toLowerCase();
|
|
65
|
+
const candidateDirectory = path.dirname(file).toLowerCase();
|
|
66
|
+
return [
|
|
67
|
+
{ path: file, distance, directoryDistance: directory === candidateDirectory ? 0 : 1 },
|
|
68
|
+
];
|
|
69
|
+
})
|
|
70
|
+
.sort(
|
|
71
|
+
(left, right) =>
|
|
72
|
+
left.distance - right.distance ||
|
|
73
|
+
left.directoryDistance - right.directoryDistance ||
|
|
74
|
+
left.path.localeCompare(right.path),
|
|
75
|
+
);
|
|
76
|
+
const candidates: { path: string }[] = [];
|
|
77
|
+
const root = await realpath(context.cwd);
|
|
78
|
+
for (const candidate of ranked.slice(0, 20)) {
|
|
79
|
+
if (context.signal?.aborted || Date.now() > deadline) return undefined;
|
|
80
|
+
try {
|
|
81
|
+
const target = await realpath(path.resolve(context.cwd, candidate.path));
|
|
82
|
+
if (insideWorkspace(path.relative(root, target))) candidates.push({ path: candidate.path });
|
|
83
|
+
} catch {
|
|
84
|
+
// Ignore files removed while searching.
|
|
85
|
+
}
|
|
86
|
+
if (candidates.length === 3) break;
|
|
87
|
+
}
|
|
88
|
+
return candidates.length ? candidates : undefined;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function insideWorkspace(relative: string): boolean {
|
|
92
|
+
return relative !== "" && !/^\.\.(?:[\\/]|$)/u.test(relative) && !path.isAbsolute(relative);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function editDistance(left: string, right: string): number {
|
|
96
|
+
let previous = Array.from({ length: right.length + 1 }, (_, index) => index);
|
|
97
|
+
for (let row = 1; row <= left.length; row++) {
|
|
98
|
+
const current = [row];
|
|
99
|
+
for (let column = 1; column <= right.length; column++) {
|
|
100
|
+
current[column] = Math.min(
|
|
101
|
+
requiredValue(current[column - 1]) + 1,
|
|
102
|
+
requiredValue(previous[column]) + 1,
|
|
103
|
+
requiredValue(previous[column - 1]) + (left[row - 1] === right[column - 1] ? 0 : 1),
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
previous = current;
|
|
107
|
+
}
|
|
108
|
+
return requiredValue(previous[right.length]);
|
|
109
|
+
}
|