pi-agent-ide 0.2.1 → 0.2.2
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 +31 -0
- package/dist/{chunk-XNXQYPVT.js → chunk-4LUW26BX.js} +1 -1
- package/dist/{chunk-2ZMYT6ZC.js → chunk-4U6KGABH.js} +1 -1
- package/dist/chunk-4ZTEPMJO.js +14 -0
- package/dist/{chunk-KNMWCDDK.js → chunk-6ACQQBUY.js} +1 -1
- package/dist/chunk-76WHES5H.js +7 -0
- package/dist/chunk-BHSO2MDK.js +6 -0
- package/dist/chunk-BMOJTJJJ.js +3 -0
- package/dist/chunk-GFWDXTOB.js +4 -0
- package/dist/{chunk-VSP2QQPQ.js → chunk-GIRAEVUJ.js} +1 -1
- package/dist/chunk-JJVXUL5U.js +2 -0
- package/dist/chunk-KCEOTU5Z.js +3 -0
- package/dist/chunk-KVGQG43U.js +1 -0
- package/dist/{chunk-MTTKFJV6.js → chunk-LQYZG62K.js} +1 -1
- package/dist/{chunk-PETQCA7G.js → chunk-P6T3Q7LB.js} +1 -1
- package/dist/chunk-QIJMV2P2.js +2 -0
- package/dist/chunk-QJFRAMK7.js +2 -0
- package/dist/{chunk-2SKAED2I.js → chunk-RAZOACDD.js} +2 -2
- package/dist/chunk-RIGRP3FD.js +1 -0
- package/dist/chunk-S3ZPXWX7.js +2 -0
- package/dist/{chunk-266RH77Z.js → chunk-THSCUT2L.js} +1 -1
- package/dist/{chunk-EEH4WYI7.js → chunk-WNMGUALD.js} +1 -1
- package/dist/{chunk-ZIHEF6K3.js → chunk-X6MPU7UO.js} +1 -1
- package/dist/{chunk-SMSIT3CE.js → chunk-XF5PVZOS.js} +1 -1
- package/dist/{chunk-SJYDLHEF.js → chunk-ZXN3TWWW.js} +1 -1
- package/dist/entry-0.js +1 -1
- package/dist/entry-10.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-21.js +2 -1
- package/dist/entry-22.js +1 -1
- package/dist/entry-23.js +1 -1
- package/dist/entry-24.js +1 -1
- package/dist/entry-25.js +1 -1
- package/dist/entry-26.js +7 -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 +4 -1
- package/dist/entry-32.js +8 -1
- package/dist/entry-33.js +1 -1
- package/dist/entry-35.js +1 -1
- package/dist/entry-37.js +1 -1
- package/dist/entry-39.js +1 -1
- package/dist/entry-4.js +1 -1
- package/dist/entry-40.js +14 -1
- package/dist/entry-41.js +1 -1
- package/dist/entry-45.js +7 -1
- package/dist/entry-46.js +11 -1
- package/dist/entry-47.js +1 -1
- package/dist/entry-48.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +1 -1
- package/dist/entry-51.js +1 -1
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-55.js +1 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-61.js +1 -1
- package/dist/entry-62.js +1 -1
- package/dist/entry-67.js +1 -1
- package/dist/entry-69.js +59 -1
- package/dist/entry-70.js +4 -1
- package/dist/entry-71.js +1 -1
- package/dist/entry-72.js +29 -1
- package/dist/entry-73.js +2 -1
- package/dist/entry-74.js +1 -1
- package/dist/entry-76.js +1 -1
- package/dist/entry-77.js +3 -1
- package/dist/entry-78.js +1 -1
- package/dist/entry-79.js +1 -1
- package/dist/entry-80.js +1 -1
- package/dist/pi-agent-ide.js +2 -13
- package/docs/configuration.md +25 -0
- package/docs/extensions.md +4 -2
- package/docs/tools.md +1 -1
- package/node_modules/pi-agent-doctor/package.json +1 -1
- package/node_modules/pi-agent-filesystem/index.ts +2 -2
- package/node_modules/pi-agent-filesystem/package.json +6 -6
- package/node_modules/pi-agent-filesystem-image/package.json +3 -3
- 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 +9 -9
- package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +89 -19
- package/node_modules/pi-agent-ide-ast/src/extension.ts +9 -14
- package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +60 -0
- package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
- package/node_modules/pi-agent-ide-changes/index.ts +1 -5
- package/node_modules/pi-agent-ide-changes/package.json +6 -6
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +1 -7
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +1 -5
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-formatter/src/formatter.ts +12 -7
- package/node_modules/pi-agent-ide-languages/package.json +2 -2
- package/node_modules/pi-agent-ide-lint/index.ts +4 -1
- package/node_modules/pi-agent-ide-lint/package.json +7 -7
- package/node_modules/pi-agent-ide-lsp/index.ts +1 -12
- package/node_modules/pi-agent-ide-lsp/package.json +8 -8
- package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +7 -4
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +8 -1
- package/node_modules/pi-agent-image/package.json +2 -2
- package/node_modules/pi-agent-image/src/image-converter.ts +1 -1
- 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-pdf/src/pdf-converter.ts +1 -1
- package/node_modules/pi-agent-read/package.json +6 -6
- package/node_modules/pi-agent-read/src/api/rendering.ts +3 -0
- package/node_modules/pi-agent-read/src/core/read-core.ts +6 -26
- package/node_modules/pi-agent-read/src/core/tools/read/native-resource-renderer.ts +74 -0
- package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +28 -7
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +35 -30
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/content-conversion/content-description.ts +1 -8
- package/node_modules/pi-agent-search/package.json +3 -3
- package/node_modules/pi-agent-search/src/core/extension.ts +7 -5
- package/node_modules/pi-agent-search/src/core/search-core.ts +10 -0
- package/node_modules/pi-agent-search-text/index.ts +42 -33
- package/node_modules/pi-agent-search-text/package.json +6 -6
- package/node_modules/pi-agent-search-text/src/file-search.ts +9 -1
- package/node_modules/pi-agent-search-text/src/resolvers.ts +1 -1
- package/node_modules/pi-agent-search-text/src/search-recipe.ts +2 -0
- package/node_modules/pi-agent-search-text/src/search-session.ts +48 -0
- package/node_modules/pi-agent-text/package.json +2 -2
- package/node_modules/pi-agent-text/src/text-converter.ts +1 -1
- package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-line-hash/index.ts +2 -6
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/node_modules/pi-agent-text-editor/package.json +6 -6
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +3 -0
- package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +71 -1
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +4 -12
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +7 -9
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +27 -2
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +38 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +81 -0
- package/node_modules/pi-agent-text-editor/src/core/text-anchor-registry.ts +5 -2
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +23 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +5 -9
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +54 -14
- package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +45 -43
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +18 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +7 -4
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +13 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +18 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -1
- package/node_modules/pi-agent-text-editor-argument-order/package.json +2 -2
- package/node_modules/pi-agent-text-editor-overwrite/package.json +3 -3
- package/node_modules/pi-agent-text-editor-renderer/index.ts +5 -1
- package/node_modules/pi-agent-text-editor-renderer/package.json +5 -5
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +7 -0
- package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +1 -1
- package/node_modules/pi-agent-text-editor-renderer/src/diff-viewport.ts +11 -2
- package/node_modules/pi-agent-text-editor-renderer/src/frozen-viewport.ts +140 -52
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +52 -4
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-result.ts +53 -1
- package/node_modules/pi-agent-text-editor-renderer/src/persisted-result.ts +8 -2
- package/node_modules/pi-agent-text-editor-renderer/src/render-resource.ts +10 -0
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +5 -3
- 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-call-interception/src/index.ts +3 -0
- package/node_modules/pi-agent-tool-ui/package.json +1 -1
- package/node_modules/pi-agent-web/index.ts +1 -6
- package/node_modules/pi-agent-web/package.json +6 -6
- package/node_modules/pi-agent-web-html/package.json +2 -2
- package/node_modules/pi-agent-web-html/src/html-converter.ts +1 -1
- 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 +35 -35
- package/src/api/plugin-protocol.ts +2 -0
- package/src/api/text-editor.ts +7 -0
- package/src/api/tool-config.ts +4 -0
- package/src/composite/builtin-extensions.ts +148 -66
- package/src/composite/extensions-config.ts +18 -0
- package/src/core/diagnostic-entry.ts +94 -0
- package/src/core/diagnostic-store.ts +43 -21
- package/src/core/extension.ts +39 -17
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +2 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +6 -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-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +1 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +6 -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-html/src/html-converter.ts +1 -1
- 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/package.json +6 -6
- package/src/extensions/pi-agent-read/src/api/rendering.ts +3 -0
- package/src/extensions/pi-agent-read/src/core/read-core.ts +6 -26
- package/src/extensions/pi-agent-read/src/core/tools/read/native-resource-renderer.ts +74 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +28 -7
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +35 -30
- package/src/extensions/pi-agent-search/package.json +3 -3
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +42 -33
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +6 -6
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +9 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +1 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +2 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +48 -0
- package/src/extensions/pi-agent-search/src/core/extension.ts +7 -5
- package/src/extensions/pi-agent-search/src/core/search-core.ts +10 -0
- package/src/extensions/pi-agent-text-editor/package.json +6 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +2 -6
- 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-argument-order/package.json +2 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +5 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +7 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +1 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-viewport.ts +11 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/frozen-viewport.ts +140 -52
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +52 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-result.ts +53 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/persisted-result.ts +8 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/render-resource.ts +10 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +5 -3
- 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-result.ts +3 -0
- package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +71 -1
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +4 -12
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +7 -9
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +27 -2
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +38 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +81 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-anchor-registry.ts +5 -2
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +23 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +5 -9
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +54 -14
- package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +45 -43
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +18 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +7 -4
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +13 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +18 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -1
- package/src/pi-agent-ide.ts +11 -0
- package/src/plugins/pi-agent-ide-ast/package.json +9 -9
- package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +89 -19
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +9 -14
- package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +60 -0
- package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
- package/src/plugins/pi-agent-ide-changes/index.ts +1 -5
- package/src/plugins/pi-agent-ide-changes/package.json +6 -6
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +1 -7
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +1 -5
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +1 -16
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +12 -7
- package/src/plugins/pi-agent-ide-languages/package.json +2 -2
- package/src/plugins/pi-agent-ide-lint/index.ts +4 -1
- package/src/plugins/pi-agent-ide-lint/package.json +7 -7
- package/src/plugins/pi-agent-ide-lsp/index.ts +1 -12
- package/src/plugins/pi-agent-ide-lsp/package.json +8 -8
- package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +7 -4
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +8 -1
- package/src/post-edit/gate.ts +44 -15
- package/src/toolchain/types.ts +2 -0
- package/dist/chunk-2XYXV5HS.js +0 -4
- package/dist/chunk-34ZQTTU2.js +0 -2
- package/dist/chunk-4SQQKEVD.js +0 -16
- package/dist/chunk-5BWUVAR4.js +0 -1
- package/dist/chunk-6DN7NO7L.js +0 -1
- package/dist/chunk-6SMFVLTY.js +0 -1
- package/dist/chunk-6XQQBKPE.js +0 -58
- package/dist/chunk-BYWAG6X3.js +0 -6
- package/dist/chunk-EW2KVKCN.js +0 -2
- package/dist/chunk-F6SESI3P.js +0 -4
- package/dist/chunk-GTK5AREE.js +0 -2
- package/dist/chunk-HOBTFFQR.js +0 -1
- package/dist/chunk-IMVCVPMP.js +0 -3
- package/dist/chunk-IOCABSRL.js +0 -1
- package/dist/chunk-KH5KPBCR.js +0 -10
- package/dist/chunk-KYVOMBO5.js +0 -1
- package/dist/chunk-L4FA6OD4.js +0 -1
- package/dist/chunk-LFV6G5Z3.js +0 -1
- package/dist/chunk-LGN7EJYR.js +0 -13
- package/dist/chunk-MB6VVVAF.js +0 -2
- package/dist/chunk-MTQSGWZJ.js +0 -1
- package/dist/chunk-NI2NK4JU.js +0 -1
- package/dist/chunk-NXHPO7ER.js +0 -6
- package/dist/chunk-OFHVDY4Q.js +0 -2
- package/dist/chunk-OIL6BB2S.js +0 -33
- package/dist/chunk-ONWUJXUR.js +0 -1
- package/dist/chunk-PODWLGNO.js +0 -6
- package/dist/chunk-QZANC2IG.js +0 -1
- package/dist/chunk-SSZB66C3.js +0 -3
- package/dist/chunk-TG6H6EOI.js +0 -1
- package/dist/chunk-UTTW55S2.js +0 -1
- package/dist/chunk-VEJGSURY.js +0 -8
- package/dist/chunk-W3XYKJ5H.js +0 -1
- package/dist/chunk-XGUAL3CA.js +0 -1
- package/node_modules/pi-agent-read/src/core/tools/read/views.ts +0 -29
- package/src/extensions/pi-agent-read/src/core/tools/read/views.ts +0 -29
|
@@ -4,7 +4,10 @@ import { type ChildProcess } from "node:child_process";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
|
|
6
6
|
import spawnProcess from "cross-spawn";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
configuredExecutableName,
|
|
9
|
+
createConfiguredProcessEnvironment,
|
|
10
|
+
} from "pi-agent-ide/api/tool-config";
|
|
8
11
|
import {
|
|
9
12
|
createMessageConnection,
|
|
10
13
|
CancellationTokenSource,
|
|
@@ -94,6 +97,10 @@ export class LspClient {
|
|
|
94
97
|
return this._process?.pid ?? null;
|
|
95
98
|
}
|
|
96
99
|
|
|
100
|
+
/** Executable used to start this server, independent of its configured ID. */
|
|
101
|
+
get commandName(): string {
|
|
102
|
+
return configuredExecutableName(this._command);
|
|
103
|
+
}
|
|
97
104
|
get diagnosticMode(): "unknown" | "pull" | "push" {
|
|
98
105
|
return this._diagnosticMode;
|
|
99
106
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-image",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./src/index.ts",
|
|
6
6
|
"exports": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"pi-agent-resource": "0.2.
|
|
13
|
+
"pi-agent-resource": "0.2.2"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"@earendil-works/pi-coding-agent": "*"
|
|
@@ -19,7 +19,7 @@ const pngSignature = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a] as const;
|
|
|
19
19
|
export function createImageContentConverter(): ContentConverter {
|
|
20
20
|
return {
|
|
21
21
|
id: "image",
|
|
22
|
-
description: "
|
|
22
|
+
description: "Image paths and URLs return image content.",
|
|
23
23
|
async tryConvert(input, context) {
|
|
24
24
|
const initialCancellation = cancellationError(context.signal);
|
|
25
25
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-pdf",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./src/index.ts",
|
|
6
6
|
"exports": {
|
|
@@ -11,6 +11,6 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"pdfjs-dist": "^6.2.108",
|
|
14
|
-
"pi-agent-resource": "0.2.
|
|
14
|
+
"pi-agent-resource": "0.2.2"
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -6,7 +6,7 @@ const maximumHeaderOffset = 1_024;
|
|
|
6
6
|
export function createPdfContentConverter(): ContentConverter {
|
|
7
7
|
return {
|
|
8
8
|
id: "pdf",
|
|
9
|
-
description: "PDF
|
|
9
|
+
description: "PDF paths and URLs return the document's readable content.",
|
|
10
10
|
async tryConvert(input, context) {
|
|
11
11
|
const cancellation = cancellationError(context.signal);
|
|
12
12
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-read",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"pi-agent-invariant": "0.2.
|
|
28
|
-
"pi-agent-resource": "0.2.
|
|
29
|
-
"pi-agent-text": "0.2.
|
|
30
|
-
"pi-agent-tool-call-interception": "0.2.
|
|
31
|
-
"pi-agent-tool-ui": "0.2.
|
|
27
|
+
"pi-agent-invariant": "0.2.2",
|
|
28
|
+
"pi-agent-resource": "0.2.2",
|
|
29
|
+
"pi-agent-text": "0.2.2",
|
|
30
|
+
"pi-agent-tool-call-interception": "0.2.2",
|
|
31
|
+
"pi-agent-tool-ui": "0.2.2"
|
|
32
32
|
},
|
|
33
33
|
"pi": {
|
|
34
34
|
"extensions": [
|
|
@@ -3,6 +3,9 @@ export type ReadPresentationKind = "code-view" | "markdown" | "source";
|
|
|
3
3
|
export interface ReadResultRendererOptions {
|
|
4
4
|
readonly kind: ReadPresentationKind;
|
|
5
5
|
readonly label?: string;
|
|
6
|
+
|
|
7
|
+
/** Opt local-file results into Pi's special skill, docs, and context-file presentation. */
|
|
8
|
+
readonly nativeResources?: boolean;
|
|
6
9
|
}
|
|
7
10
|
|
|
8
11
|
export { createReadResultRenderer } from "#src/core/tools/read/read-renderer.js";
|
|
@@ -50,7 +50,10 @@ export interface ReadCore {
|
|
|
50
50
|
export function createReadCore(): ReadCore {
|
|
51
51
|
const pendingPlugins = new Set<Promise<void>>();
|
|
52
52
|
const plugins = new Map<string, RegisteredPlugin>();
|
|
53
|
-
const read = createReadTool(
|
|
53
|
+
const read = createReadTool(
|
|
54
|
+
() => renderPromptGuidelines(plugins),
|
|
55
|
+
() => renderPluginPromptGuideline(plugins),
|
|
56
|
+
);
|
|
54
57
|
let registrationQueue = Promise.resolve();
|
|
55
58
|
|
|
56
59
|
return {
|
|
@@ -331,15 +334,13 @@ function renderPluginPromptGuideline(
|
|
|
331
334
|
const description = renderDescriptionSource(source);
|
|
332
335
|
|
|
333
336
|
if (description !== undefined) {
|
|
334
|
-
entries.push(
|
|
337
|
+
entries.push(description);
|
|
335
338
|
}
|
|
336
339
|
}
|
|
337
340
|
|
|
338
341
|
return entries.length === 0
|
|
339
342
|
? undefined
|
|
340
|
-
:
|
|
341
|
-
["Read supports these installed protocols:", ...entries].join("\n"),
|
|
342
|
-
);
|
|
343
|
+
: [...new Set(entries.flatMap((entry) => entry.split("\n")))].join("\n");
|
|
343
344
|
}
|
|
344
345
|
|
|
345
346
|
function normalizeDescriptionSource(value: unknown): PromptDescriptionSource {
|
|
@@ -390,24 +391,3 @@ function normalizeDescription(value: unknown): string {
|
|
|
390
391
|
|
|
391
392
|
return description;
|
|
392
393
|
}
|
|
393
|
-
|
|
394
|
-
function renderPromptEntry(pluginId: string, description: string): string {
|
|
395
|
-
const [firstLine, ...continuationLines] = description.split("\n");
|
|
396
|
-
|
|
397
|
-
return [
|
|
398
|
-
`- \`${escapeInlineCode(pluginId)}\` — ${firstLine ?? ""}`,
|
|
399
|
-
...continuationLines.map((line) => ` ${line}`),
|
|
400
|
-
].join("\n");
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
function indentGuidelineContinuation(guideline: string): string {
|
|
404
|
-
const [firstLine, ...continuationLines] = guideline.split("\n");
|
|
405
|
-
return [
|
|
406
|
-
firstLine ?? "",
|
|
407
|
-
...continuationLines.map((line) => (line.length === 0 ? line : ` ${line}`)),
|
|
408
|
-
].join("\n");
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
function escapeInlineCode(value: string): string {
|
|
412
|
-
return value.replaceAll("`", "\\`");
|
|
413
|
-
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import {
|
|
4
|
+
createReadToolDefinition,
|
|
5
|
+
getReadmePath,
|
|
6
|
+
type ToolDefinition,
|
|
7
|
+
} from "@earendil-works/pi-coding-agent";
|
|
8
|
+
import { Text } from "@earendil-works/pi-tui";
|
|
9
|
+
|
|
10
|
+
/** The native implementation owns labels, colors, key hints, and expanded text rendering. */
|
|
11
|
+
export const nativeReadPresentation = createReadToolDefinition(process.cwd());
|
|
12
|
+
|
|
13
|
+
/** Shared call/result context from Pi's public tool contract. */
|
|
14
|
+
export type ReadRenderContext = Parameters<NonNullable<ToolDefinition["renderCall"]>>[2];
|
|
15
|
+
type NativeArguments = Parameters<NonNullable<typeof nativeReadPresentation.renderCall>>[0];
|
|
16
|
+
|
|
17
|
+
const contextFiles = new Set([
|
|
18
|
+
"AGENTS.override.md",
|
|
19
|
+
"AGENTS.md",
|
|
20
|
+
"AGENTS.MD",
|
|
21
|
+
"CLAUDE.md",
|
|
22
|
+
"CLAUDE.MD",
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
/** Selects native special-file presentation only for native-compatible local read arguments. */
|
|
26
|
+
export function nativeReadArguments(
|
|
27
|
+
input: unknown,
|
|
28
|
+
cwd = process.cwd(),
|
|
29
|
+
): NativeArguments | undefined {
|
|
30
|
+
if (typeof input !== "object" || input === null) return undefined;
|
|
31
|
+
const args = input as { path?: unknown; offset?: unknown; limit?: unknown; views?: unknown };
|
|
32
|
+
const source = args.path;
|
|
33
|
+
if (typeof source !== "string" || source.length === 0 || source.includes("#")) return undefined;
|
|
34
|
+
if (!path.isAbsolute(source) && /^[a-z][a-z\d+.-]*:/iu.test(source)) return undefined;
|
|
35
|
+
if (args.views !== undefined && (!Array.isArray(args.views) || args.views.length > 0))
|
|
36
|
+
return undefined;
|
|
37
|
+
if (
|
|
38
|
+
args.offset !== undefined &&
|
|
39
|
+
(typeof args.offset !== "number" || !Number.isInteger(args.offset) || args.offset < 1)
|
|
40
|
+
)
|
|
41
|
+
return undefined;
|
|
42
|
+
if (
|
|
43
|
+
args.limit !== undefined &&
|
|
44
|
+
(typeof args.limit !== "number" || !Number.isInteger(args.limit) || args.limit < 1)
|
|
45
|
+
)
|
|
46
|
+
return undefined;
|
|
47
|
+
const expanded = source.startsWith("~/") ? path.join(homedir(), source.slice(2)) : source;
|
|
48
|
+
const absolute = path.resolve(cwd, expanded);
|
|
49
|
+
const name = path.basename(absolute);
|
|
50
|
+
const relative = path.relative(path.dirname(getReadmePath()), absolute);
|
|
51
|
+
const docs =
|
|
52
|
+
!path.isAbsolute(relative) &&
|
|
53
|
+
(relative === "README.md" ||
|
|
54
|
+
relative.startsWith(`docs${path.sep}`) ||
|
|
55
|
+
relative.startsWith(`examples${path.sep}`));
|
|
56
|
+
if (name !== "SKILL.md" && !contextFiles.has(name) && !docs) return undefined;
|
|
57
|
+
return {
|
|
58
|
+
path: source,
|
|
59
|
+
...(args.offset === undefined ? {} : { offset: args.offset }),
|
|
60
|
+
...(args.limit === undefined ? {} : { limit: args.limit }),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Native renderers reuse Text only; a previous IDE card is a different component type. */
|
|
65
|
+
export function nativeReadContext(
|
|
66
|
+
context: ReadRenderContext,
|
|
67
|
+
args: NativeArguments,
|
|
68
|
+
): Parameters<NonNullable<typeof nativeReadPresentation.renderCall>>[2] {
|
|
69
|
+
return {
|
|
70
|
+
...context,
|
|
71
|
+
args,
|
|
72
|
+
lastComponent: context.lastComponent instanceof Text ? context.lastComponent : undefined,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { restoreReadDetails } from "./persisted-result.js";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
nativeReadArguments,
|
|
5
|
+
nativeReadContext,
|
|
6
|
+
nativeReadPresentation,
|
|
7
|
+
type ReadRenderContext,
|
|
8
|
+
} from "./native-resource-renderer.js";
|
|
2
9
|
import { requiredValue } from "pi-agent-invariant";
|
|
3
10
|
import {
|
|
4
11
|
type AgentToolResult,
|
|
@@ -32,17 +39,20 @@ interface ReadCallArguments {
|
|
|
32
39
|
readonly views?: unknown;
|
|
33
40
|
}
|
|
34
41
|
|
|
35
|
-
interface ReadCallRenderContext {
|
|
36
|
-
readonly expanded?: boolean;
|
|
37
|
-
readonly lastComponent: Component | undefined;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
42
|
/** Renders the requested read source and non-default options in the shared tool-card header. */
|
|
41
43
|
export function renderReadCall(
|
|
42
44
|
arguments_: ReadCallArguments,
|
|
43
45
|
theme: Theme,
|
|
44
|
-
context:
|
|
46
|
+
context: ReadRenderContext,
|
|
45
47
|
): Component {
|
|
48
|
+
const nativeArgs = nativeReadArguments(arguments_, context.cwd);
|
|
49
|
+
if (nativeArgs !== undefined) {
|
|
50
|
+
return requiredValue(nativeReadPresentation.renderCall)(
|
|
51
|
+
nativeArgs,
|
|
52
|
+
theme,
|
|
53
|
+
nativeReadContext(context, nativeArgs),
|
|
54
|
+
);
|
|
55
|
+
}
|
|
46
56
|
const path = typeof arguments_.path === "string" ? arguments_.path : "inherited source";
|
|
47
57
|
const offset = typeof arguments_.offset === "number" ? arguments_.offset : undefined;
|
|
48
58
|
const limit = typeof arguments_.limit === "number" ? arguments_.limit : undefined;
|
|
@@ -78,7 +88,7 @@ export function renderReadCall(
|
|
|
78
88
|
},
|
|
79
89
|
qualifiers,
|
|
80
90
|
details,
|
|
81
|
-
expanded: context.expanded
|
|
91
|
+
expanded: context.expanded,
|
|
82
92
|
},
|
|
83
93
|
theme,
|
|
84
94
|
);
|
|
@@ -95,6 +105,17 @@ interface ReadPanelState {
|
|
|
95
105
|
export function createReadResultRenderer(options: ReadResultRendererOptions): ReadResultRenderer {
|
|
96
106
|
const restored = new WeakMap<object, ReadResultDetails>();
|
|
97
107
|
return (result, renderOptions, theme, context): Component => {
|
|
108
|
+
const nativeArgs = options.nativeResources
|
|
109
|
+
? nativeReadArguments(context.args, context.cwd)
|
|
110
|
+
: undefined;
|
|
111
|
+
if (nativeArgs !== undefined && !renderOptions.isPartial) {
|
|
112
|
+
return requiredValue(nativeReadPresentation.renderResult)(
|
|
113
|
+
{ ...result, details: { truncation: readDetails(result.details).truncation } },
|
|
114
|
+
renderOptions,
|
|
115
|
+
theme,
|
|
116
|
+
nativeReadContext(context, nativeArgs),
|
|
117
|
+
);
|
|
118
|
+
}
|
|
98
119
|
if (renderOptions.isPartial || context.isError) {
|
|
99
120
|
const text = textBlocks(result);
|
|
100
121
|
const color = context.isError ? "error" : "dim";
|
|
@@ -46,7 +46,6 @@ import {
|
|
|
46
46
|
READ_OUTPUT_MAX_LINES,
|
|
47
47
|
} from "#src/core/tools/read/output-truncation.js";
|
|
48
48
|
import { createReadResultRenderer, renderReadCall } from "#src/core/tools/read/read-renderer.js";
|
|
49
|
-
import { createLineNumberPresenter } from "#src/core/tools/read/views.js";
|
|
50
49
|
import {
|
|
51
50
|
createReadState,
|
|
52
51
|
failureResult,
|
|
@@ -58,12 +57,27 @@ const readParameters = Type.Object({
|
|
|
58
57
|
path: Type.Optional(
|
|
59
58
|
Type.String({
|
|
60
59
|
description:
|
|
61
|
-
"
|
|
60
|
+
"What to read: a file or directory path, URL, returned temp: or SEARCH# reference, or one of the source forms listed in the description. Supply a path; an empty call cannot select a source.",
|
|
61
|
+
}),
|
|
62
|
+
),
|
|
63
|
+
offset: Type.Optional(
|
|
64
|
+
Type.Number({
|
|
65
|
+
description:
|
|
66
|
+
"First line to return, numbered from 1. Omit or use 0 to start at line 1; -1 starts at the last line, -10 at the tenth line from the end. For path#anchor or a SEARCH selection, count from its containing line instead: 0 or 1 starts there, 2 starts one line later, -1 one line earlier.",
|
|
67
|
+
}),
|
|
68
|
+
),
|
|
69
|
+
limit: Type.Optional(
|
|
70
|
+
Type.Number({
|
|
71
|
+
description:
|
|
72
|
+
"Maximum lines to read from the selected starting position, subject to the output budget. Omit for the default bounded read.",
|
|
73
|
+
}),
|
|
74
|
+
),
|
|
75
|
+
views: Type.Optional(
|
|
76
|
+
Type.Array(Type.String(), {
|
|
77
|
+
description:
|
|
78
|
+
'Optional additions to the returned text. Use the views listed in the tool description. Combine views when needed, for example ["anchors", "ast"] for source text with editable line references and scope boundaries. Omit for the source\'s default presentation.',
|
|
62
79
|
}),
|
|
63
80
|
),
|
|
64
|
-
offset: Type.Optional(Type.Number()),
|
|
65
|
-
limit: Type.Optional(Type.Number()),
|
|
66
|
-
views: Type.Optional(Type.Array(Type.String())),
|
|
67
81
|
});
|
|
68
82
|
|
|
69
83
|
const fallbackReadRenderer = createReadResultRenderer({ kind: "source" });
|
|
@@ -98,13 +112,6 @@ interface ViewContribution {
|
|
|
98
112
|
readonly document: TextDocument;
|
|
99
113
|
}
|
|
100
114
|
|
|
101
|
-
/** Built-in view names that exist without any plugin registration. */
|
|
102
|
-
const BUILTIN_VIEWS = ["lines"] as const;
|
|
103
|
-
|
|
104
|
-
function createBuiltinViewRegistrations(): ReadViewRegistration[] {
|
|
105
|
-
return [{ view: "lines", presenter: createLineNumberPresenter() }];
|
|
106
|
-
}
|
|
107
|
-
|
|
108
115
|
export interface ReadToolContributions {
|
|
109
116
|
readonly resolvers?: readonly ResourceResolverRegistration[];
|
|
110
117
|
readonly targetResolvers?: readonly TextTargetResolverRegistration[];
|
|
@@ -123,7 +130,11 @@ export interface ReadTool {
|
|
|
123
130
|
dispose(): Promise<void>;
|
|
124
131
|
}
|
|
125
132
|
|
|
126
|
-
|
|
133
|
+
/** Creates a read pipeline whose prompt contributions reflect the currently installed plugins. */
|
|
134
|
+
export function createReadTool(
|
|
135
|
+
pluginPromptGuidelines?: () => readonly string[],
|
|
136
|
+
pluginDescription?: () => string | undefined,
|
|
137
|
+
): ReadTool {
|
|
127
138
|
const temporaryResources = new TempResourceStore();
|
|
128
139
|
const resolvers: RegisteredResolver[] = [
|
|
129
140
|
{
|
|
@@ -134,11 +145,7 @@ export function createReadTool(pluginPromptGuidelines?: () => readonly string[])
|
|
|
134
145
|
},
|
|
135
146
|
];
|
|
136
147
|
const handlers: RegisteredHandler[] = [];
|
|
137
|
-
const views: RegisteredView[] =
|
|
138
|
-
pluginId: "core",
|
|
139
|
-
registration,
|
|
140
|
-
order,
|
|
141
|
-
}));
|
|
148
|
+
const views: RegisteredView[] = [];
|
|
142
149
|
const fragments: RegisteredFragment[] = [];
|
|
143
150
|
const targetResolvers: {
|
|
144
151
|
readonly resolver: TextTargetResolver;
|
|
@@ -154,16 +161,17 @@ export function createReadTool(pluginPromptGuidelines?: () => readonly string[])
|
|
|
154
161
|
|
|
155
162
|
promptSnippet:
|
|
156
163
|
"Read files, URLs, temporary resources, search selections, and protocol sources, with optional views projected onto text content",
|
|
157
|
-
description
|
|
158
|
-
|
|
159
|
-
|
|
164
|
+
get description(): string {
|
|
165
|
+
return [
|
|
166
|
+
`Use read to inspect files, directories, URLs and supported sources without changing them. path selects the source; offset/limit select a text window; views add annotations. Text limit: ${READ_OUTPUT_MAX_LINES} lines or ${READ_OUTPUT_MAX_BYTES / 1024}KB. Continuation: returned offset, or returned temp: reference as path.`,
|
|
167
|
+
pluginDescription?.() ?? "",
|
|
168
|
+
]
|
|
169
|
+
.filter(Boolean)
|
|
170
|
+
.join("\n");
|
|
171
|
+
},
|
|
160
172
|
get promptGuidelines(): string[] {
|
|
161
173
|
return [
|
|
162
|
-
"Use read to examine
|
|
163
|
-
'You can use read with `views: ["lines"]` to add a line-number column.',
|
|
164
|
-
"You can use read with `offset` and `limit` to inspect a line range or continue a large source, and with a negative `offset` to read from the end.",
|
|
165
|
-
"You can combine compatible read views in one request.",
|
|
166
|
-
"When a read result is truncated and provides a `temp:` source, you can use read with that source to continue reading the saved full output.",
|
|
174
|
+
"Use read to examine supported sources instead of cat, sed, head or tail. Use search to locate workspace text and paths instead of grep, rg or find.",
|
|
167
175
|
...(pluginPromptGuidelines?.() ?? []),
|
|
168
176
|
];
|
|
169
177
|
},
|
|
@@ -318,10 +326,7 @@ async function executeRead(
|
|
|
318
326
|
(left, right) => left.priority - right.priority || left.order - right.order,
|
|
319
327
|
);
|
|
320
328
|
const requestedViews = new Set(request.views ?? []);
|
|
321
|
-
const knownViews = new Set([
|
|
322
|
-
...BUILTIN_VIEWS,
|
|
323
|
-
...viewSnapshot.map(({ registration }) => registration.view),
|
|
324
|
-
]);
|
|
329
|
+
const knownViews = new Set([...viewSnapshot.map(({ registration }) => registration.view)]);
|
|
325
330
|
const ignoredViews = [...requestedViews].filter((view) => !knownViews.has(view));
|
|
326
331
|
if (request.path !== undefined && targetSnapshot.length > 0) {
|
|
327
332
|
const targeted = await resolveTextTargets(
|
|
@@ -14,12 +14,5 @@ export function renderContentDescription(
|
|
|
14
14
|
throw new TypeError("Content provider summary must be one non-empty line");
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
return [
|
|
18
|
-
normalizedSummary,
|
|
19
|
-
...descriptions.map(({ id, description }) => `- \`${escapeInlineCode(id)}\` — ${description}`),
|
|
20
|
-
].join("\n");
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function escapeInlineCode(value: string): string {
|
|
24
|
-
return value.replaceAll("`", "\\`");
|
|
17
|
+
return [normalizedSummary, ...descriptions.map(({ description }) => description)].join("\n");
|
|
25
18
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-search",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"pi-agent-tool-call-interception": "0.2.
|
|
24
|
-
"pi-agent-tool-ui": "0.2.
|
|
23
|
+
"pi-agent-tool-call-interception": "0.2.2",
|
|
24
|
+
"pi-agent-tool-ui": "0.2.2"
|
|
25
25
|
},
|
|
26
26
|
"pi": {
|
|
27
27
|
"extensions": [
|
|
@@ -38,7 +38,7 @@ const searchSchema = Type.Object(
|
|
|
38
38
|
query: Type.String({
|
|
39
39
|
minLength: 1,
|
|
40
40
|
description:
|
|
41
|
-
"
|
|
41
|
+
"Text to find, a Boolean expression, or a prefixed query described below, such as files:*.ts. Quote text to keep it literal, or use regex:<pattern> for regular-expression matching.",
|
|
42
42
|
}),
|
|
43
43
|
path: Type.Optional(
|
|
44
44
|
Type.String({ description: "Optional file or directory scope for local search" }),
|
|
@@ -110,15 +110,17 @@ export default async function registerSearchCore(pi: ExtensionAPI): Promise<void
|
|
|
110
110
|
{
|
|
111
111
|
name: "search",
|
|
112
112
|
label: "search",
|
|
113
|
-
description:
|
|
114
|
-
|
|
113
|
+
get description(): string {
|
|
114
|
+
return [
|
|
115
|
+
"Use search to locate text, file paths and code structures in the workspace.",
|
|
116
|
+
...core.renderDescriptions(),
|
|
117
|
+
].join("\n");
|
|
118
|
+
},
|
|
115
119
|
promptSnippet:
|
|
116
120
|
"Search files and text with literals or regular expressions, plus syntax trees and language symbols",
|
|
117
121
|
get promptGuidelines(): string[] {
|
|
118
122
|
return [
|
|
119
|
-
"Use search instead of grep, rg, or find to search workspace text and paths.",
|
|
120
123
|
"Use the narrowest useful search query and scope; broaden when needed.",
|
|
121
|
-
"Do not use search merely to rediscover a file path already named in the request; use that path directly. Search within it only when you need to locate content.",
|
|
122
124
|
...core.renderPromptGuidelines(),
|
|
123
125
|
];
|
|
124
126
|
},
|
|
@@ -34,6 +34,8 @@ export interface SearchCore {
|
|
|
34
34
|
context: SearchContext,
|
|
35
35
|
): Promise<unknown>;
|
|
36
36
|
renderPromptGuidelines(): readonly string[];
|
|
37
|
+
/** Describes capabilities contributed by successfully registered plugins. */
|
|
38
|
+
renderDescriptions(): readonly string[];
|
|
37
39
|
renderer(resolverId: string): SearchResolverRegistration["resolver"]["renderResult"];
|
|
38
40
|
}
|
|
39
41
|
|
|
@@ -41,6 +43,7 @@ export function createSearchCore(): SearchCore {
|
|
|
41
43
|
const resolvers: RegisteredResolver[] = [];
|
|
42
44
|
const actions = new Map<string, SearchActionRegistration>();
|
|
43
45
|
const promptGuidelines = new Map<string, SearchDescriptionSource[]>();
|
|
46
|
+
const descriptions = new Map<string, SearchDescriptionSource>();
|
|
44
47
|
const plugins = new Map<string, Promise<void>>();
|
|
45
48
|
let queue = Promise.resolve();
|
|
46
49
|
|
|
@@ -125,6 +128,7 @@ export function createSearchCore(): SearchCore {
|
|
|
125
128
|
actions.set(actionKey(action.resolverId, action.capability), action);
|
|
126
129
|
}
|
|
127
130
|
|
|
131
|
+
if (draftDescription !== undefined) descriptions.set(plugin.id, draftDescription);
|
|
128
132
|
if (draftPromptGuidelines.length > 0) {
|
|
129
133
|
promptGuidelines.set(plugin.id, draftPromptGuidelines);
|
|
130
134
|
}
|
|
@@ -243,6 +247,12 @@ export function createSearchCore(): SearchCore {
|
|
|
243
247
|
|
|
244
248
|
return action.execute(reference, input, context);
|
|
245
249
|
},
|
|
250
|
+
renderDescriptions(): readonly string[] {
|
|
251
|
+
return [...descriptions.values()].flatMap((source) => {
|
|
252
|
+
const description = renderDescription(source);
|
|
253
|
+
return description === undefined ? [] : [description];
|
|
254
|
+
});
|
|
255
|
+
},
|
|
246
256
|
renderPromptGuidelines(): readonly string[] {
|
|
247
257
|
return [...promptGuidelines.values()].flat().flatMap((source) => {
|
|
248
258
|
const guideline = renderDescription(source);
|
|
@@ -20,6 +20,44 @@ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
|
20
20
|
export default async function registerTextSearch(pi: ExtensionAPI): Promise<void> {
|
|
21
21
|
const sessions = new SearchSessionStore();
|
|
22
22
|
|
|
23
|
+
pi.on("tool_result", async (event, ctx) => {
|
|
24
|
+
if (
|
|
25
|
+
event.toolName !== "replace" ||
|
|
26
|
+
event.isError ||
|
|
27
|
+
typeof event.details !== "object" ||
|
|
28
|
+
event.details === null
|
|
29
|
+
)
|
|
30
|
+
return;
|
|
31
|
+
const observations = await sessions.observeAfterEdit(
|
|
32
|
+
[event.input.path, event.input.start, event.input.end],
|
|
33
|
+
ctx.signal,
|
|
34
|
+
);
|
|
35
|
+
if (observations.length === 0) return;
|
|
36
|
+
return {
|
|
37
|
+
content: [
|
|
38
|
+
...event.content,
|
|
39
|
+
{
|
|
40
|
+
type: "text" as const,
|
|
41
|
+
text: [
|
|
42
|
+
"Original search observed after editing (not task validation):",
|
|
43
|
+
...observations.map((observation) => {
|
|
44
|
+
const { query: _compiledQuery, fallbacks: _fallbacks, ...scope } = observation.scope;
|
|
45
|
+
return [
|
|
46
|
+
`SEARCH#${observation.sessionId}: ${JSON.stringify(observation.query)}`,
|
|
47
|
+
`Scope and options: ${JSON.stringify(scope)}`,
|
|
48
|
+
observation.error === undefined
|
|
49
|
+
? `Matches: ${observation.matches}${observation.complete === true ? "; complete search." : "+; incomplete search, lower bound only."}`
|
|
50
|
+
: `Search failed: ${observation.error}. Applied edits remain applied.`,
|
|
51
|
+
...(observation.notices ?? []),
|
|
52
|
+
].join("\n");
|
|
53
|
+
}),
|
|
54
|
+
].join("\n"),
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
details: { ...event.details, searchObservations: observations },
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
|
|
23
61
|
pi.on("tool_result", (event) => {
|
|
24
62
|
if (event.toolName !== "search" || typeof event.details !== "object" || event.details === null)
|
|
25
63
|
return;
|
|
@@ -47,41 +85,12 @@ export default async function registerTextSearch(pi: ExtensionAPI): Promise<void
|
|
|
47
85
|
api.addResolver({ resolver: createTextResolver(sessions), fallback: true });
|
|
48
86
|
api.describe(
|
|
49
87
|
[
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
api.addPromptGuideline(
|
|
57
|
-
"Local search tries literal terms first, then unquoted terms as regex if no matches exist, then separate words for ordinary multi-word queries. Search reports each fallback; invalid optional regex is skipped. Quoted and Boolean queries never fall back to separate words.",
|
|
58
|
-
);
|
|
59
|
-
api.addPromptGuideline(
|
|
60
|
-
'You can combine search terms with uppercase `AND`/`OR`, infix `NOT`, `||`, or space-separated `|`. Parentheses containing Boolean operators group conditions. Regex groups, classes, and escapes stay inside terms: `(?:foo|bar)\\d+ AND "keep.me" NOT ignored`. Quoted terms stay literal, including during regex fallback; `foo|bar` first searches that exact text, then regex alternatives.',
|
|
61
|
-
);
|
|
62
|
-
api.addPromptGuideline(
|
|
63
|
-
"You can use `regex:<pattern>` to force regex-only search and `files:<pattern>` for file paths. Empty or unhandled protocol queries fall back to searching the original text, including the prefix. Resolver errors, timeouts, and successful empty protocol results do not trigger text fallback.",
|
|
64
|
-
);
|
|
65
|
-
api.addPromptGuideline(
|
|
66
|
-
"You can narrow local search with `path`, `include`, `exclude`, `caseSensitive`, `wholeWord`, and `limit`.",
|
|
67
|
-
);
|
|
68
|
-
api.addPromptGuideline(
|
|
69
|
-
[
|
|
70
|
-
"You can reuse complete text and regex search results through these `SEARCH#...` values:",
|
|
71
|
-
" - `SEARCH#HASH:N:line` selects one result's full line.",
|
|
72
|
-
" - `SEARCH#HASH:N:match` selects one exact match.",
|
|
73
|
-
" - `SEARCH#HASH:all:line` selects every unique containing line.",
|
|
74
|
-
" - `SEARCH#HASH:all:match` selects every exact match.",
|
|
75
|
-
" Read shows the containing lines for both modes; `:line` and `:match` control the edit range, not partial-line read rendering.",
|
|
76
|
-
" Limited or incomplete searches omit the `all` values.",
|
|
88
|
+
"Local queries try literal terms first, then unquoted terms as regex when no literal results exist, then separate words for ordinary multi-word queries. Quoted terms stay literal. Boolean conditions stay intact across fallback. Uppercase AND/OR, infix NOT, ||, and space-separated | are Boolean operators; unspaced | and regex groups/classes belong to regex terms. Parentheses containing Boolean operators group Boolean conditions. regex:<pattern> forces regex-only matching; files:<pattern> searches file paths: glob patterns use *, **, ?, character classes and braces; other queries use case-insensitive subsequence matching. Slash-containing globs match cwd-relative paths; basename globs match at any depth.",
|
|
89
|
+
"The result says when a query was broadened. Empty or unknown prefixes are searched as plain text. A recognized prefixed query returns its own results or error; it does not silently become a text search.",
|
|
90
|
+
"SEARCH#HASH:N:line selects one containing line; :match selects its exact match. :all:line selects all unique containing lines and :all:match selects all matches. Read returns containing lines for both forms. A SEARCH resource can be used as a read path or mutation path/anchor; omit the file path for an all-selection spanning files.",
|
|
91
|
+
"Use SEARCH references exactly as returned to select the matching content. A single-result reference becomes stale when its file changes; obtain a fresh result before using it again. An :all reference refreshes the original query when a selected file changes. Limited or incomplete searches do not provide :all selections.",
|
|
77
92
|
].join("\n"),
|
|
78
93
|
);
|
|
79
|
-
api.addPromptGuideline(
|
|
80
|
-
"You can pass a returned `SEARCH#...` value directly to read or a compatible mutation tool as its path or anchor. Omit the file path when an `all` value spans files.",
|
|
81
|
-
);
|
|
82
|
-
api.addPromptGuideline(
|
|
83
|
-
"You can replace every exact search match by passing `SEARCH#HASH:all:match` as the replace path, or replace whole matched lines with `SEARCH#HASH:all:line`.",
|
|
84
|
-
);
|
|
85
94
|
},
|
|
86
95
|
}),
|
|
87
96
|
connectTextEditorPlugin(pi, {
|