pi-agent-ide 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/README.md +79 -53
- package/assets/social-preview.png +0 -0
- package/dist/chunk-4KUFOHWP.js +2 -0
- package/dist/chunk-4LDOV7QS.js +28 -0
- package/dist/chunk-FA6BKC5Y.js +1 -0
- package/dist/{chunk-HSM6R7IB.js → chunk-I6Y3W4X6.js} +13 -13
- package/dist/chunk-MPT3R4BL.js +0 -0
- package/dist/chunk-PZFOOHY2.js +15 -0
- package/dist/{chunk-OYWIZII6.js → chunk-S6QRG3TQ.js} +1 -1
- package/dist/chunk-T7I2VX3J.js +1 -0
- package/dist/chunk-VCTK4JSN.js +3 -0
- package/dist/chunk-W7CASEO3.js +1 -0
- package/dist/chunk-YEQOQMU7.js +5 -0
- package/dist/chunk-YT42LKFV.js +16 -0
- package/dist/entry-10.js +1 -1
- package/dist/entry-11.js +1 -1
- package/dist/entry-12.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 -0
- package/dist/entry-19.js +1 -1
- package/dist/entry-20.js +1 -1
- package/dist/entry-21.js +1 -1
- package/dist/entry-22.js +1 -1
- package/dist/entry-23.js +1 -2
- package/dist/entry-24.js +1 -1
- package/dist/entry-25.js +2 -1
- package/dist/entry-26.js +1 -1
- package/dist/entry-27.js +2 -1
- package/dist/entry-28.js +1 -12
- package/dist/entry-29.js +1 -1
- package/dist/entry-30.js +1 -1
- package/dist/entry-31.js +12 -1
- package/dist/entry-32.js +1 -1
- package/dist/entry-33.js +1 -4
- package/dist/entry-34.js +1 -9
- package/dist/entry-35.js +1 -1
- package/dist/entry-36.js +4 -1
- package/dist/entry-37.js +9 -1
- package/dist/entry-38.js +1 -1
- package/dist/entry-39.js +1 -1
- package/dist/entry-40.js +1 -1
- package/dist/entry-41.js +1 -1
- package/dist/entry-42.js +1 -18
- package/dist/entry-43.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +17 -1
- package/dist/entry-46.js +1 -1
- package/dist/entry-47.js +1 -7
- package/dist/entry-48.js +1 -11
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +6 -1
- package/dist/entry-51.js +11 -1
- 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 -0
- package/dist/entry-58.js +1 -1
- package/dist/entry-59.js +1 -0
- package/dist/entry-60.js +0 -1
- package/dist/entry-61.js +1 -1
- package/dist/entry-62.js +0 -1
- package/dist/entry-63.js +1 -1
- package/dist/entry-64.js +1 -1
- package/dist/entry-65.js +1 -1
- package/dist/entry-66.js +1 -0
- package/dist/entry-67.js +1 -1
- package/dist/entry-68.js +1 -0
- package/dist/entry-69.js +0 -1
- package/dist/entry-70.js +1 -1
- package/dist/entry-71.js +0 -1
- package/dist/entry-72.js +1 -259
- package/dist/entry-73.js +1 -30
- package/dist/entry-74.js +1 -2
- package/dist/entry-75.js +315 -1
- package/dist/entry-76.js +30 -1
- package/dist/entry-77.js +2 -3
- package/dist/entry-78.js +1 -3
- package/dist/entry-79.js +1 -1
- package/dist/entry-80.js +3 -1
- package/dist/entry-81.js +3 -1
- package/dist/entry-82.js +1 -0
- package/dist/entry-83.js +1 -0
- package/dist/entry-84.js +1 -0
- package/dist/entry-9.js +1 -1
- package/dist/pi-agent-ide.js +3 -3
- package/docs/agent-guides/apply.md +333 -0
- package/docs/agent-guides/debugger.md +5 -0
- package/docs/agent-guides/diagnostics.md +5 -0
- package/docs/agent-guides/editing.md +44 -0
- package/docs/agent-guides/git-changes.md +5 -0
- package/docs/agent-guides/json-reading.md +41 -0
- package/docs/agent-guides/read-resources.md +44 -0
- package/docs/agent-guides/search-code.md +29 -0
- package/docs/agent-guides/terminal.md +7 -0
- package/docs/agent-guides/vision.md +5 -0
- package/docs/configuration.md +6 -14
- package/docs/research/apply-read-latency.md +219 -0
- package/node_modules/pi-agent-doctor/package.json +6 -6
- package/node_modules/pi-agent-doctor/runtime/entry-23.js +1 -0
- package/node_modules/pi-agent-documentation/package.json +15 -0
- package/node_modules/pi-agent-documentation/runtime/entry-24.js +1 -0
- package/node_modules/pi-agent-documentation/src/index.ts +69 -0
- package/node_modules/pi-agent-filesystem/index.ts +0 -4
- package/node_modules/pi-agent-filesystem/package.json +7 -7
- package/node_modules/pi-agent-filesystem-image/package.json +4 -4
- package/node_modules/pi-agent-filesystem-jq/index.ts +134 -0
- package/node_modules/pi-agent-filesystem-jq/package.json +23 -0
- package/node_modules/pi-agent-filesystem-jq/runtime/entry-27.js +2 -0
- package/node_modules/pi-agent-filesystem-jq/src/jq.ts +107 -0
- package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
- package/node_modules/pi-agent-filesystem-text/package.json +4 -4
- package/node_modules/pi-agent-filesystem-text/runtime/entry-29.js +2 -0
- package/node_modules/pi-agent-ide-ast/package.json +11 -11
- package/node_modules/pi-agent-ide-ast/runtime/entry-30.js +1 -0
- package/node_modules/pi-agent-ide-changes/index.ts +8 -0
- package/node_modules/pi-agent-ide-changes/package.json +9 -8
- package/node_modules/pi-agent-ide-changes/runtime/entry-32.js +1 -0
- package/node_modules/pi-agent-ide-formatter/package.json +4 -4
- package/node_modules/pi-agent-ide-formatter/src/formatter.ts +1 -1
- package/node_modules/pi-agent-ide-languages/package.json +3 -3
- package/node_modules/pi-agent-ide-languages/runtime/entry-35.js +2 -0
- package/node_modules/pi-agent-ide-lint/index.ts +1 -1
- package/node_modules/pi-agent-ide-lint/package.json +8 -8
- package/node_modules/pi-agent-ide-lint/runtime/entry-36.js +2 -0
- package/node_modules/pi-agent-ide-lint/src/command-linter.ts +17 -1
- package/node_modules/pi-agent-ide-lsp/index.ts +0 -3
- package/node_modules/pi-agent-ide-lsp/package.json +10 -10
- package/node_modules/pi-agent-ide-lsp/runtime/entry-37.js +2 -0
- package/node_modules/pi-agent-image/package.json +3 -3
- package/node_modules/pi-agent-invariant/package.json +2 -2
- package/node_modules/pi-agent-pdf/package.json +3 -3
- package/node_modules/pi-agent-read/package.json +12 -11
- package/node_modules/pi-agent-read/runtime/entry-42.js +0 -1
- package/node_modules/pi-agent-read/runtime/entry-45.js +2 -0
- package/node_modules/pi-agent-read/src/api/read-parameters.ts +2 -2
- package/node_modules/pi-agent-read/src/core/extension.ts +16 -2
- package/node_modules/pi-agent-read/src/core/read-core.ts +4 -5
- package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +62 -8
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +19 -12
- package/node_modules/pi-agent-resource/package.json +2 -2
- package/node_modules/pi-agent-search/package.json +8 -7
- package/node_modules/pi-agent-search/runtime/entry-47.js +0 -1
- package/node_modules/pi-agent-search/runtime/entry-48.js +1 -0
- package/node_modules/pi-agent-search/runtime/entry-50.js +2 -0
- package/node_modules/pi-agent-search/src/core/extension.ts +29 -10
- package/node_modules/pi-agent-search-text/package.json +9 -9
- package/node_modules/pi-agent-text/package.json +3 -3
- package/node_modules/pi-agent-text/runtime/entry-53.js +1 -0
- package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
- package/node_modules/pi-agent-text-anchor-constant/runtime/entry-54.js +2 -0
- package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-55.js +1 -0
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-56.js +2 -0
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-58.js +2 -0
- package/node_modules/pi-agent-text-editor/index.ts +15 -0
- package/node_modules/pi-agent-text-editor/package.json +26 -25
- package/node_modules/pi-agent-text-editor/runtime/entry-72.js +0 -1
- package/node_modules/pi-agent-text-editor/runtime/entry-73.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-74.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-75.js +2 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +24 -18
- package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +4 -2
- package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +5 -44
- package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +13 -5
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +124 -26
- package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +2 -6
- package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +186 -1
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +2 -2
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +0 -11
- package/node_modules/pi-agent-text-editor/src/core/text-editor-config.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +0 -2
- package/node_modules/pi-agent-text-editor-renderer/index.ts +17 -4
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-renderer/runtime/entry-76.js +2 -0
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +23 -11
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +21 -16
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-78.js +1 -0
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-79.js +1 -0
- package/node_modules/pi-agent-web/package.json +7 -7
- package/node_modules/pi-agent-web-html/package.json +3 -3
- package/node_modules/pi-agent-web-image/package.json +4 -4
- package/node_modules/pi-agent-web-image/runtime/entry-82.js +2 -0
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/runtime/entry-83.js +2 -0
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/node_modules/pi-agent-web-text/runtime/entry-84.js +2 -0
- package/package.json +108 -44
- package/src/api/documentation.ts +2 -0
- package/src/composite/builtin-extensions.ts +7 -0
- package/src/composite/extensions-config.ts +6 -0
- package/src/composite/module-labels.ts +5 -0
- package/src/composite/module-settings-store.ts +3 -0
- package/src/composite/module-settings.ts +39 -5
- package/src/composite/preferences.ts +37 -0
- package/src/composite/presentation.ts +14 -0
- package/src/composite/presets.ts +57 -0
- package/src/documentation/extension.ts +295 -0
- package/src/documentation/registry.ts +98 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +0 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/index.ts +134 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +23 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-27.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/jq.ts +107 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-28.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-29.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-25.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-82.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-83.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-84.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-80.js +2 -0
- package/src/extensions/pi-agent-read/package.json +12 -11
- package/src/extensions/pi-agent-read/runtime/entry-42.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-43.js +1 -0
- package/src/extensions/pi-agent-read/runtime/entry-45.js +2 -0
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +2 -2
- package/src/extensions/pi-agent-read/src/core/extension.ts +16 -2
- package/src/extensions/pi-agent-read/src/core/read-core.ts +4 -5
- package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +62 -8
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +19 -12
- package/src/extensions/pi-agent-search/package.json +8 -7
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +9 -9
- package/src/extensions/pi-agent-search/runtime/entry-47.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-48.js +1 -0
- package/src/extensions/pi-agent-search/runtime/entry-49.js +1 -0
- package/src/extensions/pi-agent-search/runtime/entry-50.js +2 -0
- package/src/extensions/pi-agent-search/src/core/extension.ts +29 -10
- package/src/extensions/pi-agent-text-editor/index.ts +15 -0
- package/src/extensions/pi-agent-text-editor/package.json +26 -25
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-54.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-55.js +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-56.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-57.js +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-58.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +17 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-76.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +23 -11
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +21 -16
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/runtime/entry-72.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-73.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-74.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-75.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +24 -18
- package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +4 -2
- package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +5 -44
- package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +13 -5
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +124 -26
- package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +2 -6
- package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +186 -1
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +2 -2
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +0 -11
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-config.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +0 -2
- package/src/pi-agent-ide.ts +7 -10
- package/src/plugins/pi-agent-ide-ast/package.json +11 -11
- package/src/plugins/pi-agent-ide-ast/runtime/entry-30.js +1 -0
- package/src/plugins/pi-agent-ide-changes/index.ts +8 -0
- package/src/plugins/pi-agent-ide-changes/package.json +9 -8
- package/src/plugins/pi-agent-ide-changes/runtime/entry-32.js +1 -0
- package/src/plugins/pi-agent-ide-debugger/index.ts +12 -4
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +9 -4
- package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +1 -1
- package/src/plugins/pi-agent-ide-languages/package.json +3 -3
- package/src/plugins/pi-agent-ide-languages/runtime/entry-35.js +2 -0
- package/src/plugins/pi-agent-ide-lint/index.ts +1 -1
- package/src/plugins/pi-agent-ide-lint/package.json +8 -8
- package/src/plugins/pi-agent-ide-lint/runtime/entry-36.js +2 -0
- package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +17 -1
- package/src/plugins/pi-agent-ide-lsp/index.ts +0 -3
- package/src/plugins/pi-agent-ide-lsp/package.json +10 -10
- package/src/plugins/pi-agent-ide-lsp/runtime/entry-37.js +2 -0
- package/src/plugins/pi-agent-ide-terminal/index.ts +27 -2
- package/src/plugins/pi-agent-ide-terminal/src/renderer.ts +27 -2
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +1 -4
- package/src/plugins/pi-agent-ide-terminal/src/search.ts +0 -3
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +7 -4
- package/src/plugins/pi-agent-ide-vision/index.ts +8 -6
- package/dist/chunk-22CLOM2D.js +0 -1
- package/dist/chunk-3XJ3KDPZ.js +0 -16
- package/dist/chunk-526E364R.js +0 -3
- package/dist/chunk-DDKHZZDO.js +0 -5
- package/dist/chunk-EJ5OACQM.js +0 -1
- package/dist/chunk-PCZH7GOX.js +0 -26
- package/dist/chunk-SQ7ZTGOP.js +0 -2
- package/dist/entry-18.js +0 -1
- package/node_modules/pi-agent-doctor/runtime/entry-18.js +0 -1
- package/node_modules/pi-agent-filesystem/runtime/entry-23.js +0 -2
- package/node_modules/pi-agent-filesystem-image/runtime/entry-24.js +0 -2
- package/node_modules/pi-agent-ide-ast/runtime/entry-27.js +0 -1
- package/node_modules/pi-agent-ide-changes/runtime/entry-29.js +0 -1
- package/node_modules/pi-agent-ide-changes/runtime/entry-30.js +0 -2
- package/node_modules/pi-agent-ide-languages/runtime/entry-32.js +0 -2
- package/node_modules/pi-agent-image/runtime/entry-35.js +0 -1
- package/node_modules/pi-agent-invariant/runtime/entry-36.js +0 -1
- package/node_modules/pi-agent-pdf/runtime/entry-37.js +0 -1
- package/node_modules/pi-agent-search/runtime/entry-45.js +0 -1
- package/node_modules/pi-agent-search-text/runtime/entry-48.js +0 -2
- package/node_modules/pi-agent-text/runtime/entry-50.js +0 -1
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-53.js +0 -2
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-54.js +0 -1
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-55.js +0 -2
- package/node_modules/pi-agent-text-editor/runtime/entry-56.js +0 -1
- package/node_modules/pi-agent-text-editor/runtime/entry-58.js +0 -1
- package/node_modules/pi-agent-text-editor-renderer/runtime/entry-73.js +0 -2
- package/node_modules/pi-agent-text-editor-renderer/src/config.ts +0 -73
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-74.js +0 -2
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-75.js +0 -1
- package/node_modules/pi-agent-tool-ui/runtime/entry-76.js +0 -1
- package/node_modules/pi-agent-web-html/runtime/entry-78.js +0 -2
- package/node_modules/pi-agent-web-image/runtime/entry-79.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-24.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-25.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-23.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-78.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-79.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-80.js +0 -2
- package/src/extensions/pi-agent-read/runtime/entry-38.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-39.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-40.js +0 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-48.js +0 -2
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-49.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-45.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-46.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-53.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-54.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-55.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-73.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/config.ts +0 -73
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-74.js +0 -2
- package/src/extensions/pi-agent-text-editor/runtime/entry-56.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-57.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-58.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-27.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-28.js +0 -2
- package/src/plugins/pi-agent-ide-changes/runtime/entry-29.js +0 -1
- package/src/plugins/pi-agent-ide-changes/runtime/entry-30.js +0 -2
- package/src/plugins/pi-agent-ide-languages/runtime/entry-32.js +0 -2
- /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem}/runtime/entry-25.js +0 -0
- /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-image}/runtime/entry-26.js +0 -0
- /package/node_modules/{pi-agent-ide-ast → pi-agent-filesystem-pdf}/runtime/entry-28.js +0 -0
- /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-ast}/runtime/entry-31.js +0 -0
- /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-changes}/runtime/entry-33.js +0 -0
- /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-formatter}/runtime/entry-34.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-image}/runtime/entry-38.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-invariant}/runtime/entry-39.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-40.js +0 -0
- /package/node_modules/{pi-agent-resource → pi-agent-read}/runtime/entry-43.js +0 -0
- /package/node_modules/{pi-agent-search → pi-agent-read}/runtime/entry-44.js +0 -0
- /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-46.js +0 -0
- /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-49.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-constant → pi-agent-search-text}/runtime/entry-51.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-exact → pi-agent-search-text}/runtime/entry-52.js +0 -0
- /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-line-hash}/runtime/entry-57.js +0 -0
- /package/node_modules/{pi-agent-web → pi-agent-text-editor-stale-anchor}/runtime/entry-77.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web}/runtime/entry-80.js +0 -0
- /package/node_modules/{pi-agent-web-text → pi-agent-web-html}/runtime/entry-81.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-image}/runtime/entry-26.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-html}/runtime/entry-81.js +0 -0
- /package/src/extensions/{pi-agent-search → pi-agent-read}/runtime/entry-44.js +0 -0
- /package/src/extensions/{pi-agent-text-editor/plugins/pi-agent-text-anchor-constant → pi-agent-search/plugins/pi-agent-search-text}/runtime/entry-51.js +0 -0
- /package/src/extensions/{pi-agent-text-editor/plugins/pi-agent-text-anchor-exact → pi-agent-search/plugins/pi-agent-search-text}/runtime/entry-52.js +0 -0
- /package/src/extensions/{pi-agent-read/extensions/pi-agent-web → pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor}/runtime/entry-77.js +0 -0
- /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-ast}/runtime/entry-31.js +0 -0
- /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-changes}/runtime/entry-33.js +0 -0
- /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-formatter}/runtime/entry-34.js +0 -0
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { connectReadPlugin } from "pi-agent-read/api/connect-plugin";
|
|
3
|
+
import { READ_API_VERSION, READ_PROTOCOL } from "pi-agent-read/api/plugin-protocol";
|
|
4
|
+
import {
|
|
5
|
+
DOCUMENTATION_API_VERSION,
|
|
6
|
+
DOCUMENTATION_PROTOCOL,
|
|
7
|
+
DOCUMENTATION_READY_EVENT,
|
|
8
|
+
DOCUMENTATION_REGISTER_EVENT,
|
|
9
|
+
type AgentDocumentation,
|
|
10
|
+
} from "#src/api/documentation.js";
|
|
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
|
+
|
|
18
|
+
interface RegistrationRequest {
|
|
19
|
+
readonly documents: readonly AgentDocumentation[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Registers progressive documentation discovery, resources, and first-use attachments. */
|
|
23
|
+
export default async function registerProgressiveDocumentation(pi: ExtensionAPI): Promise<void> {
|
|
24
|
+
const registry = new AgentDocumentationRegistry();
|
|
25
|
+
const claimed = new Set<string>();
|
|
26
|
+
const fallbackGates = new Map<string, readonly AgentDocumentation[]>();
|
|
27
|
+
const gatedToolNames: string[] = [];
|
|
28
|
+
const gateHandler: ToolCallInterceptorHandler = {
|
|
29
|
+
name: "agent-documentation-first-use",
|
|
30
|
+
blockExecution: true,
|
|
31
|
+
toolNames: gatedToolNames,
|
|
32
|
+
intercept(context): InterceptResult | undefined {
|
|
33
|
+
if (process.env.PI_AGENT_IDE_TEST_SKIP_GUIDE_GATE === "1") return;
|
|
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
|
+
},
|
|
46
|
+
};
|
|
47
|
+
registerToolCallInterceptor(pi, gateHandler);
|
|
48
|
+
const unsubscribe = pi.events.on(DOCUMENTATION_REGISTER_EVENT, (value) => {
|
|
49
|
+
if (!isRegistrationRequest(value)) throw new Error("Invalid agent documentation registration");
|
|
50
|
+
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
|
+
});
|
|
60
|
+
pi.on("session_shutdown", unsubscribe);
|
|
61
|
+
|
|
62
|
+
await connectReadPlugin(pi, {
|
|
63
|
+
protocol: READ_PROTOCOL,
|
|
64
|
+
apiVersion: READ_API_VERSION,
|
|
65
|
+
id: "agent-documentation",
|
|
66
|
+
setup(api) {
|
|
67
|
+
api.addResolver({
|
|
68
|
+
resolver: {
|
|
69
|
+
id: "agent-documentation",
|
|
70
|
+
tryResolve(source) {
|
|
71
|
+
if (!source.startsWith("docs:"))
|
|
72
|
+
return Promise.resolve({ kind: "not-handled" as const });
|
|
73
|
+
const id = source.slice("docs:".length);
|
|
74
|
+
const document = id.length === 0 ? undefined : registry.get(id);
|
|
75
|
+
const markdown = id.length === 0 ? renderListing(registry.list()) : document?.markdown;
|
|
76
|
+
if (markdown === undefined) {
|
|
77
|
+
return Promise.resolve({
|
|
78
|
+
kind: "failed" as const,
|
|
79
|
+
error: new Error(`Unknown documentation ID: ${id}`),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return Promise.resolve({
|
|
83
|
+
kind: "resolved" as const,
|
|
84
|
+
resource: {
|
|
85
|
+
source,
|
|
86
|
+
read: () => Promise.resolve([{ type: "text" as const, text: markdown }]),
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
api.describe(() =>
|
|
93
|
+
registry.list().length === 0
|
|
94
|
+
? undefined
|
|
95
|
+
: "docs: and docs:<id> — list or read packaged agent guidance.",
|
|
96
|
+
);
|
|
97
|
+
api.addPromptGuideline(() => renderPromptGuideline(registry.list()));
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
pi.on("session_start", (_event, context) => {
|
|
102
|
+
restoreClaims(context.sessionManager.getBranch(), registry, claimed);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
pi.on("tool_call", (event, context) => {
|
|
106
|
+
if (process.env.PI_AGENT_IDE_TEST_SKIP_GUIDE_GATE === "1") return;
|
|
107
|
+
if (event.toolCallId.includes("-preflight-")) return;
|
|
108
|
+
restoreClaims(context.sessionManager.getBranch(), registry, claimed);
|
|
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) };
|
|
114
|
+
});
|
|
115
|
+
pi.on("tool_result", (event, context) => {
|
|
116
|
+
if (event.toolCallId.includes("-preflight-")) return;
|
|
117
|
+
const fallbackDocuments = fallbackGates.get(event.toolCallId);
|
|
118
|
+
if (fallbackDocuments !== undefined) {
|
|
119
|
+
fallbackGates.delete(event.toolCallId);
|
|
120
|
+
return {
|
|
121
|
+
content: [{ type: "text" as const, text: guideNotice(fallbackDocuments) }],
|
|
122
|
+
details: documentationGateDetails(fallbackDocuments),
|
|
123
|
+
isError: true,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
restoreClaims(context.sessionManager.getBranch(), registry, claimed, event.toolCallId);
|
|
127
|
+
const docsSource = documentationSource(event.input);
|
|
128
|
+
if (docsSource !== undefined) {
|
|
129
|
+
const id = docsSource.slice("docs:".length);
|
|
130
|
+
const available = registry.list();
|
|
131
|
+
const known = id.length === 0 || registry.get(id) !== undefined;
|
|
132
|
+
if (id.length > 0 && known) claimed.add(id);
|
|
133
|
+
return {
|
|
134
|
+
content: event.content,
|
|
135
|
+
details: {
|
|
136
|
+
...(isRecord(event.details) ? event.details : {}),
|
|
137
|
+
documentation: known
|
|
138
|
+
? id.length === 0
|
|
139
|
+
? { kind: "list", ids: available.map((document) => document.id) }
|
|
140
|
+
: { kind: "document", id }
|
|
141
|
+
: { kind: "error", code: "UNKNOWN_DOCUMENTATION", id },
|
|
142
|
+
},
|
|
143
|
+
isError: event.isError,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
if (process.env.PI_AGENT_IDE_TEST_SKIP_GUIDE_GATE === "1") return;
|
|
147
|
+
const documents = registry
|
|
148
|
+
.matching(event.toolName, event.input)
|
|
149
|
+
.filter((document) => !claimed.has(document.id));
|
|
150
|
+
if (documents.length === 0) return;
|
|
151
|
+
for (const document of documents) claimed.add(document.id);
|
|
152
|
+
return {
|
|
153
|
+
content: [
|
|
154
|
+
...event.content,
|
|
155
|
+
...documents.map((document) => ({
|
|
156
|
+
type: "text" as const,
|
|
157
|
+
text: `\n\n---\n\n# Guide: ${document.id}\n\n${document.markdown.trim()}`,
|
|
158
|
+
})),
|
|
159
|
+
],
|
|
160
|
+
details: {
|
|
161
|
+
...(isRecord(event.details) ? event.details : {}),
|
|
162
|
+
documentation: { kind: "attachment", ids: documents.map((document) => document.id) },
|
|
163
|
+
},
|
|
164
|
+
isError: event.isError,
|
|
165
|
+
};
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
pi.events.emit(DOCUMENTATION_READY_EVENT, {
|
|
169
|
+
protocol: DOCUMENTATION_PROTOCOL,
|
|
170
|
+
apiVersion: DOCUMENTATION_API_VERSION,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
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
|
+
function renderListing(documents: readonly AgentDocumentation[]): string {
|
|
227
|
+
if (documents.length === 0) return "No agent documentation is currently available.";
|
|
228
|
+
return [
|
|
229
|
+
"# Available agent documentation",
|
|
230
|
+
"",
|
|
231
|
+
...documents.map((doc) => `- \`${doc.id}\` — ${doc.description}`),
|
|
232
|
+
].join("\n");
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function renderPromptGuideline(documents: readonly AgentDocumentation[]): string | undefined {
|
|
236
|
+
if (documents.length === 0) return undefined;
|
|
237
|
+
return [
|
|
238
|
+
"Read docs:<id> for detailed packaged guidance when needed. Available documents:",
|
|
239
|
+
...documents.map((document) => ` - ${document.id} — ${document.description}`),
|
|
240
|
+
].join("\n");
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function restoreClaims(
|
|
244
|
+
branch: readonly unknown[],
|
|
245
|
+
registry: AgentDocumentationRegistry,
|
|
246
|
+
claimed: Set<string>,
|
|
247
|
+
currentToolCallId?: string,
|
|
248
|
+
): void {
|
|
249
|
+
for (const entry of branch) {
|
|
250
|
+
if (!isRecord(entry) || entry.type !== "message" || !isRecord(entry.message)) continue;
|
|
251
|
+
const message = entry.message;
|
|
252
|
+
if (message.toolCallId === currentToolCallId) continue;
|
|
253
|
+
if (typeof message.toolCallId === "string" && message.toolCallId.includes("-preflight-"))
|
|
254
|
+
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
|
+
}
|
|
273
|
+
const input = message.input ?? sourceInput(message.details);
|
|
274
|
+
for (const document of registry.matching(message.toolName, input)) claimed.add(document.id);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function documentationSource(input: unknown): string | undefined {
|
|
279
|
+
if (!isRecord(input) || typeof input.path !== "string" || !input.path.startsWith("docs:"))
|
|
280
|
+
return undefined;
|
|
281
|
+
return input.path;
|
|
282
|
+
}
|
|
283
|
+
|
|
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
|
+
function isRegistrationRequest(value: unknown): value is RegistrationRequest {
|
|
290
|
+
return isRecord(value) && Array.isArray(value.documents);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
294
|
+
return typeof value === "object" && value !== null;
|
|
295
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { AgentDocumentation } from "#src/api/documentation.js";
|
|
2
|
+
|
|
3
|
+
const DOCUMENT_ID = /^[a-z0-9]+(?:[.-][a-z0-9]+)*$/;
|
|
4
|
+
|
|
5
|
+
/** Ordered registry for currently enabled agent documentation. */
|
|
6
|
+
export class AgentDocumentationRegistry {
|
|
7
|
+
readonly #documents = new Map<string, AgentDocumentation>();
|
|
8
|
+
|
|
9
|
+
register(documents: readonly AgentDocumentation[]): void {
|
|
10
|
+
const ids = new Set(this.#documents.keys());
|
|
11
|
+
for (const document of documents) {
|
|
12
|
+
validateDocument(document, ids);
|
|
13
|
+
ids.add(document.id);
|
|
14
|
+
}
|
|
15
|
+
for (const document of documents) this.#documents.set(document.id, freezeDocument(document));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
list(): readonly AgentDocumentation[] {
|
|
19
|
+
return [...this.#documents.values()].sort((left, right) => left.id.localeCompare(right.id));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
get(id: string): AgentDocumentation | undefined {
|
|
23
|
+
return this.#documents.get(id);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
matching(toolName: string, input: unknown): readonly AgentDocumentation[] {
|
|
27
|
+
const resourcePath = readPath(input);
|
|
28
|
+
if (resourcePath?.startsWith("docs:") === true) return [];
|
|
29
|
+
return this.list().filter((document) =>
|
|
30
|
+
document.triggers.some((trigger) => {
|
|
31
|
+
if (trigger.tool !== toolName) return false;
|
|
32
|
+
const resourceMatches =
|
|
33
|
+
trigger.resourcePrefixes === undefined ||
|
|
34
|
+
(resourcePath !== undefined &&
|
|
35
|
+
trigger.resourcePrefixes.some((prefix) => resourcePath.startsWith(prefix)));
|
|
36
|
+
const viewMatches =
|
|
37
|
+
trigger.viewPrefixes === undefined ||
|
|
38
|
+
readViews(input).some((view) =>
|
|
39
|
+
trigger.viewPrefixes?.some((prefix) => view.startsWith(prefix)),
|
|
40
|
+
);
|
|
41
|
+
return resourceMatches && viewMatches;
|
|
42
|
+
}),
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function validateDocument(document: AgentDocumentation, existingIds: ReadonlySet<string>): void {
|
|
48
|
+
if (!DOCUMENT_ID.test(document.id)) throw new Error(`Invalid documentation ID: ${document.id}`);
|
|
49
|
+
if (document.description.trim().length === 0)
|
|
50
|
+
throw new Error(`Documentation ${document.id} has no description`);
|
|
51
|
+
if (document.markdown.trim().length === 0)
|
|
52
|
+
throw new Error(`Documentation ${document.id} has no Markdown content`);
|
|
53
|
+
if (
|
|
54
|
+
document.triggers.length === 0 ||
|
|
55
|
+
document.triggers.some(
|
|
56
|
+
(trigger) =>
|
|
57
|
+
trigger.tool.trim().length === 0 ||
|
|
58
|
+
trigger.resourcePrefixes?.some((prefix) => prefix.length === 0) === true ||
|
|
59
|
+
trigger.viewPrefixes?.some((prefix) => prefix.length === 0) === true,
|
|
60
|
+
)
|
|
61
|
+
)
|
|
62
|
+
throw new Error(`Documentation ${document.id} has no valid triggers`);
|
|
63
|
+
if (existingIds.has(document.id))
|
|
64
|
+
throw new Error(`Documentation ${document.id} is already registered`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function freezeDocument(document: AgentDocumentation): AgentDocumentation {
|
|
68
|
+
return Object.freeze({
|
|
69
|
+
...document,
|
|
70
|
+
triggers: Object.freeze(
|
|
71
|
+
document.triggers.map((trigger) =>
|
|
72
|
+
Object.freeze({
|
|
73
|
+
...trigger,
|
|
74
|
+
...(trigger.resourcePrefixes === undefined
|
|
75
|
+
? {}
|
|
76
|
+
: { resourcePrefixes: Object.freeze([...trigger.resourcePrefixes]) }),
|
|
77
|
+
...(trigger.viewPrefixes === undefined
|
|
78
|
+
? {}
|
|
79
|
+
: { viewPrefixes: Object.freeze([...trigger.viewPrefixes]) }),
|
|
80
|
+
}),
|
|
81
|
+
),
|
|
82
|
+
),
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function readViews(input: unknown): readonly string[] {
|
|
87
|
+
if (typeof input !== "object" || input === null) return [];
|
|
88
|
+
const views = (input as { readonly views?: unknown }).views;
|
|
89
|
+
return Array.isArray(views)
|
|
90
|
+
? views.filter((view): view is string => typeof view === "string")
|
|
91
|
+
: [];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function readPath(input: unknown): string | undefined {
|
|
95
|
+
if (typeof input !== "object" || input === null) return undefined;
|
|
96
|
+
const path = (input as { readonly path?: unknown }).path;
|
|
97
|
+
return typeof path === "string" ? path : undefined;
|
|
98
|
+
}
|
|
@@ -37,10 +37,6 @@ export default async function registerFilesystemPlugin(pi: ExtensionAPI): Promis
|
|
|
37
37
|
readHost.listDescriptions(),
|
|
38
38
|
),
|
|
39
39
|
);
|
|
40
|
-
|
|
41
|
-
api.addPromptGuideline(
|
|
42
|
-
"Use read with paths relative to the current working directory for project files. Use read with absolute paths for files elsewhere on the system.",
|
|
43
|
-
);
|
|
44
40
|
},
|
|
45
41
|
} satisfies ReadPlugin;
|
|
46
42
|
const textEditorPlugin = {
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-filesystem",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"pi-agent-image": "0.6.
|
|
10
|
-
"pi-agent-read": "0.6.
|
|
11
|
-
"pi-agent-resource": "0.6.
|
|
12
|
-
"pi-agent-text": "0.6.
|
|
13
|
-
"pi-agent-text-editor": "0.6.
|
|
9
|
+
"pi-agent-image": "0.6.1",
|
|
10
|
+
"pi-agent-read": "0.6.1",
|
|
11
|
+
"pi-agent-resource": "0.6.1",
|
|
12
|
+
"pi-agent-text": "0.6.1",
|
|
13
|
+
"pi-agent-text-editor": "0.6.1"
|
|
14
14
|
},
|
|
15
15
|
"pi": {
|
|
16
16
|
"extensions": [
|
|
17
|
-
"./runtime/entry-
|
|
17
|
+
"./runtime/entry-25.js"
|
|
18
18
|
]
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-filesystem-image",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#extension": "./index.ts"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"pi-agent-image": "0.6.
|
|
10
|
-
"pi-agent-resource": "0.6.
|
|
9
|
+
"pi-agent-image": "0.6.1",
|
|
10
|
+
"pi-agent-resource": "0.6.1"
|
|
11
11
|
},
|
|
12
12
|
"pi": {
|
|
13
13
|
"extensions": [
|
|
14
|
-
"./runtime/entry-
|
|
14
|
+
"./runtime/entry-26.js"
|
|
15
15
|
]
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { connectDoctorPlugin } from "pi-agent-doctor/api/connect-plugin";
|
|
3
|
+
import { isExecutableAvailable, probeExecutable } from "pi-agent-doctor/api/executable";
|
|
4
|
+
import {
|
|
5
|
+
DOCTOR_API_VERSION,
|
|
6
|
+
DOCTOR_PROTOCOL,
|
|
7
|
+
type DoctorPlugin,
|
|
8
|
+
} from "pi-agent-doctor/api/plugin-protocol";
|
|
9
|
+
import { connectAgentDocumentation, loadPackagedAgentGuide } from "pi-agent-documentation";
|
|
10
|
+
import { connectReadPlugin } from "pi-agent-read/api/connect-plugin";
|
|
11
|
+
import {
|
|
12
|
+
READ_API_VERSION,
|
|
13
|
+
READ_PROTOCOL,
|
|
14
|
+
type ReadPlugin,
|
|
15
|
+
} from "pi-agent-read/api/plugin-protocol";
|
|
16
|
+
import type { ReadTextState } from "pi-agent-read/api/tools/read";
|
|
17
|
+
import { createTextDocument } from "pi-agent-text";
|
|
18
|
+
|
|
19
|
+
import { executeJq, parseJqView } from "#src/jq.js";
|
|
20
|
+
|
|
21
|
+
export default async function registerFilesystemJq(pi: ExtensionAPI): Promise<void> {
|
|
22
|
+
connectAgentDocumentation(pi, [
|
|
23
|
+
await loadPackagedAgentGuide({
|
|
24
|
+
id: "json-reading",
|
|
25
|
+
description: "Query and transform JSON resources with jq read views",
|
|
26
|
+
triggers: [{ tool: "read", viewPrefixes: ["jq:"] }],
|
|
27
|
+
}),
|
|
28
|
+
]);
|
|
29
|
+
await Promise.all([connectReadPlugin(pi, readPlugin), connectDoctorPlugin(pi, doctorPlugin)]);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const readPlugin = {
|
|
33
|
+
protocol: READ_PROTOCOL,
|
|
34
|
+
apiVersion: READ_API_VERSION,
|
|
35
|
+
id: "filesystem-jq",
|
|
36
|
+
setup(api) {
|
|
37
|
+
api.addView({
|
|
38
|
+
view: "jq",
|
|
39
|
+
presenter: { id: "filesystem-jq", present: (document) => document },
|
|
40
|
+
});
|
|
41
|
+
api.addHandler({
|
|
42
|
+
stage: "read",
|
|
43
|
+
when: { resolvedBy: "filesystem", contentKind: "text" },
|
|
44
|
+
async handler(context) {
|
|
45
|
+
const state = context.state;
|
|
46
|
+
if (state?.contentKind !== "text") return { kind: "continue", context };
|
|
47
|
+
let selected: ReturnType<typeof parseJqView>;
|
|
48
|
+
try {
|
|
49
|
+
selected = parseJqView(context.request.views);
|
|
50
|
+
} catch (error) {
|
|
51
|
+
return jqFailure(state, error instanceof Error ? error.message : String(error));
|
|
52
|
+
}
|
|
53
|
+
if (selected === undefined) return { kind: "continue", context };
|
|
54
|
+
let output: string;
|
|
55
|
+
try {
|
|
56
|
+
output = await executeJq(selected.filter, state.content[0].text, {
|
|
57
|
+
cwd: context.resolverContext.cwd,
|
|
58
|
+
...(context.resolverContext.signal === undefined
|
|
59
|
+
? {}
|
|
60
|
+
: { signal: context.resolverContext.signal }),
|
|
61
|
+
});
|
|
62
|
+
} catch (error) {
|
|
63
|
+
return jqFailure(state, error instanceof Error ? error.message : String(error));
|
|
64
|
+
}
|
|
65
|
+
const transformed: ReadTextState = {
|
|
66
|
+
...state,
|
|
67
|
+
content: [{ type: "text", text: output }],
|
|
68
|
+
text: createTextDocument(state.source, output),
|
|
69
|
+
preserveTruncatedOutput: true,
|
|
70
|
+
};
|
|
71
|
+
return { kind: "continue", context: { ...context, state: transformed } };
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
api.describe(
|
|
75
|
+
'JSON files accept views such as ["jq:.scripts | keys"] to query them with the installed jq executable.',
|
|
76
|
+
);
|
|
77
|
+
},
|
|
78
|
+
} satisfies ReadPlugin;
|
|
79
|
+
|
|
80
|
+
function jqFailure(state: ReadTextState, message: string) {
|
|
81
|
+
return {
|
|
82
|
+
kind: "return" as const,
|
|
83
|
+
result: {
|
|
84
|
+
content: [{ type: "text" as const, text: `jq failed: ${message}` }],
|
|
85
|
+
details: {
|
|
86
|
+
source: state.source,
|
|
87
|
+
resolvedBy: state.resolvedBy,
|
|
88
|
+
failure: {
|
|
89
|
+
code: "READ_FAILED" as const,
|
|
90
|
+
source: state.source,
|
|
91
|
+
resolverId: state.resolvedBy,
|
|
92
|
+
pluginId: "filesystem-jq",
|
|
93
|
+
stage: "read" as const,
|
|
94
|
+
message,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
isError: true,
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
const doctorPlugin = {
|
|
102
|
+
protocol: DOCTOR_PROTOCOL,
|
|
103
|
+
apiVersion: DOCTOR_API_VERSION,
|
|
104
|
+
id: "filesystem-jq",
|
|
105
|
+
setup(api) {
|
|
106
|
+
api.addSetupCheck({
|
|
107
|
+
id: "jq",
|
|
108
|
+
async inspect(context) {
|
|
109
|
+
return (await isExecutableAvailable("jq", context.cwd, context.env))
|
|
110
|
+
? {}
|
|
111
|
+
: {
|
|
112
|
+
actions: [
|
|
113
|
+
{
|
|
114
|
+
id: "jq-unavailable",
|
|
115
|
+
message: "JSON jq views are unavailable because jq was not found",
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
api.addCheck({
|
|
122
|
+
id: "jq",
|
|
123
|
+
title: "JSON jq views",
|
|
124
|
+
async run(context) {
|
|
125
|
+
const result = await probeExecutable("jq", ["--version"], context.cwd, context.env);
|
|
126
|
+
return [
|
|
127
|
+
result.ok
|
|
128
|
+
? { status: "pass", message: "jq is available", detail: result.detail }
|
|
129
|
+
: { status: "fail", message: "jq is not available", detail: result.detail },
|
|
130
|
+
];
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
} satisfies DoctorPlugin;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pi-agent-filesystem-jq",
|
|
3
|
+
"version": "0.6.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"imports": {
|
|
6
|
+
"#src/*": "./src/*"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"cross-spawn": "^7.0.6",
|
|
10
|
+
"pi-agent-doctor": "0.6.1",
|
|
11
|
+
"pi-agent-documentation": "0.6.1",
|
|
12
|
+
"pi-agent-read": "0.6.1",
|
|
13
|
+
"pi-agent-text": "0.6.1"
|
|
14
|
+
},
|
|
15
|
+
"pi": {
|
|
16
|
+
"extensions": [
|
|
17
|
+
"./runtime/entry-27.js"
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"@earendil-works/pi-coding-agent": "*"
|
|
22
|
+
}
|
|
23
|
+
}
|