pi-agent-ide 0.6.0 → 0.6.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 +41 -0
- package/README.md +146 -68
- package/assets/social-preview.png +0 -0
- package/assets/summary/debugging.png +0 -0
- package/assets/summary/editing.png +0 -0
- package/assets/summary/read.png +0 -0
- package/assets/summary/search-and-replace.png +0 -0
- package/assets/summary/search.png +0 -0
- package/assets/summary/settings.png +0 -0
- package/assets/summary/terminal.png +0 -0
- package/assets/summary/thumbs/debugging.png +0 -0
- package/assets/summary/thumbs/editing.png +0 -0
- package/assets/summary/thumbs/read.png +0 -0
- package/assets/summary/thumbs/search-and-replace.png +0 -0
- package/assets/summary/thumbs/search.png +0 -0
- package/assets/summary/thumbs/settings.png +0 -0
- package/assets/summary/thumbs/terminal.png +0 -0
- package/assets/summary/thumbs/user_terminal.png +0 -0
- package/assets/summary/user_terminal.png +0 -0
- package/dist/chunk-3E2NTWCN.js +2 -0
- package/dist/chunk-7WCZOO5I.js +1 -0
- package/dist/chunk-CEX3VOJ7.js +2 -0
- package/dist/chunk-FA6BKC5Y.js +1 -0
- package/dist/{chunk-2527OQ4Y.js → chunk-HMLH43ZS.js} +1 -1
- package/dist/chunk-LVWMWWWF.js +28 -0
- package/dist/chunk-MPT3R4BL.js +0 -0
- package/dist/chunk-PZFOOHY2.js +15 -0
- package/dist/{chunk-HKMBQLEK.js → chunk-QDLTO5PH.js} +1 -1
- package/dist/{chunk-Z3VC3S2T.js → chunk-QIK2E64R.js} +1 -1
- package/dist/{chunk-OYWIZII6.js → chunk-S6QRG3TQ.js} +1 -1
- package/dist/chunk-T7CZIACQ.js +27 -0
- package/dist/chunk-T7I2VX3J.js +1 -0
- package/dist/chunk-VCTK4JSN.js +3 -0
- package/dist/chunk-VXD6FZP5.js +5 -0
- package/dist/chunk-W7CASEO3.js +1 -0
- package/dist/chunk-YT42LKFV.js +16 -0
- package/dist/entry-1.js +1 -1
- 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-2.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 +13 -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 +10 -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 +1 -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 +0 -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 +1 -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 +0 -30
- package/dist/entry-74.js +1 -2
- package/dist/entry-75.js +1 -1
- package/dist/entry-76.js +1 -1
- package/dist/entry-77.js +315 -3
- package/dist/entry-78.js +30 -3
- package/dist/entry-79.js +2 -1
- package/dist/entry-80.js +1 -1
- package/dist/entry-81.js +1 -1
- package/dist/entry-82.js +3 -0
- package/dist/entry-83.js +3 -0
- package/dist/entry-84.js +1 -0
- package/dist/entry-85.js +1 -0
- package/dist/entry-86.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 +12 -11
- package/node_modules/pi-agent-ide-ast/runtime/entry-30.js +1 -0
- package/node_modules/pi-agent-ide-ast/src/search-presentation.ts +117 -0
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +20 -2
- 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 +17 -9
- package/node_modules/pi-agent-search-text/runtime/entry-53.js +1 -0
- package/node_modules/pi-agent-search-text/src/persisted-result.ts +9 -7
- package/node_modules/pi-agent-search-text/src/search-renderer.ts +10 -4
- package/node_modules/pi-agent-search-text/src/search-result.ts +8 -1
- package/node_modules/pi-agent-text/package.json +3 -3
- package/node_modules/pi-agent-text/runtime/entry-55.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-56.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-58.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-60.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/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/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-80.js +1 -0
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-81.js +1 -0
- package/node_modules/pi-agent-web/package.json +7 -7
- package/node_modules/pi-agent-web/runtime/entry-82.js +2 -0
- package/node_modules/pi-agent-web-html/package.json +3 -3
- package/node_modules/pi-agent-web-html/runtime/entry-83.js +2 -0
- package/node_modules/pi-agent-web-image/package.json +4 -4
- package/node_modules/pi-agent-web-image/runtime/entry-84.js +2 -0
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/runtime/entry-85.js +2 -0
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/node_modules/pi-agent-web-text/runtime/entry-86.js +2 -0
- package/package.json +108 -44
- package/src/api/documentation.ts +2 -0
- package/src/api/plugin-protocol.ts +10 -4
- 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-html/runtime/entry-83.js +2 -0
- 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-84.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-85.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-86.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-82.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 +17 -9
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-53.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/persisted-result.ts +9 -7
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +10 -4
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +8 -1
- 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-56.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-57.js +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-58.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-59.js +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-60.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-78.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/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-79.js +2 -0
- 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 +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-76.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-77.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 +12 -11
- package/src/plugins/pi-agent-ide-ast/runtime/entry-30.js +1 -0
- package/src/plugins/pi-agent-ide-ast/src/search-presentation.ts +117 -0
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +20 -2
- 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 +44 -14
- package/src/plugins/pi-agent-ide-debugger/src/renderer.ts +10 -1
- package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +39 -0
- package/src/plugins/pi-agent-ide-debugger/src/ui.ts +42 -5
- 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 +88 -12
- package/src/plugins/pi-agent-ide-terminal/src/screen-image.ts +6 -2
- 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 +10 -7
- package/src/plugins/pi-agent-ide-vision/src/vision.ts +17 -3
- package/assets/gallery/apply-editing.png +0 -0
- package/assets/gallery/debugging.png +0 -0
- package/assets/gallery/read-web.png +0 -0
- package/assets/gallery/search-replace.png +0 -0
- package/assets/gallery/terminal.png +0 -0
- package/assets/gallery/tool-editing.png +0 -0
- 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-HSM6R7IB.js +0 -27
- 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-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/runtime/entry-60.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-web-pdf/runtime/entry-80.js +0 -2
- package/node_modules/pi-agent-web-text/runtime/entry-81.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/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-81.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-77.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-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/extensions/pi-agent-text-editor/runtime/entry-59.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-60.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-anchor-line-hash → pi-agent-search-text}/runtime/entry-54.js +0 -0
- /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-exact}/runtime/entry-57.js +0 -0
- /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-line-hash}/runtime/entry-59.js +0 -0
- /package/node_modules/{pi-agent-tool-call-interception → pi-agent-text-editor}/runtime/entry-75.js +0 -0
- /package/node_modules/{pi-agent-tool-ui → pi-agent-text-editor}/runtime/entry-76.js +0 -0
- /package/node_modules/{pi-agent-web → pi-agent-text-editor}/runtime/entry-77.js +0 -0
- /package/node_modules/{pi-agent-web-html → pi-agent-text-editor-renderer}/runtime/entry-78.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-text-editor-stale-anchor}/runtime/entry-79.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-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-text-editor/plugins/pi-agent-text-anchor-line-hash → pi-agent-search/plugins/pi-agent-search-text}/runtime/entry-54.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
package/dist/entry-12.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{a}from"./chunk-K5G4FDXD.js";import"./chunk-EI7MMDWY.js";export{a as sameFilePath};
|
package/dist/entry-13.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import"./chunk-U2JKHKLK.js";import{a as k,b as l,c as m,d as n,e as o,f as p,g as q}from"./chunk-FA6BKC5Y.js";import"./chunk-NNCZYO4Q.js";import{b as i,d as j}from"./chunk-VCTK4JSN.js";import"./chunk-YHUTTZC6.js";import{a as h}from"./chunk-6CZO43OH.js";import{a,b,c,d,e,f,g}from"./chunk-OBNING2A.js";import"./chunk-S3ZPXWX7.js";import"./chunk-5VSE5X5R.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{i as COMPACT_READ_ROWS,b as READ_API_VERSION,c as READ_CORE_READY_EVENT,d as READ_PLUGIN_REGISTER_EVENT,a as READ_PROTOCOL,h as connectReadPlugin,j as createReadResultRenderer,p as isFragmentResolverRegistration,e as isReadCoreReady,q as isReadFragmentResolution,n as isReadHandlerRegistration,f as isReadPlugin,g as isReadPluginRegistrationRequest,o as isReadViewRegistration,m as isResourceResolverRegistration,l as isTextTargetResolverRegistration,k as readParameters};
|
package/dist/entry-14.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c,l as d,m as g,n as h,o as i,p as j,q as k,r as l,s as n,t as q,u as s,v as u}from"./chunk-S3ZPXWX7.js";import"./chunk-EI7MMDWY.js";export{j as CONTENT_API_VERSION,l as CONTENT_CONVERTER_REGISTER_EVENT,k as CONTENT_HOST_READY_EVENT,i as CONTENT_PROTOCOL,d as UnsupportedContentError,u as connectContentConverter,s as createContentHost,g as createContentRunner,r as isAgentContent,b as isContentConversionAttempt,x as isContentConversionContext,a as isContentConverter,c as isContentConverterRegistration,q as isContentConverterRegistrationRequest,n as isContentHostReady,t as isContentInput,p as isContentTarget,e as isResource,m as isResourceResolutionAttempt,f as isResourceResolver,o as renderContentDescription,h as targetsEqual};
|
package/dist/entry-15.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o,b as r,c as e,d as f,e as m,f as p,g as t
|
|
1
|
+
import"./chunk-ROXXK6TW.js";import{a}from"./chunk-KII2JQC5.js";import{a as x}from"./chunk-ZTYWHL2F.js";import{a as o,b as r,c as e,d as f,e as m,f as p,g as t}from"./chunk-7UGNGK7Y.js";import"./chunk-EI7MMDWY.js";export{r as SEARCH_API_VERSION,e as SEARCH_CORE_READY_EVENT,f as SEARCH_PLUGIN_REGISTER_EVENT,o as SEARCH_PROTOCOL,x as connectSearchPlugin,m as isSearchCoreReady,p as isSearchPlugin,t as isSearchPluginRegistrationRequest,a as searchSchema};
|
package/dist/entry-16.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c,l as d,m as g,n as h,o as i,p as j,q as k,r as l,s as n,t as q,u as s}from"./chunk-5VSE5X5R.js";import"./chunk-EI7MMDWY.js";export{o as TextAnchor,r as attachTextAnchorRenderer,j as createTextContentConverter,g as createTextDocument,e as getTextAnchorRenderer,a as getTextSourceLine,t as isTextAnchorRecoveryOutcome,p as isTextAnchorResolutionAttempt,m as isTextAnchorResolver,c as isTextLinePresenter,d as isTextPresenterRegistration,n as isTextTargetResolutionAttempt,k as isTextualMediaType,i as renderPresentedTextDocument,x as renderPresentedTextRows,f as renderTextAnchor,h as renderTextDocument,s as restoreText,q as storeText,l as textFromAgentContent,b as withTextSourceLine};
|
package/dist/entry-17.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-IQD6PON5.js";import{m as o}from"./chunk-FEDVTZJG.js";import{a as n}from"./chunk-L7JMDDSD.js";import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import"./chunk-5VSE5X5R.js";import"./chunk-EI7MMDWY.js";export{b as TEXT_EDITOR_API_VERSION,e as TEXT_EDITOR_CORE_READY_EVENT,f as TEXT_EDITOR_PLUGIN_REGISTER_EVENT,a as TEXT_EDITOR_PROTOCOL,c as TEXT_POSITION_ANCHOR_KIND,d as TEXT_SEARCH_ANCHOR_KIND,n as connectTextEditorPlugin,o as connectTextEditorPostEditHandler,h as isResourceResolverRegistration,i as isTextAnchorResolverRegistration,j as isTextAnchorResourceResolutionAttempt,k as isTextEditorCoreReady,l as isTextEditorPlugin,m as isTextEditorPluginRegistrationRequest,g as isTextEditorToolId};
|
package/dist/entry-19.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import"./chunk-K4ZMRDEI.js";
|
package/dist/entry-2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g}from"./chunk-QIK2E64R.js";import"./chunk-EI7MMDWY.js";export{b as IDE_API_VERSION,c as IDE_CORE_READY_EVENT,d as IDE_PLUGIN_REGISTER_EVENT,a as IDE_PROTOCOL,e as isIdeCoreReady,f as isIdePlugin,g as isIdePluginRegistrationRequest};
|
package/dist/entry-20.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a
|
|
1
|
+
import{a}from"./chunk-MGCHOGQD.js";import"./chunk-T6LX2RX5.js";import"./chunk-EI7MMDWY.js";export{a as connectDoctorPlugin};
|
package/dist/entry-21.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b
|
|
1
|
+
import{a,b}from"./chunk-WZI4YC2O.js";import"./chunk-EI7MMDWY.js";export{b as hasProjectMarker,a as inspectRecipeEvidence};
|
package/dist/entry-22.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e
|
|
1
|
+
import{a,b,c,d,e}from"./chunk-N34ATN52.js";import"./chunk-EI7MMDWY.js";export{d as isExecutableAvailable,b as normalizeProcessEnvironment,e as probeExecutable,a as projectExecutableDirectories,c as projectProcessEnvironment};
|
package/dist/entry-23.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{a
|
|
2
|
-
`)}]}o(U,"readDirectoryContent");async function V(e,s,t){a(t);let i=await D(e,{encoding:null,...t!==void 0&&{signal:t}});return a(t),s.convert({source:e,bytes:i},t===void 0?{}:{signal:t})}o(V,"readFilesystemContent");function W(e){return/^[A-Za-z]:[\\/]/u.test(e)||e.startsWith("file://")?!0:!/^[A-Za-z][A-Za-z\d+.-]*:/u.test(e)}o(W,"isFilesystemSource");function a(e){if(e?.aborted===!0)throw E()}o(a,"throwIfAborted");function E(){let e=new Error("The operation was aborted");return e.name="AbortError",e}o(E,"abortError");var z={provider:"filesystem",capability:"read"},Z={provider:"filesystem",capability:"write"},$=v({kind:"source",nativeResources:!0});async function j(e){let s=m(e,z),t=m(e,Z),i=T(s),r=C(t),l={protocol:y,apiVersion:p,id:"filesystem",setup(n){n.addResolver({resolver:i,renderResult:$}),n.describe(()=>g("File path \u2014 file content; directory path \u2014 entry listing. Relative, absolute and file:// paths accepted.",s.listDescriptions())),n.addPromptGuideline("Use read with paths relative to the current working directory for project files. Use read with absolute paths for files elsewhere on the system.")}},c={protocol:h,apiVersion:F,id:"filesystem",setup(n){n.addResolver({resolver:r})}};await Promise.all([R(e,l),w(e,c)])}o(j,"registerFilesystemPlugin");export{j as default};
|
|
1
|
+
import{a,b,c,d,e,f}from"./chunk-T6LX2RX5.js";import"./chunk-EI7MMDWY.js";export{b as DOCTOR_API_VERSION,c as DOCTOR_CORE_READY_EVENT,d as DOCTOR_PLUGIN_REGISTER_EVENT,a as DOCTOR_PROTOCOL,e as isDoctorCoreReady,f as isDoctorPluginRegistrationRequest};
|
package/dist/entry-24.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a
|
|
1
|
+
import{a,b,c,d,e,f}from"./chunk-T7I2VX3J.js";import"./chunk-EI7MMDWY.js";export{b as DOCUMENTATION_API_VERSION,a as DOCUMENTATION_PROTOCOL,c as DOCUMENTATION_READY_EVENT,d as DOCUMENTATION_REGISTER_EVENT,f as connectAgentDocumentation,e as loadPackagedAgentGuide};
|
package/dist/entry-25.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as b}from"./chunk-L7JMDDSD.js";import{a as F,b as T}from"./chunk-O6LE42GK.js";import"./chunk-NNCZYO4Q.js";import{d as v}from"./chunk-VCTK4JSN.js";import"./chunk-YHUTTZC6.js";import{a as p}from"./chunk-6CZO43OH.js";import{a as y,b as R}from"./chunk-OBNING2A.js";import{a as g,u as m}from"./chunk-S3ZPXWX7.js";import{r as f}from"./chunk-5VSE5X5R.js";import"./chunk-ZC65Z3CK.js";import{a as o}from"./chunk-EI7MMDWY.js";import{readdirSync as x,realpathSync as H,statSync as S}from"node:fs";import{mkdir as D,readFile as O,writeFile as k}from"node:fs/promises";import w from"node:path";import{fileURLToPath as I,pathToFileURL as _}from"node:url";function C(e){return E("read",e)}o(C,"createFilesystemReadResolver");function h(e){return E("write",e)}o(h,"createFilesystemWriteResolver");function E(e,s){return{id:"filesystem",tryResolve(t,i){return Promise.resolve(L(t,i,e,s))}}}o(E,"createFilesystemResolver");function L(e,s,t,i){if(e.length===0)return{kind:"failed",error:new TypeError("Filesystem source must not be empty")};if(!z(e))return{kind:"not-handled"};if(s.signal?.aborted===!0)return{kind:"failed",error:P()};let r=e.startsWith("file://")?H(I(new URL(e))):w.resolve(s.cwd,e),l=_(r).href,c=(()=>{try{return S(r).isDirectory()}catch{return!1}})(),n=o(async({signal:d})=>c?V(r,d):W(r,i,d),"read");return t==="read"||c?{kind:"resolved",resource:{source:r,link:l,read:n}}:{kind:"resolved",resource:{source:r,link:l,read:n,async write(d,u){a(u.signal);let A=f(d);await D(w.dirname(r),{recursive:!0}),a(u.signal),await k(r,A,{encoding:"utf8",...u.signal!==void 0&&{signal:u.signal}})}}}}o(L,"resolveFilesystemSource");function V(e,s){a(s);let t=x(e,{withFileTypes:!0}),i=[`\u{1F4C1} ${e}/`];t.length>0&&i.push("");for(let r of t){let l=r.isDirectory()?"\u{1F4C1}":r.isFile()?"\u{1F4C4}":"\u{1F517}";i.push(` ${l} ${r.name}`)}return[{type:"text",text:i.join(`
|
|
2
|
+
`)}]}o(V,"readDirectoryContent");async function W(e,s,t){a(t);let i=await O(e,{encoding:null,...t!==void 0&&{signal:t}});return a(t),s.convert({source:e,bytes:i},t===void 0?{}:{signal:t})}o(W,"readFilesystemContent");function z(e){return/^[A-Za-z]:[\\/]/u.test(e)||e.startsWith("file://")?!0:!/^[A-Za-z][A-Za-z\d+.-]*:/u.test(e)}o(z,"isFilesystemSource");function a(e){if(e?.aborted===!0)throw P()}o(a,"throwIfAborted");function P(){let e=new Error("The operation was aborted");return e.name="AbortError",e}o(P,"abortError");var U={provider:"filesystem",capability:"read"},Z={provider:"filesystem",capability:"write"},$=v({kind:"source",nativeResources:!0});async function N(e){let s=m(e,U),t=m(e,Z),i=C(s),r=h(t),l={protocol:y,apiVersion:R,id:"filesystem",setup(n){n.addResolver({resolver:i,renderResult:$}),n.describe(()=>g("File path \u2014 file content; directory path \u2014 entry listing. Relative, absolute and file:// paths accepted.",s.listDescriptions()))}},c={protocol:F,apiVersion:T,id:"filesystem",setup(n){n.addResolver({resolver:r})}};await Promise.all([p(e,l),b(e,c)])}o(N,"registerFilesystemPlugin");export{N as default};
|
package/dist/entry-26.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a as r}from"./chunk-QIJMV2P2.js";import{v as e}from"./chunk-S3ZPXWX7.js";import{a as t}from"./chunk-EI7MMDWY.js";var n={target:{provider:"filesystem",capability:"read"},converter:r(),priority:100};async function i(o){await e(o,n)}t(i,"registerFilesystemImage");export{i as default};
|
package/dist/entry-27.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{b as
|
|
1
|
+
import{e as P,f as x}from"./chunk-T7I2VX3J.js";import{a as T}from"./chunk-MGCHOGQD.js";import{a as E,b as h}from"./chunk-T6LX2RX5.js";import{a as S}from"./chunk-6CZO43OH.js";import{a as R,b as O}from"./chunk-OBNING2A.js";import{m as q}from"./chunk-5VSE5X5R.js";import{c as j,d as v,e as y}from"./chunk-N34ATN52.js";import{a as o}from"./chunk-EI7MMDWY.js";import C from"cross-spawn";import{fileURLToPath as L}from"node:url";var b=5e3,J=10*1024*1024,k=L(new URL(".",new URL("../src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/jq.ts",import.meta.url).href));function _(r){let e=r?.filter(i=>i==="jq"||i.startsWith("jq:"))??[];if(e.length===0)return;if(e.length>1)throw new Error("Read accepts only one jq view");if(r?.length!==1)throw new Error("The jq view cannot be combined with other views");let t=e[0];if(t===void 0||t==="jq"||t.slice(3).trim().length===0)throw new Error('The jq view requires a filter, for example views: ["jq:.scripts"]');return{filter:t.slice(3)}}o(_,"parseJqView");function A(r,e,t){return t.signal?.aborted===!0?Promise.reject(new Error("jq execution was cancelled")):new Promise((i,d)=>{let s=C(t.command??"jq",["-L",k,"--",r],{cwd:t.cwd,env:V(t.cwd),shell:!1,stdio:["pipe","pipe","pipe"],windowsHide:!0}),a="",l="",u=!1,m=0,c=o(n=>{u||(u=!0,clearTimeout(p),t.signal?.removeEventListener("abort",g),n===void 0?i(a):d(n))},"finish"),f=o(n=>{s.kill(),c(n)},"stop"),g=o(()=>f(new Error("jq execution was cancelled")),"abort"),p=setTimeout(()=>f(new Error(`jq did not finish within ${b/1e3} seconds`)),b);p.unref(),t.signal?.addEventListener("abort",g,{once:!0}),s.stdout?.setEncoding("utf8"),s.stderr?.setEncoding("utf8"),s.stdout?.on("data",n=>{if(m+=Buffer.byteLength(n),m>J){f(new Error(`jq output exceeded ${J/1024/1024}MB`));return}a+=n}),s.stderr?.on("data",n=>{Buffer.byteLength(l)<16384&&(l+=n)}),s.once("error",n=>c(new Error(`Cannot start jq: ${n.message}`))),s.once("close",(n,w)=>{if(!u)if(n===0)c();else{let I=l.trim().split(/\r?\n/u).slice(0,8).join(`
|
|
2
|
+
`);c(new Error(I||`jq exited ${w===null?`with code ${String(n)}`:`after signal ${w}`}`))}}),s.stdin?.once("error",n=>c(new Error(`Cannot send JSON to jq: ${n.message}`))),s.stdin?.end(e)})}o(A,"executeJq");function V(r){let e=j(r,process.env),t={};for(let i of["PATH","PATHEXT","SystemRoot","SYSTEMROOT","WINDIR"])e[i]!==void 0&&(t[i]=e[i]);return t}o(V,"safeEnvironment");async function N(r){x(r,[await P({id:"json-reading",description:"Query and transform JSON resources with jq read views",triggers:[{tool:"read",viewPrefixes:["jq:"]}]})]),await Promise.all([S(r,B),T(r,$)])}o(N,"registerFilesystemJq");var B={protocol:R,apiVersion:O,id:"filesystem-jq",setup(r){r.addView({view:"jq",presenter:{id:"filesystem-jq",present:o(e=>e,"present")}}),r.addHandler({stage:"read",when:{resolvedBy:"filesystem",contentKind:"text"},async handler(e){let t=e.state;if(t?.contentKind!=="text")return{kind:"continue",context:e};let i;try{i=_(e.request.views)}catch(a){return D(t,a instanceof Error?a.message:String(a))}if(i===void 0)return{kind:"continue",context:e};let d;try{d=await A(i.filter,t.content[0].text,{cwd:e.resolverContext.cwd,...e.resolverContext.signal===void 0?{}:{signal:e.resolverContext.signal}})}catch(a){return D(t,a instanceof Error?a.message:String(a))}let s={...t,content:[{type:"text",text:d}],text:q(t.source,d),preserveTruncatedOutput:!0};return{kind:"continue",context:{...e,state:s}}}}),r.describe('JSON files accept views such as ["jq:.scripts | keys"] to query them with the installed jq executable.')}};function D(r,e){return{kind:"return",result:{content:[{type:"text",text:`jq failed: ${e}`}],details:{source:r.source,resolvedBy:r.resolvedBy,failure:{code:"READ_FAILED",source:r.source,resolverId:r.resolvedBy,pluginId:"filesystem-jq",stage:"read",message:e}},isError:!0}}}o(D,"jqFailure");var $={protocol:E,apiVersion:1,id:"filesystem-jq",setup(r){r.addSetupCheck({id:"jq",async inspect(e){return await v("jq",e.cwd,e.env)?{}:{actions:[{id:"jq-unavailable",message:"JSON jq views are unavailable because jq was not found"}]}}}),r.addCheck({id:"jq",title:"JSON jq views",async run(e){let t=await y("jq",["--version"],e.cwd,e.env);return[t.ok?{status:"pass",message:"jq is available",detail:t.detail}:{status:"fail",message:"jq is not available",detail:t.detail}]}})}};export{N as default};
|
package/dist/entry-28.js
CHANGED
|
@@ -1,12 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`,`
|
|
3
|
-
`).split(`
|
|
4
|
-
`));n.push(i===void 0?{status:"fail",message:`${r} parser did not return a tree`}:{status:"pass",message:`${r} parser loaded`,detail:s})}catch(o){n.push({status:"fail",message:`${r}: ${o instanceof Error?o.message:String(o)}`})}}return n.length>0?n:[{status:"skip",message:"No supported AST files found"}]}}),a.addCheck({id:"ast-grep",title:"Structural search",async run(e){if(![...e.detectedLanguageIds].some(r=>y.has(r)))return[{status:"skip",message:"No supported structural-search files found"}];let n=await x("ast-grep",["--version"],e.cwd,e.env);return[n.ok?{status:"pass",message:"ast-grep is available",detail:n.detail}:{status:"fail",message:"ast-grep is not available",detail:n.detail}]}})}};function re(a,e){let n=a.slice(a.lastIndexOf(".")).toLowerCase();return{c:[".c",".h"],cpp:[".cc",".cpp",".cxx",".hh",".hpp",".hxx"],csharp:[".cs"],css:[".css",".scss",".less"],dart:[".dart"],elixir:[".ex",".exs"],go:[".go"],html:[".html",".htm"],java:[".java"],kotlin:[".kt",".kts"],lua:[".lua"],markdown:[".md",".mdx"],php:[".php"],ruby:[".rb",".rake"],scala:[".scala",".sc"],shell:[".sh",".bash"],sql:[".sql"],swift:[".swift"],javascript:[".js",".jsx",".mjs",".cjs"],typescript:[".ts",".tsx",".mts",".cts"],python:[".py",".pyi"],rust:[".rs"],json:[".json",".jsonc"],yaml:[".yaml",".yml"],toml:[".toml"]}[e]?.includes(n)??!1}d(re,"matchesLanguage");var se,ae;function F(a){return{id:"ast",tryResolve(e,n){return Promise.resolve(oe(e,n,a))}}}d(F,"createAstOutlineResolver");function oe(a,e,n){let r;try{r=S(a,"ast")}catch(o){return{kind:"failed",error:o}}if(r===void 0)return{kind:"not-handled"};let t;try{t=R(r.path,e.cwd)}catch(o){return{kind:"failed",error:o}}return{kind:"resolved",resource:{source:w("ast",t),async read({signal:o}){o?.throwIfAborted();let i=await(ae??=import("./chunk-5QQABP47.js")),l=await(n??(se??=new i.AstOutlineManager)).readFileOutline(t,e.cwd);return o?.throwIfAborted(),[i.formatAstOutline(l)]}}}}d(oe,"resolveAstOutlineSource");import{DEFAULT_MAX_BYTES as ie,DEFAULT_MAX_LINES as ce,truncateHead as A}from"@earendil-works/pi-coding-agent";var b=d(async(a,e,n)=>{let{source:r,resolvedBy:t,lines:s,totalLines:o,startLine:i}=a.details;if(!(r===void 0||t!=="filesystem"||s===void 0||s.length!==o||i!==void 0&&i!==1))try{let{AstOutlineManager:c,isSupportedOutlinePath:l}=await import("./chunk-5QQABP47.js");if(!l(r))return;let u=d(m=>[`AST overview of ${m.path}, source lines 1-${m.totalLines}: the requested text exceeded the read buffer.`,"Source line numbers are on the left. Detail is reduced to fit the buffer; omitted bodies are not exact source text. Read a small source range when needed.",...m.renderedLines.map(g=>`${g.sourceLine?.lineNumber??"\u2026"} | ${g.text}`)].join(`
|
|
5
|
-
`),"format");e.signal?.throwIfAborted();let p=await new c(12).readDocumentOutline(r,e.cwd,s.map(m=>m.content),m=>(e.signal?.throwIfAborted(),!A(u(m),n).truncated)),f=u(p);return A(f,n).truncated?void 0:{content:[{type:"text",text:f}],details:{source:r,resolvedBy:"ast-overflow"}}}catch{e.signal?.throwIfAborted();return}},"reduceAstReadOutput");function z(){return async a=>{let{state:e,result:n}=a,r=n?.content.length===1?n.content[0]:void 0;if(a.audience==="script"||n===void 0||e?.contentKind!=="text"||e.resolvedBy!=="filesystem"||r?.type!=="text"||!A(r.text).truncated)return{kind:"continue",context:a};let t=await b({...n,details:{...n.details,source:e.source,resolvedBy:e.resolvedBy,lines:e.text.lines,startLine:1,totalLines:e.text.lines.length}},a.resolverContext,{maxBytes:ie,maxLines:ce});return t===void 0?{kind:"continue",context:a}:{kind:"return",result:t}}}d(z,"createAstOverflowHandler");var X="pi-agent-ast";function K(a){return{id:"ast-scopes",async present(e,n){if(n.resolvedBy!=="filesystem")return e;try{let r=await a.getDocumentScopes(e.source,n.cwd,e.lines.map(s=>s.content)),t=de(e.lines,r);return t===e.lines?e:{...e,lines:t}}catch{return e}}}}d(K,"createAstScopePresenter");function U(){return a=>{let e=a.state,n=a.result;if(e?.contentKind!=="text"||n===void 0)return{kind:"continue",context:a};let r=n.details.lines;if(r===void 0)return{kind:"continue",context:a};let t=new Map(e.text.lines.map(u=>[u.lineNumber,u])),s=new Set(r.map(u=>u.lineNumber)),o=new Map;for(let u of r){let p=t.get(u.lineNumber),f=q(p);for(let m of f?.boundaries??[]){if(s.has(m.endLine))continue;let g=t.get(m.endLine);g!==void 0&&o.set(m.endLine,g)}}if(o.size===0)return{kind:"continue",context:a};let i=[...o.values()].sort((u,p)=>u.lineNumber-p.lineNumber),c=[...r,...i],l=le(n,c,r.at(-1));return{kind:"continue",context:{...a,result:l}}}}d(U,"createAstScopePostReadHandler");function de(a,e){if(e.length===0)return a;let n=new Map,r=new Map;for(let t of e){let s=n.get(t.startLine)??[];s.push(t.beginAnchor.value),n.set(t.startLine,s);let o=r.get(t.startLine)??[];o.push({endLine:t.endLine,beginAnchor:t.beginAnchor.value,endAnchor:t.endScopeAnchor.value}),r.set(t.startLine,o);let i=n.get(t.endLine)??[];i.push(t.endScopeAnchor.value),n.set(t.endLine,i)}return a.map(t=>{let s=n.get(t.lineNumber),o=r.get(t.lineNumber);return s===void 0&&o===void 0?t:{...t,...s!==void 0&&{anchors:[...new Set([...t.anchors??[],...s])],presentation:{...t.presentation,suffix:`${t.presentation?.suffix??""}${s.map(i=>` <!-- ${i} -->`).join("")}`}},metadata:{...t.metadata,[X]:{...q(t),...o!==void 0&&{boundaries:o}}}}})}d(de,"addScopeMarkers");function q(a){let e=a?.metadata?.[X];if(!(typeof e!="object"||e===null))return e}d(q,"getAstScopeMetadata");function le(a,e,n){let r=a.content.length===1?a.content[0]:void 0;if(r?.type!=="text"||a.details.lines===void 0)return a;let t=e.slice(a.details.lines.length);if(t.length===0)return a;let s=n?.lineEnding!==void 0&&n.lineEnding.length>0?n.lineEnding:t[0]?.lineEnding!==void 0&&t[0].lineEnding.length>0?t[0].lineEnding:`
|
|
6
|
-
`,o=t.map((l,u)=>{let f=u===t.length-1?l.lineEnding:l.lineEnding||s,m=l.presentation?.prefix??"",g=l.presentation?.suffix??"";return`${m}${l.content}${g}${f}`}).join(""),i=/(?:\r\n|\r|\n)$/.test(r.text)?"":s,c=`${r.text}${i}${o}`;return{...a,content:[{...r,text:c}],details:{...a.details,lines:e}}}d(le,"appendTextLines");var W=/^scope-(begin|end)-[A-Z0-9]{3,4}(?:-[1-9]\d*)?$/;function J(a){return{id:"ast-scope",description:'`scope-begin-HASH` / `scope-end-HASH` from read views: ["ast"] \u2014 first/last lines of a scope. Any numeric suffix is part of the anchor.',renderFull(e){return e},renderCompact(e){return W.exec(e)?.[1]==="begin"?"scope start":"scope end"},async tryResolve(e,n){if(!W.test(e))return{kind:"not-handled"};try{let t=(await a.getDocumentScopes(n.source,n.cwd,n.lines)).find(s=>s.beginAnchor.value===e||s.endScopeAnchor.value===e);return t===void 0?{kind:"rejected",rejection:{code:"stale",reason:`AST scope anchor ${e} is stale`}}:{kind:"resolved",anchor:t.beginAnchor.value===e?t.beginAnchor:t.endScopeAnchor}}catch(r){return{kind:"failed",error:r}}}}}d(J,"createAstScopeAnchorResolver");import ue from"cross-spawn";import{readFile as pe,stat as Y}from"node:fs/promises";import h from"node:path";function Q(a){return{id:"ast",async tryResolve(e,n){if(!e.query.startsWith("ast:"))return{kind:"not-handled"};let r=e.query.slice(4).trim();if(r.length===0)return{kind:"failed",error:new Error("ast: pattern must not be empty")};let t=d(async i=>{let c=await me(r,e,n.cwd,i);c.sort((u,p)=>h.resolve(n.cwd,u.file).localeCompare(h.resolve(n.cwd,p.file))||u.range.byteOffset.start-p.range.byteOffset.start||u.range.byteOffset.end-p.range.byteOffset.end);let l=c.slice(0,e.limit??100);return{raw:l,matches:await fe(l,n.cwd,i),complete:c.length<=(e.limit??100)}},"collect"),s=await t(n.signal),o=await a({request:e,matches:s.matches,complete:s.complete,refresh:t},n);return{kind:"resolved",payload:{pattern:r,matches:s.raw.map((i,c)=>({...i,selection:s.matches[c]})),complete:s.complete,sessionId:o.id}}},format(e){let n=e;if(n.matches.length===0)return{content:[{type:"text",text:"No AST matches found."}],details:n};let r=n.matches.flatMap((t,s)=>[`SEARCH#${n.sessionId}:${String(s+1)}:match ${t.file}:${String(t.range.start.line+1)}:${String(t.range.start.column+1)} ${t.language}`,` ${t.lines.trim()}`]);return n.complete&&r.unshift(`SEARCH#${n.sessionId}:all:match selects all exact AST matches.`),n.complete||r.push("Result limit reached."),{content:[{type:"text",text:r.join(`
|
|
7
|
-
`)}],details:n}}}}d(Q,"createAstSearchResolver");async function fe(a,e,n){let r=new Map;for(let t of a){let s=h.resolve(e,t.file);if(r.has(s))continue;let o=await Y(s),i=await pe(s,{signal:n}),c=await Y(s);if(o.mtimeMs!==c.mtimeMs||o.size!==c.size)throw new Error("AST source changed during search. Run the structural query again.");r.set(s,i)}return a.map(t=>{let s=h.resolve(e,t.file),o=r.get(s);if(o===void 0)throw new Error("Missing AST source snapshot");let{start:i,end:c}=t.range.byteOffset;if(!Number.isInteger(i)||!Number.isInteger(c)||i<0||c<i||c>o.length||o.subarray(i,c).toString("utf8")!==t.text)throw new Error("AST range does not match its source snapshot. Search again.");let l=o.subarray(0,i).toString("utf8"),u=o.subarray(0,c).toString("utf8"),p=l.split(`
|
|
8
|
-
`).length;return{source:s,lineNumber:p,endLineNumber:u.split(`
|
|
9
|
-
`).length,startColumn:l.length-l.lastIndexOf(`
|
|
10
|
-
`)-1,endColumn:u.length-u.lastIndexOf(`
|
|
11
|
-
`)-1,matchedText:t.text,lineText:o.toString("utf8").split(`
|
|
12
|
-
`)[p-1]?.replace(/\r$/u,"")??""}})}d(fe,"selectionMatches");function me(a,e,n,r){let t=["run","--pattern",a,"--json=compact","--no-ignore","parent"];for(let s of Z(e.include))t.push("--globs",s);for(let s of Z(e.exclude))t.push("--globs",`!${s}`);return t.push(e.path??"."),new Promise((s,o)=>{let i=ue("ast-grep",t,{cwd:n,stdio:["ignore","pipe","pipe"]}),c="",l="";i.stdout.setEncoding("utf8"),i.stderr.setEncoding("utf8"),i.stdout.on("data",p=>c+=p),i.stderr.on("data",p=>l+=p);let u=d(()=>{i.kill("SIGTERM")},"abort");r?.addEventListener("abort",u,{once:!0}),i.once("error",o),i.once("close",p=>{if(r?.removeEventListener("abort",u),r?.aborted===!0){o(r.reason instanceof Error?r.reason:new Error("AST search aborted"));return}if(p!==0&&p!==1){o(new Error(l.trim()||`ast-grep exited with code ${String(p)}`));return}try{let f=JSON.parse(c.length===0?"[]":c);if(!Array.isArray(f))throw new TypeError("ast-grep returned non-array JSON");s(f)}catch(f){o(f instanceof Error?f:new Error(String(f)))}})})}d(me,"runAstGrep");function Z(a){return a?.split(",").map(e=>e.trim()).filter(Boolean)??[]}d(Z,"splitGlobs");var ge=$({kind:"code-view",label:"AST"});async function ee(a){let e=new V,n=K(e),r={protocol:k,apiVersion:P,id:"ast",setup(s){s.addResolver({resolver:F(),renderResult:ge}),s.addHandler({stage:"read",when:{resolvedBy:"ast",contentKind:"text"},handler:v()}),s.addView({view:"ast",presenter:n});let o=z();s.addOutputReducer(b);let i=U();s.addHandler({stage:"post-read",async handler(c){let l=await o(c);return l.kind==="return"?l:i(l.context)}}),s.describe('ast:<path> \u2014 compact declaration outline. views: ["ast"] \u2014 scope boundaries alongside source text. Oversized code reads may return an outline with source line numbers; offset/limit read a smaller source range.')}},t={protocol:I,apiVersion:C,id:"ast",setup(s){s.addAnchorResolver({resolver:J(e),kind:N,type:"auxiliary"}),s.addTextPresenter({presenter:n})}};await Promise.all([M(a,r),E(a,G),_(a,t),B(a,{protocol:H,apiVersion:j,id:"ast-search",setup(s){s.addResolver({resolver:Q(s.registerSelection)}),s.describe("Search code structure with ast:<pattern>, using source-code syntax and placeholders such as $NAME for one node and $$$BODY for several nodes. path, include and exclude narrow the search. Use returned SEARCH# references to read, replace, copy, move or delete exact AST matches, including multiline nodes. A single :match reference becomes stale after its file changes; :all:match reruns the original structural query. Incomplete results do not provide all selections. Use captures in Apply to compute replacement text; these edits do not update imports or references.")}})])}d(ee,"registerAst");export{ee as default};
|
|
1
|
+
import{a as r}from"./chunk-BHSO2MDK.js";import{v as e}from"./chunk-S3ZPXWX7.js";import{a as t}from"./chunk-EI7MMDWY.js";var n={target:{provider:"filesystem",capability:"read"},converter:r(),priority:200};async function i(o){await e(o,n)}t(i,"registerFilesystemPdf");export{i as default};
|
package/dist/entry-29.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{v as t}from"./chunk-S3ZPXWX7.js";import{p as i}from"./chunk-5VSE5X5R.js";import{a as r}from"./chunk-EI7MMDWY.js";var o=i(),n={target:{provider:"filesystem",capability:"read"},converter:o,priority:300},s={target:{provider:"filesystem",capability:"write"},converter:o,priority:300};async function a(e){await Promise.all([t(e,n),t(e,s)])}r(a,"registerFilesystemText");export{a as default};
|
package/dist/entry-30.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as V,b as z,c as Q}from"./chunk-DEP55R35.js";import{a as O}from"./chunk-MGCHOGQD.js";import{a as L,b as N}from"./chunk-T6LX2RX5.js";import{a as B}from"./chunk-L7JMDDSD.js";import{a as M,b as _}from"./chunk-O6LE42GK.js";import{a as j}from"./chunk-6CZO43OH.js";import{a as U,b as F}from"./chunk-OBNING2A.js";import"./chunk-S3ZPXWX7.js";import{a as H}from"./chunk-5VSE5X5R.js";import{d as $,e as D}from"./chunk-N34ATN52.js";import{a as x}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import{Value as De}from"typebox/value";import{access as ne}from"node:fs/promises";import re from"node:path";var K={protocol:L,apiVersion:1,id:"changes",setup(n){n.addSetupCheck({id:"git",async inspect(e){return await oe(e.cwd)?await $("git",e.cwd,e.env)?{}:{actions:[{id:"git-unavailable",message:"Git integration is unavailable because Git was not found"}]}:{}}}),n.addCheck({id:"git",title:"Git changes",async run(e){let t=await D("git",["--version"],e.cwd,e.env);return[t.ok?{status:"pass",message:"Git is available",detail:t.detail}:{status:"warn",message:"Git is not available; change anchors and index tools are disabled",detail:t.detail}]}})}};async function oe(n){try{return await ne(re.join(n,".git")),!0}catch{return!1}}s(oe,"isGitProject");import{mkdtemp as ae,rm as ie,writeFile as se}from"node:fs/promises";import de from"node:os";import m from"node:path";var b=class n{constructor(e,t){this.executor=e;this.repositoryRoot=t}static{s(this,"GitChangesBackend")}static async create(e,t,r){let o=await e.exec("git",["rev-parse","--show-toplevel"],{cwd:t,...r!==void 0&&{signal:r}});return o.code!==0?{status:"unavailable",reason:"no-worktree",message:o.stderr.trim()||"not inside a Git worktree"}:{status:"ready",backend:new n(e,m.resolve(o.stdout.trim()))}}async readTrackedFile(e,t,r){let o=m.resolve(t,e),a=m.relative(this.repositoryRoot,o);return a===".."||a.startsWith(`..${m.sep}`)||m.isAbsolute(a)?{status:"unavailable",reason:"outside-worktree",message:`${o} is outside ${this.repositoryRoot}`}:this.readTrackedRepositoryFile(a.split(m.sep).join("/"),r)}async readTrackedRepositoryFile(e,t){let r=await this.git(["rev-parse","--verify","HEAD"],t);if(r.code!==0)return{status:"unavailable",reason:"missing-head",message:r.stderr.trim()||"Git HEAD does not exist"};let o=await this.git(["--literal-pathspecs","ls-tree","-z","HEAD","--",e],t);if(o.code!==0)return{status:"unavailable",reason:"head-file-lookup-failed",message:o.stderr.trim()||`could not inspect HEAD:${e}`};let a=ce(o.stdout);if(a===void 0)return{status:"untracked"};let i=await this.readBlob(a.blob,"HEAD",e,t);if(i.status!=="found")return i;let c=await this.git(["--literal-pathspecs","ls-files","--stage","-z","--",e],t);if(c.code!==0)return{status:"unavailable",reason:"index-file-lookup-failed",message:c.stderr.trim()||`could not inspect the index entry for ${e}`};let d=ue(c.stdout);if(d.some(({stage:g})=>g!==0))return{status:"unavailable",reason:"conflicted",message:`${e} has unresolved Git index entries`};let u=d.find(({stage:g})=>g===0),l="";if(u!==void 0){let g=await this.readBlob(u.blob,"index",e,t);if(g.status!=="found")return g;l=g.text}return{status:"found",head:r.stdout.trim(),repositoryPath:e,repositoryRoot:this.repositoryRoot,headText:i.text,indexText:l,indexMode:u?.mode??a.mode}}async writeIndexFile(e,t,r,o){let a=await ae(m.join(de.tmpdir(),"pi-agent-index-")),i=m.join(a,"content");try{await se(i,r,"utf8");let c=await this.git(["hash-object","-w",`--path=${e}`,i],o);if(c.code!==0||c.stdout.trim().length===0)throw new Error(c.stderr.trim()||`could not write a Git blob for ${e}`);let d=await this.git(["update-index","--add","--cacheinfo",t,c.stdout.trim(),e],o);if(d.code!==0)throw new Error(d.stderr.trim()||`could not update the Git index entry for ${e}`)}finally{await ie(a,{recursive:!0,force:!0})}}async readBlob(e,t,r,o){let a=await this.git(["cat-file","blob",e],o);return a.code!==0?{status:"unavailable",reason:t==="HEAD"?"head-file-lookup-failed":"index-file-lookup-failed",message:a.stderr.trim()||`could not read ${t}:${r}`}:{status:"found",text:a.stdout}}git(e,t){return this.executor.exec("git",e,{cwd:this.repositoryRoot,...t!==void 0&&{signal:t}})}};function ce(n){let e=n.split("\0",1)[0];if(e===void 0||e.length===0)return;let t=e.indexOf(" ");if(t===-1)return;let[r,o,a]=e.slice(0,t).split(" ",3);return r===void 0||o!=="blob"||a===void 0?void 0:{mode:r,blob:a,path:e.slice(t+1)}}s(ce,"parseTreeEntry");function ue(n){return n.split("\0").filter(Boolean).flatMap(e=>{let t=e.indexOf(" ");if(t===-1)return[];let[r,o,a]=e.slice(0,t).split(" ",3),i=Number(a);return r===void 0||o===void 0||!Number.isInteger(i)?[]:[{mode:r,blob:o,stage:i,path:e.slice(t+1)}]})}s(ue,"parseIndexEntries");function W(n){return{exec:s((e,t,r)=>n.exec(e,t,r),"exec")}}s(W,"extensionGitExecutor");var f=class n{constructor(e){this.git=e}static{s(this,"ChangeService")}static async create(e,t,r){let o=await b.create(e,t,r);return o.status==="unavailable"?o:{status:"ready",service:new n(o.backend)}}async inspect(e){if(e.worktreeText.includes("\0"))return{status:"unavailable",reason:"binary",message:"worktree file contains binary content"};let t=await this.git.readTrackedFile(e.source,e.cwd,e.signal);if(t.status!=="found")return t.status==="untracked"?{status:"not-applicable",reason:"untracked"}:t;if(t.headText.includes("\0")||t.indexText.includes("\0"))return{status:"unavailable",reason:"binary",message:"Git file state contains binary content"};let r=V(t.repositoryPath,t.headText,t.indexText,e.worktreeText);return r.length===0?{status:"not-applicable",reason:"clean"}:{status:"applicable",head:t.head,repositoryRoot:t.repositoryRoot,repositoryPath:t.repositoryPath,groups:r}}async changeIndex(e,t,r){let o=await this.inspect(e);if(o.status!=="applicable")return o;let a=o.groups.find(u=>u.selector===t);if(a===void 0)return A(t,o.groups.map(({selector:u})=>u));let i=r==="stage"?"staged":"unstaged";if(a.state===i)return{status:"unchanged",state:i,group:a};let c=x(a.segments[0]),d={head:o.head,repositoryPath:o.repositoryPath,headStart:c.headStart,headEnd:c.headEnd,replacementText:r==="stage"?c.worktreeText:c.headText};try{await this.applyIndexUpdate(d,e.signal)}catch(u){return{status:"unavailable",reason:"index-write-failed",message:le(u)}}return{status:"applied",state:i,group:a}}async prepareUndo(e,t){let r=await this.inspect(e);if(r.status!=="applicable")return r;let o=r.groups.find(d=>d.selector===t);if(o===void 0)return A(t,r.groups.map(({selector:d})=>d));let a=z(e.worktreeText,o);if(a===void 0)return A(t,r.groups.map(({selector:d})=>d));let i=x(o.segments[0]),c=o.state==="unstaged"?void 0:{head:r.head,repositoryPath:r.repositoryPath,headStart:i.headStart,headEnd:i.headEnd,replacementText:i.headText};return{status:"applied",worktreeText:a,group:o,...c!==void 0&&{indexUpdate:c}}}async applyIndexUpdate(e,t){let r=await this.git.readTrackedRepositoryFile(e.repositoryPath,t);if(r.status!=="found")throw new Error(r.status==="untracked"?`${e.repositoryPath} is no longer tracked by HEAD`:r.message);if(r.head!==e.head)throw new Error(`Git HEAD changed while updating ${e.repositoryPath}`);let o=Q(r.headText,r.indexText,e.headStart,e.headEnd,e.replacementText);o!==r.indexText&&await this.git.writeIndexFile(e.repositoryPath,r.indexMode,o,t)}};function A(n,e){return{status:"unavailable",reason:"stale-selector",message:`${n} is not available in the current file state`,availableSelectors:e}}s(A,"staleSelector");function le(n){return n instanceof Error?n.message:String(n)}s(le,"errorMessage");var T="pi-agent-ide-changes/change",ge=/^CHANGE#[0-9A-F]{4,64}$/,pe=/^[A-Za-z][A-Za-z\d+.-]*:\/\//,G=class extends H{static{s(this,"ChangeTextAnchor")}constructor(e){super(e.selector,e.currentStartLine)}};function Y(n){return{resolver:fe(s(async t=>{if(pe.test(t.source))return;let r=await f.create(n,t.cwd,t.signal);if(r.status!=="ready")throw new Error(r.message);return r.service.inspect({source:t.source,worktreeText:t.content,cwd:t.cwd,...t.signal!==void 0&&{signal:t.signal}})},"inspect"))}}s(Y,"createChangeAnchorRegistration");function fe(n){return{id:"git-change",description:"Use the complete `CHANGE#HASH` shown beside a current Git change.",renderFull(e){return e},renderCompact(e){return e},async tryResolve(e,t){if(!ge.test(e))return{kind:"not-handled"};try{let r=await n(t);if(r===void 0)return{kind:"not-handled"};if(r.status==="unavailable")return{kind:"failed",error:new Error(r.message)};let o=r.status==="applicable"?r.groups.find(a=>a.selector===e):void 0;return o===void 0?{kind:"rejected",rejection:{code:"stale",reason:`Change anchor ${e} is stale or unknown`}}:{kind:"resolved",anchor:new G(o)}}catch(r){return{kind:"failed",error:r}}}}}s(fe,"createChangeAnchorResolver");import{diffLines as he}from"diff";var me="filesystem";function q(n){return{id:"current-git-changes",async present(e,t){if(t.purpose!=="read"||t.resolvedBy!==me)return e;let r=await f.create(n,t.cwd,t.signal);if(r.status!=="ready")return e;let o=await r.service.inspect({source:t.source,worktreeText:e.content,cwd:t.cwd,...t.signal!==void 0&&{signal:t.signal}});return o.status!=="applicable"?e:ye(e,o.groups)}}}s(q,"createCurrentChangePresenter");function ye(n,e){let t=new Map;for(let r of e)xe(n,r,t);return{...n,lines:n.lines.map(r=>be(r,t.get(r.lineNumber)))}}s(ye,"presentChangeGroups");function xe(n,e,t){let r=x(e.segments[0]),o=he(r.headText,r.worktreeText),a=e.currentStartLine,i,c;for(let d of o){let u=ve(d.value);if(d.removed){let l=Te(n,a),g=R(t,l.lineNumber),p=l.after?g.after:g.before;for(let h of u){let w={kind:"synthetic",rows:p,index:p.length};p.push({marker:"-",prefix:"|",content:h}),i??=w,c=w}continue}if(d.added){for(let l of u){let g=R(t,a),p={kind:"current",lineNumber:a};g.added=!0,i??=p,c=p,a++}continue}a+=u.length}if(i!==void 0&&c!==void 0){let d=`${e.selector} \xB7 ${e.state}`;we(i,c)?I(t,i,`<!-- change: ${d} -->`):(I(t,i,`<!-- change-begin: ${d} -->`),I(t,c,`<!-- change-end: ${d} -->`))}}s(xe,"presentChangeGroup");function we(n,e){return n.kind==="current"&&e.kind==="current"?n.lineNumber===e.lineNumber:n.kind==="synthetic"&&e.kind==="synthetic"?n.rows===e.rows&&n.index===e.index:!1}s(we,"sameTarget");function I(n,e,t){if(e.kind==="current"){R(n,e.lineNumber).annotations.push(t);return}let r=x(e.rows[e.index]);e.rows[e.index]={...r,suffix:`${r.suffix??""} ${t}`}}s(I,"annotateTarget");function be(n,e){if(e===void 0)return n;let t=e.annotations.length===0?"":` ${e.annotations.join(" ")}`;return{...n,presentation:{...n.presentation,...e.added&&{marker:"+"},before:[...n.presentation?.before??[],...e.before],after:[...e.after,...n.presentation?.after??[]],suffix:`${n.presentation?.suffix??""}${t}`}}}s(be,"presentLine");function R(n,e){let t=n.get(e);if(t!==void 0)return t;let r={before:[],after:[],annotations:[],added:!1};return n.set(e,r),r}s(R,"presentationsFor");function Te(n,e){return e<=n.lines.length?{lineNumber:Math.max(1,e),after:!1}:{lineNumber:n.lines.length,after:!0}}s(Te,"placementFor");function ve(n){if(n.length===0)return[];let e=n.split(/\r\n|\r|\n/u);return e.at(-1)===""&&e.pop(),e}s(ve,"splitLines");var v=class{static{s(this,"IndexMutationQueue")}tail=Promise.resolve();run(e){let t=this.tail.then(e,e);return this.tail=t.then(()=>{},()=>{}),t}};import{createHash as Ce}from"node:crypto";import{realpathSync as ke}from"node:fs";import J from"node:path";import{fileURLToPath as Ee}from"node:url";var k=class{static{s(this,"LastTextTransactionStore")}#e=new Map;observe(e){let t=X(e.resourceSource,e.cwd);if(e.postProcessing==="final"){let r=this.#e.get(t);r&&r.afterDigest===C(e.before.content)?this.#e.set(t,{...r,afterDigest:C(e.after.content)}):this.#e.delete(t);return}if(e.intent!=="edit"||!e.existed||e.before.content===e.after.content){this.#e.delete(t);return}this.#e.set(t,{before:e.before.content,afterDigest:C(e.after.content)})}restore(e,t,r){let o=X(e,t),a=this.#e.get(o);if(a===void 0)throw new Error(`No last text transaction is available for ${e}.`);if(a.afterDigest!==C(r))throw this.#e.delete(o),new Error(`${e} changed after its last text transaction; refusing to overwrite newer text.`);return a.before}};function X(n,e){return n.startsWith("file://")?Z(Ee(new URL(n))):/^[a-z][a-z\d+.-]*:/iu.test(n)?n:Z(J.resolve(e,n))}s(X,"sourceKey");function Z(n){try{return ke.native(n)}catch{return J.normalize(n)}}s(Z,"canonicalFile");function C(n){return Ce("sha256").update(n).digest("hex")}s(C,"textDigest");import{readFile as Pe}from"node:fs/promises";import Ae from"node:path";import{defineTool as Ge,withFileMutationQueue as Ie}from"@earendil-works/pi-coding-agent";import{Type as S}from"typebox";var P=S.Object({file:S.String({description:"Path to the tracked text file"}),change:S.String({description:"Complete CHANGE#HASH anchor shown by read",pattern:"^CHANGE#[0-9A-F]{4,64}$"})},{additionalProperties:!1});function ee(n,e,t){n.registerTool(E("stage",e,t)),n.registerTool(E("unstage",e,t))}s(ee,"registerIndexChangeTools");function E(n,e,t){let r=n==="stage"?"staged":"unstaged",o=n==="stage"?"Staged":"Unstaged";return Ge({name:n,label:n,promptSnippet:`${o.slice(0,-1)} a selected Git change`,description:`Use ${n} to ${n==="stage"?"add one current Git change to the index":"remove one current Git change from the index"}. Select the change with a CHANGE# anchor; worktree content is kept.`,parameters:P,async execute(a,i,c,d,u){let l=Re(i.file,u.cwd);return Ie(l,()=>t.run(async()=>{let g=await Pe(l,"utf8"),p=await f.create(e,u.cwd,c);if(p.status!=="ready")throw new Error(p.message);let h=await p.service.changeIndex({source:l,worktreeText:g,cwd:u.cwd,...c!==void 0&&{signal:c}},i.change,n);if(h.status==="unavailable")throw new Error(h.message);if(h.status==="not-applicable")throw new Error(`${n} is not applicable to ${l}: ${h.reason}`);let w=h.status==="unchanged";return{content:[{type:"text",text:w?`${i.change} is already ${r} in ${i.file}.`:`${o} ${i.change} in ${i.file}.`}],details:{action:n,change:i.change,file:l,state:r,unchanged:w}}}))}})}s(E,"createIndexChangeTool");function Re(n,e){let t=n.startsWith("@")?n.slice(1):n;return Ae.resolve(e,t)}s(Re,"resolveFile");import{diffChars as Se}from"diff";import{Type as y}from"typebox";var He=y.Object({file:y.Optional(y.String({description:"File to restore; may be omitted to inherit the previous batched source"})),change:y.Optional(y.String({description:"Complete CHANGE#HASH anchor shown by read, or last for this file's latest text-editor transaction",pattern:"^(?:CHANGE#[0-9A-F]{4,64}|last)$"})),transaction:y.Optional(y.String({description:"APPLY# receipt returned by a successful Apply transaction",pattern:"^APPLY#[0-9A-F]{12}$"}))},{additionalProperties:!1});function te(n,e,t,r){return{name:"undo",description:"Use undo to revert an APPLY# transaction receipt, a selected uncommitted Git change, or the latest text-editor transaction for one file. Apply receipts restore every touched path atomically; CHANGE# restores that change to HEAD in both worktree and index; last restores one file's latest text edit.",promptSnippet:"Restore an Apply transaction, Git change, or latest text edit",direct:{matches:s(o=>o!==null&&typeof o=="object"&&"transaction"in o&&typeof o.transaction=="string","matches"),async execute(o,a){if(a.change!==void 0)throw new Error("transaction cannot be combined with change");let i=String(a.transaction),c=await r(i,o.signal);return{source:i,summary:`Restored ${String(c.restored.length)} paths from ${i}.`,data:{kind:"apply-undo",ok:!0,transaction:i,restored:c.restored}}}},parameters:He,intent:"restore",source:{field:"file",inherited:!0},anchors:[{field:"change",sourceField:"file",kinds:[T],nonAnchorValues:["last"]}],async mutate(o,a){if(a.change===void 0)throw new Error("change is required when transaction is omitted");let i=o.sourceFor("file"),c,d;if(a.change==="last")c=e.restore(i,o.cwd,o.sourceDocument.content);else{await o.resolveAnchor("change");let u=await f.create(n,o.cwd,o.signal);if(u.status!=="ready")throw new Error(u.message);let l=await u.service.prepareUndo({source:i,worktreeText:o.sourceDocument.content,cwd:o.cwd,...o.signal!==void 0&&{signal:o.signal}},a.change);if(l.status!=="applied")throw l.status==="unavailable"?new Error(l.message):new Error(`Undo is not applicable to ${i}: ${l.reason}`);if(c=l.worktreeText,l.indexUpdate!==void 0){let g=l.indexUpdate;d=s(()=>t.run(()=>u.service.applyIndexUpdate(g,o.signal)),"afterWrite")}}return{edits:new Map([[i,{changes:$e(o.sourceDocument.content,c),action:"edited"}]]),...d!==void 0&&{afterWrite:d}}}}}s(te,"createUndoMutationTool");function $e(n,e){let t=[],r=0,o,a=0,i="",c=s(()=>{o!==void 0&&(t.push({from:o,to:o+a,insert:i}),o=void 0,a=0,i="")},"flush");for(let d of Se(n,e)){if(!d.added&&!d.removed){c(),r+=d.value.length;continue}o??=r,d.removed?(r+=d.value.length,a+=d.value.length):i+=d.value}return c(),t}s($e,"createTextChanges");async function Le(n){let e=W(n),t=new k,r=new v,o=q(e),a=Y(e),i={protocol:U,apiVersion:F,id:"current-git-changes",setup(d){d.addView({view:"changes",presenter:o}),d.describe('views: ["changes"] \u2014 uncommitted edits in tracked files, staged/unstaged state, and CHANGE# anchors for stage, unstage and undo.')}},c={protocol:M,apiVersion:_,id:"current-git-changes",setup(d){d.addAnchorResolver({...a,kind:T,type:"auxiliary"}),d.onDidEdit(u=>{t.observe(u)}),d.addMutationTool(te(e,t,r,d.restoreApplyUndo));for(let u of["stage","unstage"]){let l=E(u,e,r);d.addScriptIndexOperation({name:u,parameters:P,execute:s((g,p,h)=>l.execute(`apply-${u}`,De.Decode(P,g),p,void 0,h),"execute")})}d.addTextPresenter({presenter:o})}};await Promise.all([O(n,K),j(n,i),B(n,c)]),ee(n,e,r)}s(Le,"registerGitChanges");export{Le as default};
|
|
1
|
+
import{b as e,c as o}from"./chunk-25CZ5ZIU.js";import"./chunk-5VSE5X5R.js";import"./chunk-EI7MMDWY.js";export{o as AstScopeManager,e as parseDocument};
|
package/dist/entry-31.js
CHANGED
|
@@ -1 +1,13 @@
|
|
|
1
|
-
import{a as P}from"./chunk-MGCHOGQD.js";import{a as F,b as R}from"./chunk-T6LX2RX5.js";import{a as j}from"./chunk-HKMBQLEK.js";import{a as h,b as v}from"./chunk-Z3VC3S2T.js";import{b as C,c as w,g as k,i as x,j as g,l as u,m as E}from"./chunk-M5MJP7Z2.js";import{a as b}from"./chunk-WZI4YC2O.js";import"./chunk-N34ATN52.js";import"./chunk-ZC65Z3CK.js";import{a as f}from"./chunk-EI7MMDWY.js";import{copyFile as $,mkdtemp as A,rm as M}from"node:fs/promises";import y from"node:path";var D=[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".json",".jsonc",".css",".scss",".html",".md",".yaml",".yml",".vue",".svelte"],z=[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".json",".jsonc",".css",".scss",".less",".html",".htm",".md",".markdown",".mdx",".yaml",".yml",".toml"],d=[e("dart-format",["dart"],["dart"],["pubspec.yaml","analysis_options.yaml"],[".dart"],["dart","format","{file}"],"https://dart.dev/tools/dart-format"),e("zig-format",["zig"],["zig"],["build.zig","build.zig.zon","zls.json"],[".zig",".zon"],["zig","fmt","{file}"],"https://ziglang.org/documentation/master/"),e("styler",["r"],["Rscript"],[".Rprofile","DESCRIPTION"],[".r"],["Rscript","-e","styler::style_file(commandArgs(TRUE)[1])","{file}"],"https://styler.r-lib.org/"),e("clang-format",["c","cpp"],["clang-format"],[".clang-format","_clang-format"],[".c",".h",".cc",".cpp",".cxx",".hh",".hpp",".hxx"],["clang-format","-i","{file}"],"https://clang.llvm.org/docs/ClangFormat.html"),e("prettier",["javascript","typescript","html","css","json","yaml","markdown","vue","svelte"],["prettier"],[".prettierrc",".prettierrc.json",".prettierrc.json5",".prettierrc.yaml",".prettierrc.yml",".prettierrc.toml",".prettierrc.js",".prettierrc.cjs",".prettierrc.mjs","prettier.config.js","prettier.config.cjs","prettier.config.mjs","prettier.config.ts","prettier.config.mts","prettier.config.cts"],D,["prettier","--write","{file}"],"https://prettier.io/docs/",["prettier"],{"package.json":["prettier"]}),e("biome",["javascript","typescript","json","css"],["biome"],["biome.json","biome.jsonc"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".json",".jsonc",".css"],["biome","format","--write","{file}"],"https://biomejs.dev/",["@biomejs/biome"]),e("oxfmt",["javascript","typescript","json","css","html","markdown","yaml","toml"],["oxfmt"],[".oxfmtrc.json",".oxfmtrc.jsonc","oxfmt.config.ts","oxfmt.config.mts"],z,["oxfmt","--write","{file}"],"https://oxc.rs/docs/guide/usage/formatter.html",["oxfmt"]),e("ruff-format",["python"],["ruff"],["ruff.toml",".ruff.toml"],[".py",".pyi"],["ruff","format","{file}"],"https://docs.astral.sh/ruff/formatter/",["ruff"],{"pyproject.toml":["tool.ruff"]}),e("black",["python"],["black"],[],[".py",".pyi"],["black","--quiet","{file}"],"https://black.readthedocs.io/",["black"],{"pyproject.toml":["tool.black"]}),e("gofmt",["go"],["gofmt"],["go.mod"],[".go"],["gofmt","-w","{file}"],"https://pkg.go.dev/cmd/gofmt"),e("goimports",["go"],["goimports"],["go.mod"],[".go"],["goimports","-w","{file}"],"https://pkg.go.dev/golang.org/x/tools/cmd/goimports"),e("rustfmt",["rust"],["rustfmt"],["rustfmt.toml",".rustfmt.toml","Cargo.toml"],[".rs"],["rustfmt","{file}"],"https://github.com/rust-lang/rustfmt"),e("csharpier",["csharp"],["csharpier"],[".csharpierrc",".csharpierrc.json",".csharpierrc.yaml",".csharpierrc.yml"],[".cs"],["csharpier","format","{file}"],"https://csharpier.com/"),e("google-java-format",["java"],["google-java-format"],["pom.xml","build.gradle"],[".java"],["google-java-format","--replace","{file}"],"https://github.com/google/google-java-format"),e("ktlint-format",["kotlin"],["ktlint"],[".editorconfig","build.gradle.kts"],[".kt",".kts"],["ktlint","-F","{file}"],"https://pinterest.github.io/ktlint/"),e("rubocop-format",["ruby"],["rubocop"],[".rubocop.yml","Gemfile"],[".rb",".rake"],["rubocop","--fix-layout","{file}"],"https://docs.rubocop.org/"),e("pint",["php"],["pint"],["pint.json","composer.json"],[".php"],["pint","{file}"],"https://laravel.com/docs/pint"),e("swift-format",["swift"],["swift-format"],[".swift-format","Package.swift"],[".swift"],["swift-format","format","--in-place","{file}"],"https://github.com/swiftlang/swift-format"),e("stylua",["lua"],["stylua"],["stylua.toml",".stylua.toml"],[".lua"],["stylua","{file}"],"https://github.com/JohnnyMorganz/StyLua"),e("shfmt",["shell"],["shfmt"],[".editorconfig"],[".sh",".bash",".zsh"],["shfmt","-w","{file}"],"https://github.com/mvdan/sh"),e("taplo",["toml"],["taplo"],["taplo.toml"],[".toml"],["taplo","format","{file}"],"https://taplo.tamasfe.dev/"),e("sqlfluff-format",["sql"],["sqlfluff"],[".sqlfluff","pyproject.toml"],[".sql"],["sqlfluff","format","{file}"],"https://docs.sqlfluff.com/"),e("terraform-fmt",["terraform"],["terraform"],[".terraform.lock.hcl"],[".tf",".tfvars"],["terraform","fmt","{file}"],"https://developer.hashicorp.com/terraform/cli/commands/fmt"),e("cmake-format",["cmake"],["cmake-format"],[".cmake-format.py","CMakeLists.txt"],[".cmake"],["cmake-format","-i","{file}"],"https://cmake-format.readthedocs.io/",void 0,void 0,["CMakeLists.txt"]),e("xmlformat",["xml"],["xmlformat"],[".xmlformat.conf"],[".xml",".xsd",".xsl"],["xmlformat","--overwrite","{file}"],"https://github.com/pamoller/xmlformatter"),e("mix-format",["elixir"],["mix"],["mix.exs",".formatter.exs"],[".ex",".exs"],["mix","format","{file}"],"https://hexdocs.pm/mix/Mix.Tasks.Format.html"),e("scalafmt",["scala"],["scalafmt"],[".scalafmt.conf"],[".scala",".sc",".sbt"],["scalafmt","{file}"],"https://scalameta.org/scalafmt/"),e("julia-format",["julia"],["julia"],[".JuliaFormatter.toml","Project.toml"],[".jl"],["julia","--startup-file=no","--history-file=no","-e","using JuliaFormatter; format_file(ARGS[1])","{file}"],"https://github.com/domluna/JuliaFormatter.jl"),e("powershell-format",["powershell"],["pwsh"],["PSScriptAnalyzerSettings.psd1"],[".ps1",".psm1",".psd1"],["pwsh","-NoProfile","-NonInteractive","-CommandWithArgs",'$ErrorActionPreference="Stop";$p=$args[0];$options=@{};if(Test-Path -LiteralPath PSScriptAnalyzerSettings.psd1){$options.Settings="PSScriptAnalyzerSettings.psd1"};[IO.File]::WriteAllText($p,(Invoke-Formatter -ScriptDefinition ([IO.File]::ReadAllText($p)) @options))',"{file}"],"https://learn.microsoft.com/powershell/module/psscriptanalyzer/invoke-formatter"),e("dockfmt",["dockerfile"],["dockfmt"],["Dockerfile","Containerfile"],[".dockerfile"],["dockfmt","fmt","--write","{file}"],"https://github.com/jessfraz/dockfmt",void 0,void 0,["Dockerfile","Containerfile"])];function e(o,t,r,i,n,m,a,l,s,c){return{id:o,name:o,kind:"formatter",languages:t,executables:r,configFiles:i,documentation:a,...l&&{dependencies:l},...s&&{configSections:s},formatter:{extensions:n,...c&&{fileNames:c},run:{command:m},output:"in-place"}}}f(e,"recipe");var p=class o{constructor(t,r,i=new Map){this.formatters=t;this.availableBuiltIns=r;this.evidence=i}static{f(this,"FormatterCommandRegistry")}static async fromDirectory(t,r={}){let i=await k(t,"formatters",s=>E(s).formatters,r),n=r.environment??process.env,m=await Promise.all(i.entries.filter(s=>s.layer==="built-in").map(async s=>({id:s.id,available:await g(s.config.run,t,n)}))),a=await b(t,d),l=[...i.entries].sort((s,c)=>s.layer==="built-in"&&c.layer==="built-in"?(a.get(c.id)?.score??0)-(a.get(s.id)?.score??0):0);return new o(l,new Set(m.filter(s=>s.available&&(!r.requireBuiltInEvidence||(a.get(s.id)?.score??0)>0)).map(s=>s.id)),a)}static fromConfig(t){return new o(Object.entries(t.formatters).map(([r,i])=>({id:r,config:i,layer:"project",sourcePath:"<memory>"})),new Set)}resolve(t,r){return this.resolveEntry(t,r)?.config}resolveEntry(t,r){return x(this.formatters,this.availableBuiltIns,this.evidence,t,r)}get entries(){return this.formatters}};var T={protocol:F,apiVersion:1,id:"formatter",setup(o){for(let t of d)o.addToolRecipe(t);o.addSetupCheck({id:"effective-config",inspect:_}),o.addCheck({id:"config",title:"Formatter",async run(t){try{let r=await p.fromDirectory(t.cwd,{environment:t.env}),i=q(r,t.files,t.cwd);return i.length===0?[{status:"skip",message:"No formatter matches the inspected project files"}]:await Promise.all(i.map(async({entry:n,source:m})=>{let a=`${n.id} [${n.layer}] command ${JSON.stringify(n.config.run.command)}`,l=await A(y.join(y.dirname(m),".pi-agent-ide-doctor-")),s=y.join(l,y.basename(m));try{return await $(m,s),(await u(n.config,{projectRoot:t.cwd,filePath:s,env:t.env})).ok?{status:"pass",message:`${a}: probe passed`,detail:n.sourcePath}:{status:"fail",message:`${a}: probe failed`,detail:n.sourcePath}}catch(c){return{status:"fail",message:`${a}: ${c instanceof Error?c.message:String(c)}`,detail:n.sourcePath}}finally{await M(l,{recursive:!0,force:!0})}}))}catch(r){return[{status:"fail",message:r instanceof Error?r.message:String(r)}]}}})}};async function _(o){try{let t=await p.fromDirectory(o.cwd,{environment:o.env}),r=[],i=new Map;for(let[n,m]of o.detectedLanguages){let a=m.map(l=>t.resolveEntry(l,o.cwd)).find(l=>l!==void 0);a!==void 0&&(r.push({kind:"formatter",languageId:n,toolId:a.id}),await g(a.config.run,o.cwd,o.env)||i.set(a.id,{id:`formatter-${a.id}-unavailable`,message:`Configured formatter ${a.id} cannot run ${JSON.stringify(a.config.run.command)}`}))}return{selections:r,actions:[...i.values()]}}catch(t){return{actions:[{id:"formatter-config-invalid",message:`Formatter configuration cannot load: ${t instanceof Error?t.message:String(t)}`}]}}}f(_,"inspectFormatterSetup");function q(o,t,r){let i=new Map;for(let n of t){let m=o.resolveEntry(n,r);m!==void 0&&!i.has(m.id)&&i.set(m.id,{entry:m,source:n})}return[...i.values()]}f(q,"applicableFormatters");import L from"node:path";var S=new Map;function O(){return{kind:"formatter",name:"formatter",priority:100,extensions:["*"],detect:f(async o=>(await I(o.cwd),!0),"detect"),async format({filePath:o},t){let r=await w(t.cwd,o,"formatters",d);if(r===void 0)return{ok:!0,edits:0,formatter:null};let i=r!==L.resolve(t.cwd),m=(await I(r,i)).resolve(o,r);if(m===void 0)return{ok:!0,edits:0,formatter:null};let a=C(m.run.command);try{let l=await u(m,{projectRoot:r,filePath:o});return{ok:l.ok,edits:l.changed?1:0,formatter:a}}catch{return{ok:!1,edits:0,formatter:a}}}}}f(O,"createFormatter");async function I(o,t=!1){let r=JSON.stringify([o,t]),i=S.get(r);return i===void 0&&(i=p.fromDirectory(o,{includeGlobal:!t,requireBuiltInEvidence:t}),S.set(r,i)),i}f(I,"loadRegistry");async function N(o){let t={kind:"formatter",name:"pi-agent-ide-formatter",priority:200,extensions:["*"],detect:f(()=>Promise.resolve(!0),"detect"),async format(i,n){return O().format(i,n)}},r={protocol:h,apiVersion:4,id:"formatter",setup(i){i.addTool(t)}};await Promise.all([j(o,r),P(o,T)])}f(N,"registerFormatter");export{N as default};
|
|
1
|
+
import{b as B}from"./chunk-CEX3VOJ7.js";import"./chunk-7WCZOO5I.js";import{b as V,c as F}from"./chunk-25CZ5ZIU.js";import{a as E}from"./chunk-MGCHOGQD.js";import{a as O,b as L}from"./chunk-T6LX2RX5.js";import{a as _}from"./chunk-L7JMDDSD.js";import{a as $,b as C,c as N}from"./chunk-O6LE42GK.js";import"./chunk-NNCZYO4Q.js";import{d as I}from"./chunk-VCTK4JSN.js";import"./chunk-YHUTTZC6.js";import{a as M}from"./chunk-6CZO43OH.js";import{a as P,b as k}from"./chunk-OBNING2A.js";import"./chunk-S3ZPXWX7.js";import{a as j}from"./chunk-ZTYWHL2F.js";import{a as D,b as H}from"./chunk-7UGNGK7Y.js";import{a as R,b,c as w,l as v}from"./chunk-NTYXZ3EL.js";import"./chunk-5VSE5X5R.js";import"./chunk-KINKBPPX.js";import{j as T}from"./chunk-M5MJP7Z2.js";import"./chunk-WZI4YC2O.js";import{e as x}from"./chunk-N34ATN52.js";import"./chunk-ZC65Z3CK.js";import{a as l}from"./chunk-EI7MMDWY.js";import{readFile as se}from"node:fs/promises";var ae={cmake:"no compatible Tree-sitter parser is packaged",dockerfile:"no compatible Tree-sitter parser is packaged",julia:"no compatible Tree-sitter parser is packaged",powershell:"no compatible Tree-sitter parser is packaged",r:"no compatible Tree-sitter parser is packaged",svelte:"the container grammar is not available as an ast-grep language package",terraform:"the HCL grammar is not available as an ast-grep language package",vue:"the container grammar is not available as an ast-grep language package",xml:"no compatible Tree-sitter parser is packaged",zig:"no compatible Tree-sitter parser is packaged"},y=new Set(["c","cpp","csharp","css","dart","elixir","go","html","java","kotlin","lua","markdown","php","ruby","scala","shell","sql","swift","javascript","typescript","python","rust","json","yaml","toml"]),G={protocol:O,apiVersion:1,id:"ast",setup(a){a.addSetupCheck({id:"structural-search",async inspect(e){return[...e.detectedLanguageIds].some(r=>y.has(r))?await T({command:["ast-grep"]},e.cwd,e.env)?{}:{actions:[{id:"ast-grep-unavailable",message:"Structural search is unavailable because ast-grep was not found"}]}:{}}}),a.addCheck({id:"parsers",title:"AST",async run(e){let n=[];for(let r of e.detectedLanguageIds){let t=ae[r];if(t!==void 0){n.push({status:"skip",message:`${r} AST is unavailable: ${t}`});continue}if(!y.has(r))continue;let s=e.files.find(o=>oe(o,r));if(s!==void 0)try{let o=await se(s,"utf8"),i=await V(s,e.cwd,o.replaceAll(`\r
|
|
2
|
+
`,`
|
|
3
|
+
`).split(`
|
|
4
|
+
`));n.push(i===void 0?{status:"fail",message:`${r} parser did not return a tree`}:{status:"pass",message:`${r} parser loaded`,detail:s})}catch(o){n.push({status:"fail",message:`${r}: ${o instanceof Error?o.message:String(o)}`})}}return n.length>0?n:[{status:"skip",message:"No supported AST files found"}]}}),a.addCheck({id:"ast-grep",title:"Structural search",async run(e){if(![...e.detectedLanguageIds].some(r=>y.has(r)))return[{status:"skip",message:"No supported structural-search files found"}];let n=await x("ast-grep",["--version"],e.cwd,e.env);return[n.ok?{status:"pass",message:"ast-grep is available",detail:n.detail}:{status:"fail",message:"ast-grep is not available",detail:n.detail}]}})}};function oe(a,e){let n=a.slice(a.lastIndexOf(".")).toLowerCase();return{c:[".c",".h"],cpp:[".cc",".cpp",".cxx",".hh",".hpp",".hxx"],csharp:[".cs"],css:[".css",".scss",".less"],dart:[".dart"],elixir:[".ex",".exs"],go:[".go"],html:[".html",".htm"],java:[".java"],kotlin:[".kt",".kts"],lua:[".lua"],markdown:[".md",".mdx"],php:[".php"],ruby:[".rb",".rake"],scala:[".scala",".sc"],shell:[".sh",".bash"],sql:[".sql"],swift:[".swift"],javascript:[".js",".jsx",".mjs",".cjs"],typescript:[".ts",".tsx",".mts",".cts"],python:[".py",".pyi"],rust:[".rs"],json:[".json",".jsonc"],yaml:[".yaml",".yml"],toml:[".toml"]}[e]?.includes(n)??!1}l(oe,"matchesLanguage");var ie,ce;function z(a){return{id:"ast",tryResolve(e,n){return Promise.resolve(le(e,n,a))}}}l(z,"createAstOutlineResolver");function le(a,e,n){let r;try{r=R(a,"ast")}catch(o){return{kind:"failed",error:o}}if(r===void 0)return{kind:"not-handled"};let t;try{t=b(r.path,e.cwd)}catch(o){return{kind:"failed",error:o}}return{kind:"resolved",resource:{source:w("ast",t),async read({signal:o}){o?.throwIfAborted();let i=await(ce??=import("./chunk-5QQABP47.js")),d=await(n??(ie??=new i.AstOutlineManager)).readFileOutline(t,e.cwd);return o?.throwIfAborted(),[i.formatAstOutline(d)]}}}}l(le,"resolveAstOutlineSource");import{DEFAULT_MAX_BYTES as de,DEFAULT_MAX_LINES as ue,truncateHead as A}from"@earendil-works/pi-coding-agent";var S=l(async(a,e,n)=>{let{source:r,resolvedBy:t,lines:s,totalLines:o,startLine:i}=a.details;if(!(r===void 0||t!=="filesystem"||s===void 0||s.length!==o||i!==void 0&&i!==1))try{let{AstOutlineManager:c,isSupportedOutlinePath:d}=await import("./chunk-5QQABP47.js");if(!d(r))return;let u=l(m=>[`AST overview of ${m.path}, source lines 1-${m.totalLines}: the requested text exceeded the read buffer.`,"Source line numbers are on the left. Detail is reduced to fit the buffer; omitted bodies are not exact source text. Read a small source range when needed.",...m.renderedLines.map(g=>`${g.sourceLine?.lineNumber??"\u2026"} | ${g.text}`)].join(`
|
|
5
|
+
`),"format");e.signal?.throwIfAborted();let p=await new c(12).readDocumentOutline(r,e.cwd,s.map(m=>m.content),m=>(e.signal?.throwIfAborted(),!A(u(m),n).truncated)),f=u(p);return A(f,n).truncated?void 0:{content:[{type:"text",text:f}],details:{source:r,resolvedBy:"ast-overflow"}}}catch{e.signal?.throwIfAborted();return}},"reduceAstReadOutput");function U(){return async a=>{let{state:e,result:n}=a,r=n?.content.length===1?n.content[0]:void 0;if(a.audience==="script"||n===void 0||e?.contentKind!=="text"||e.resolvedBy!=="filesystem"||r?.type!=="text"||!A(r.text).truncated)return{kind:"continue",context:a};let t=await S({...n,details:{...n.details,source:e.source,resolvedBy:e.resolvedBy,lines:e.text.lines,startLine:1,totalLines:e.text.lines.length}},a.resolverContext,{maxBytes:de,maxLines:ue});return t===void 0?{kind:"continue",context:a}:{kind:"return",result:t}}}l(U,"createAstOverflowHandler");var X="pi-agent-ast";function K(a){return{id:"ast-scopes",async present(e,n){if(n.resolvedBy!=="filesystem")return e;try{let r=await a.getDocumentScopes(e.source,n.cwd,e.lines.map(s=>s.content)),t=pe(e.lines,r);return t===e.lines?e:{...e,lines:t}}catch{return e}}}}l(K,"createAstScopePresenter");function q(){return a=>{let e=a.state,n=a.result;if(e?.contentKind!=="text"||n===void 0)return{kind:"continue",context:a};let r=n.details.lines;if(r===void 0)return{kind:"continue",context:a};let t=new Map(e.text.lines.map(u=>[u.lineNumber,u])),s=new Set(r.map(u=>u.lineNumber)),o=new Map;for(let u of r){let p=t.get(u.lineNumber),f=W(p);for(let m of f?.boundaries??[]){if(s.has(m.endLine))continue;let g=t.get(m.endLine);g!==void 0&&o.set(m.endLine,g)}}if(o.size===0)return{kind:"continue",context:a};let i=[...o.values()].sort((u,p)=>u.lineNumber-p.lineNumber),c=[...r,...i],d=fe(n,c,r.at(-1));return{kind:"continue",context:{...a,result:d}}}}l(q,"createAstScopePostReadHandler");function pe(a,e){if(e.length===0)return a;let n=new Map,r=new Map;for(let t of e){let s=n.get(t.startLine)??[];s.push(t.beginAnchor.value),n.set(t.startLine,s);let o=r.get(t.startLine)??[];o.push({endLine:t.endLine,beginAnchor:t.beginAnchor.value,endAnchor:t.endScopeAnchor.value}),r.set(t.startLine,o);let i=n.get(t.endLine)??[];i.push(t.endScopeAnchor.value),n.set(t.endLine,i)}return a.map(t=>{let s=n.get(t.lineNumber),o=r.get(t.lineNumber);return s===void 0&&o===void 0?t:{...t,...s!==void 0&&{anchors:[...new Set([...t.anchors??[],...s])],presentation:{...t.presentation,suffix:`${t.presentation?.suffix??""}${s.map(i=>` <!-- ${i} -->`).join("")}`}},metadata:{...t.metadata,[X]:{...W(t),...o!==void 0&&{boundaries:o}}}}})}l(pe,"addScopeMarkers");function W(a){let e=a?.metadata?.[X];if(!(typeof e!="object"||e===null))return e}l(W,"getAstScopeMetadata");function fe(a,e,n){let r=a.content.length===1?a.content[0]:void 0;if(r?.type!=="text"||a.details.lines===void 0)return a;let t=e.slice(a.details.lines.length);if(t.length===0)return a;let s=n?.lineEnding!==void 0&&n.lineEnding.length>0?n.lineEnding:t[0]?.lineEnding!==void 0&&t[0].lineEnding.length>0?t[0].lineEnding:`
|
|
6
|
+
`,o=t.map((d,u)=>{let f=u===t.length-1?d.lineEnding:d.lineEnding||s,m=d.presentation?.prefix??"",g=d.presentation?.suffix??"";return`${m}${d.content}${g}${f}`}).join(""),i=/(?:\r\n|\r|\n)$/.test(r.text)?"":s,c=`${r.text}${i}${o}`;return{...a,content:[{...r,text:c}],details:{...a.details,lines:e}}}l(fe,"appendTextLines");var J=/^scope-(begin|end)-[A-Z0-9]{3,4}(?:-[1-9]\d*)?$/;function Y(a){return{id:"ast-scope",description:'`scope-begin-HASH` / `scope-end-HASH` from read views: ["ast"] \u2014 first/last lines of a scope. Any numeric suffix is part of the anchor.',renderFull(e){return e},renderCompact(e){return J.exec(e)?.[1]==="begin"?"scope start":"scope end"},async tryResolve(e,n){if(!J.test(e))return{kind:"not-handled"};try{let t=(await a.getDocumentScopes(n.source,n.cwd,n.lines)).find(s=>s.beginAnchor.value===e||s.endScopeAnchor.value===e);return t===void 0?{kind:"rejected",rejection:{code:"stale",reason:`AST scope anchor ${e} is stale`}}:{kind:"resolved",anchor:t.beginAnchor.value===e?t.beginAnchor:t.endScopeAnchor}}catch(r){return{kind:"failed",error:r}}}}}l(Y,"createAstScopeAnchorResolver");import Ae from"cross-spawn";import{readFile as Se,stat as ee}from"node:fs/promises";import h from"node:path";import Z from"node:path";import{pathToFileURL as me}from"node:url";function Q(a,e,n,r,t){let s=new Map;for(let i of e){let c=s.get(i.file)??[];c.push(i),s.set(i.file,c)}let o=[...s.entries()].map(([i,c])=>ge(i,c,r));return{sessionId:t,query:a,matchCount:e.length,fileCount:o.length,complete:n,files:o}}l(Q,"createAstSearchPresentation");function ge(a,e,n){let r=new Map;e.forEach((o,i)=>{let c=o.lines.replace(/\r/gu,"").split(`
|
|
7
|
+
`);c.at(-1)===""&&c.pop();let d=`${a}:${String(i)}`;c.forEach((u,p)=>{let f=o.range.start.line+p+1,m=he(o,u,p,c.length);if(m===void 0)return;let g=r.get(f)??{text:u,ranges:[],logicalMatchIds:[]};g.ranges.push(m),g.logicalMatchIds.push(d),r.set(f,g)})});let t=[...r.entries()].sort(([o],[i])=>o-i).map(([o,i])=>{let c=ye(i.ranges);return{lineNumber:o,text:i.text,matchCount:c.length,ranges:c,logicalMatchIds:[...new Set(i.logicalMatchIds)]}}),s=Z.resolve(n,a);return{path:Z.relative(n,s),link:me(s).href,matchCount:e.length,lines:t}}l(ge,"createFilePresentation");function he(a,e,n,r){let t=n===0,s=n===r-1,o=t?a.range.start.column:0,i=s?a.range.end.column:e.length;if(!(i<=o))return{from:Math.min(o,e.length),to:Math.min(i,e.length)}}l(he,"highlightedRange");function ye(a){let e=[...a].sort((r,t)=>r.from-t.from||r.to-t.to),n=[];for(let r of e){let t=n.at(-1);t===void 0||r.from>t.to?n.push(r):n[n.length-1]={from:t.from,to:Math.max(t.to,r.to)}}return n}l(ye,"mergeRanges");function ne(a){return{id:"ast",renderResult:B,async tryResolve(e,n){if(!e.query.startsWith("ast:"))return{kind:"not-handled"};let r=e.query.slice(4).trim();if(r.length===0)return{kind:"failed",error:new Error("ast: pattern must not be empty")};let t=l(async i=>{let c=await be(r,e,n.cwd,i);c.sort((u,p)=>h.resolve(n.cwd,u.file).localeCompare(h.resolve(n.cwd,p.file))||u.range.byteOffset.start-p.range.byteOffset.start||u.range.byteOffset.end-p.range.byteOffset.end);let d=c.slice(0,e.limit??100);return{raw:d,matches:await Re(d,n.cwd,i),complete:c.length<=(e.limit??100)}},"collect"),s=await t(n.signal),o=await a({request:e,matches:s.matches,complete:s.complete,refresh:t},n);return{kind:"resolved",payload:{pattern:r,matches:s.raw.map((i,c)=>({...i,selection:s.matches[c]})),complete:s.complete,sessionId:o.id,presentation:Q(e.query,s.raw,s.complete,n.cwd,o.id)}}},format(e){let n=e;if(n.matches.length===0)return{content:[{type:"text",text:"No AST matches found."}],details:n.presentation};let r=n.matches.flatMap((t,s)=>[`SEARCH#${n.sessionId}:${String(s+1)}:match ${t.file}:${String(t.range.start.line+1)}:${String(t.range.start.column+1)} ${t.language}`,` ${t.lines.trim()}`]);return n.complete&&r.unshift(`SEARCH#${n.sessionId}:all:match selects all exact AST matches.`),n.complete||r.push("Result limit reached."),{content:[{type:"text",text:r.join(`
|
|
8
|
+
`)}],details:n.presentation}}}}l(ne,"createAstSearchResolver");async function Re(a,e,n){let r=new Map;for(let t of a){let s=h.resolve(e,t.file);if(r.has(s))continue;let o=await ee(s),i=await Se(s,{signal:n}),c=await ee(s);if(o.mtimeMs!==c.mtimeMs||o.size!==c.size)throw new Error("AST source changed during search. Run the structural query again.");r.set(s,i)}return a.map(t=>{let s=h.resolve(e,t.file),o=r.get(s);if(o===void 0)throw new Error("Missing AST source snapshot");let{start:i,end:c}=t.range.byteOffset;if(!Number.isInteger(i)||!Number.isInteger(c)||i<0||c<i||c>o.length||o.subarray(i,c).toString("utf8")!==t.text)throw new Error("AST range does not match its source snapshot. Search again.");let d=o.subarray(0,i).toString("utf8"),u=o.subarray(0,c).toString("utf8"),p=d.split(`
|
|
9
|
+
`).length;return{source:s,lineNumber:p,endLineNumber:u.split(`
|
|
10
|
+
`).length,startColumn:d.length-d.lastIndexOf(`
|
|
11
|
+
`)-1,endColumn:u.length-u.lastIndexOf(`
|
|
12
|
+
`)-1,matchedText:t.text,lineText:o.toString("utf8").split(`
|
|
13
|
+
`)[p-1]?.replace(/\r$/u,"")??""}})}l(Re,"selectionMatches");function be(a,e,n,r){let t=["run","--pattern",a,"--json=compact","--no-ignore","parent"];for(let s of te(e.include))t.push("--globs",s);for(let s of te(e.exclude))t.push("--globs",`!${s}`);return t.push(e.path??"."),new Promise((s,o)=>{let i=Ae("ast-grep",t,{cwd:n,stdio:["ignore","pipe","pipe"]}),c="",d="";i.stdout.setEncoding("utf8"),i.stderr.setEncoding("utf8"),i.stdout.on("data",p=>c+=p),i.stderr.on("data",p=>d+=p);let u=l(()=>{i.kill("SIGTERM")},"abort");r?.addEventListener("abort",u,{once:!0}),i.once("error",o),i.once("close",p=>{if(r?.removeEventListener("abort",u),r?.aborted===!0){o(r.reason instanceof Error?r.reason:new Error("AST search aborted"));return}if(p!==0&&p!==1){o(new Error(d.trim()||`ast-grep exited with code ${String(p)}`));return}try{let f=JSON.parse(c.length===0?"[]":c);if(!Array.isArray(f))throw new TypeError("ast-grep returned non-array JSON");s(f)}catch(f){o(f instanceof Error?f:new Error(String(f)))}})})}l(be,"runAstGrep");function te(a){return a?.split(",").map(e=>e.trim()).filter(Boolean)??[]}l(te,"splitGlobs");var we=I({kind:"code-view",label:"AST"});async function re(a){let e=new F,n=K(e),r={protocol:P,apiVersion:k,id:"ast",setup(s){s.addResolver({resolver:z(),renderResult:we}),s.addHandler({stage:"read",when:{resolvedBy:"ast",contentKind:"text"},handler:v()}),s.addView({view:"ast",presenter:n});let o=U();s.addOutputReducer(S);let i=q();s.addHandler({stage:"post-read",async handler(c){let d=await o(c);return d.kind==="return"?d:i(d.context)}}),s.describe('ast:<path> \u2014 compact declaration outline. views: ["ast"] \u2014 scope boundaries alongside source text. Oversized code reads may return an outline with source line numbers; offset/limit read a smaller source range.')}},t={protocol:$,apiVersion:C,id:"ast",setup(s){s.addAnchorResolver({resolver:Y(e),kind:N,type:"auxiliary"}),s.addTextPresenter({presenter:n})}};await Promise.all([M(a,r),E(a,G),_(a,t),j(a,{protocol:D,apiVersion:H,id:"ast-search",setup(s){s.addResolver({resolver:ne(s.registerSelection)}),s.describe("Search code structure with ast:<pattern>, using source-code syntax and placeholders such as $NAME for one node and $$$BODY for several nodes. path, include and exclude narrow the search. Use returned SEARCH# references to read, replace, copy, move or delete exact AST matches, including multiline nodes. A single :match reference becomes stale after its file changes; :all:match reruns the original structural query. Incomplete results do not provide all selections. Use captures in Apply to compute replacement text; these edits do not update imports or references.")}})])}l(re,"registerAst");export{re as default};
|
package/dist/entry-32.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a
|
|
1
|
+
import{a,b,c}from"./chunk-DEP55R35.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as createChangeGroups,c as replaceHeadRangeInIndex,b as reverseChangeGroup};
|
package/dist/entry-33.js
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
import{a as N}from"./chunk-MGCHOGQD.js";import{a as A,b as T}from"./chunk-T6LX2RX5.js";import{a as O}from"./chunk-K5G4FDXD.js";import{a as P}from"./chunk-HKMBQLEK.js";import{a as b,b as j}from"./chunk-Z3VC3S2T.js";import{b as R,c as E,g as S,i as D,j as w,k as $,n as I}from"./chunk-M5MJP7Z2.js";import{a as L}from"./chunk-WZI4YC2O.js";import"./chunk-N34ATN52.js";import{a as g}from"./chunk-ZC65Z3CK.js";import{a}from"./chunk-EI7MMDWY.js";import se from"node:path";var p=[c("dart-analyze",["dart"],["dart"],["analysis_options.yaml","pubspec.yaml"],[".dart"],["dart","analyze","--format","machine","{file}"],"regex","https://dart.dev/tools/dart-analyze","^(?<severity>[^|]+)\\|[^|]+\\|(?<code>[^|]+)\\|(?<file>[^|]+)\\|(?<line>\\d+)\\|(?<column>\\d+)\\|\\d+\\|(?<message>.*)$",void 0,[0,1,2,3]),c("zig-ast-check",["zig"],["zig"],["build.zig","build.zig.zon","zls.json"],[".zig",".zon"],["zig","ast-check","{file}"],"gcc","https://ziglang.org/documentation/master/"),c("lintr",["r"],["Rscript"],[".lintr","DESCRIPTION"],[".r"],["Rscript","-e","print(lintr::lint(commandArgs(TRUE)[1]))","{file}"],"regex","https://lintr.r-lib.org/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<severity>[^:]+): \\[(?<code>[^\\]]+)\\] (?<message>.*)$"),c("clang-tidy",["c","cpp"],["clang-tidy"],[".clang-tidy","compile_commands.json"],[".c",".h",".cc",".cpp",".cxx",".hh",".hpp",".hxx"],["clang-tidy","{file}"],"clang","https://clang.llvm.org/extra/clang-tidy/"),c("eslint",["javascript","typescript","vue","svelte"],["eslint"],["eslint.config.js","eslint.config.mjs","eslint.config.cjs","eslint.config.ts","eslint.config.mts","eslint.config.cts",".eslintrc",".eslintrc.json",".eslintrc.js",".eslintrc.cjs",".eslintrc.yaml",".eslintrc.yml"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".vue",".svelte"],["eslint","--format","json","{file}"],"eslint-json","https://eslint.org/docs/latest/",void 0,["eslint"]),c("oxlint",["javascript","typescript"],["oxlint"],[".oxlintrc.json",".oxlintrc.jsonc","oxlint.config.ts","oxlint.config.mts"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts"],["oxlint","--format","sarif","{file}"],"sarif","https://oxc.rs/docs/guide/usage/linter.html",void 0,["oxlint"]),c("ruff",["python"],["ruff"],["pyproject.toml","ruff.toml",".ruff.toml"],[".py",".pyi"],["ruff","check","--output-format","concise","{file}"],"regex","https://docs.astral.sh/ruff/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<code>\\S+) (?<message>.+)$",["ruff"]),c("golangci-lint",["go"],["golangci-lint"],[".golangci.yml",".golangci.yaml","go.mod"],[".go"],["golangci-lint","run","--output.text.path=","--output.checkstyle.path=stdout","--show-stats=false","./..."],"checkstyle","https://golangci-lint.run/"),c("clippy",["rust"],["cargo"],["Cargo.toml","clippy.toml"],[".rs"],["cargo","clippy","--message-format","short"],"gcc","https://doc.rust-lang.org/clippy/"),c("dotnet-format",["csharp"],["dotnet"],[".editorconfig","global.json"],[".cs"],["dotnet","format","--verify-no-changes","--include","{relativeFile}"],"regex","https://learn.microsoft.com/dotnet/core/tools/dotnet-format","^(?<file>.+)\\((?<line>\\d+),(?<column>\\d+)\\): (?<severity>error|warning) (?<code>[^:]+): (?<message>.*?)(?: \\[.*\\])?$",void 0,[0,2]),c("checkstyle",["java"],["checkstyle"],["checkstyle.xml","pom.xml"],[".java"],["checkstyle","-c","checkstyle.xml","-f","xml","{file}"],"checkstyle","https://checkstyle.org/"),c("detekt",["kotlin"],["detekt"],["detekt.yml","build.gradle.kts"],[".kt",".kts"],["detekt","--input","{file}","--config","detekt.yml"],"regex","https://detekt.dev/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<message>.*?) \\[(?<code>[^\\]]+)\\]$",void 0,[0,2]),c("rubocop",["ruby"],["rubocop"],[".rubocop.yml","Gemfile"],[".rb",".rake"],["rubocop","--format","clang","{file}"],"regex","https://docs.rubocop.org/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<severity>[A-Z]): (?:\\[Correctable\\] )?(?<code>[^:]+): (?<message>.*)$"),c("phpcs",["php"],["phpcs"],["phpcs.xml","phpcs.xml.dist","composer.json"],[".php"],["phpcs","--report=checkstyle","{file}"],"checkstyle","https://github.com/PHPCSStandards/PHP_CodeSniffer",void 0,void 0,[0,1,2,3]),c("swiftlint",["swift"],["swiftlint"],[".swiftlint.yml","Package.swift"],[".swift"],["swiftlint","lint","--quiet","--reporter","checkstyle","{file}"],"checkstyle","https://github.com/realm/SwiftLint",void 0,void 0,[0,2]),c("scalafix",["scala"],["scalafix"],[".scalafix.conf"],[".scala",".sc"],["scalafix","--check","--files","{file}"],"gcc","https://scalacenter.github.io/scalafix/",void 0,void 0,[0,2,64,66]),c("credo",["elixir"],["mix"],["mix.exs",".credo.exs"],[".ex",".exs"],["mix","credo","--strict","--format","flycheck","--files-included","{file}"],"regex","https://hexdocs.pm/credo/","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): (?<severity>[A-Z]): (?<message>.+)$",void 0,Array.from({length:32},(t,e)=>e)),c("psscriptanalyzer",["powershell"],["pwsh"],["PSScriptAnalyzerSettings.psd1"],[".ps1",".psm1",".psd1"],["pwsh","-NoProfile","-NonInteractive","-CommandWithArgs",'$ErrorActionPreference="Stop";$options=@{};if(Test-Path -LiteralPath PSScriptAnalyzerSettings.psd1){$options.Settings="PSScriptAnalyzerSettings.psd1"};Invoke-ScriptAnalyzer -Path $args[0] @options | ForEach-Object {"$($_.ScriptPath):$($_.Line):$($_.Column): $($_.Severity): $($_.Message) [$($_.RuleName)]"}',"{file}"],"regex","https://learn.microsoft.com/powershell/module/psscriptanalyzer/invoke-scriptanalyzer","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): (?<severity>\\w+): (?<message>.+) \\[(?<code>[^\\]]+)\\]$",void 0,[0]),c("luacheck",["lua"],["luacheck"],[".luacheckrc"],[".lua"],["luacheck","--formatter","plain","--codes","--no-color","{file}"],"regex","https://github.com/lunarmodules/luacheck","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): \\((?<code>(?<severity>[WE])\\d+)\\) (?<message>.+)$",void 0,[0,1,2]),c("shellcheck",["shell"],["shellcheck"],[".shellcheckrc"],[".sh",".bash",".zsh"],["shellcheck","-f","gcc","{file}"],"gcc","https://www.shellcheck.net/"),c("stylelint",["css"],["stylelint"],["stylelint.config.js",".stylelintrc.json"],[".css",".scss",".sass",".less"],["stylelint","--formatter","compact","{file}"],"regex","https://stylelint.io/","^(?<file>.+): line (?<line>\\d+), col (?<column>\\d+), (?<severity>error|warning) - (?<message>.+) \\((?<code>[^)]+)\\)$",["stylelint"],[0,2]),c("yamllint",["yaml"],["yamllint"],[".yamllint",".yamllint.yml"],[".yaml",".yml"],["yamllint","-f","parsable","{file}"],"regex","https://yamllint.readthedocs.io/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): \\[(?<severity>[^\\]]+)\\] (?<message>.*?) \\((?<code>[^)]+)\\)$"),c("markdownlint",["markdown"],["markdownlint"],[".markdownlint.json",".markdownlint.yaml"],[".md",".mdx"],["markdownlint","{file}"],"regex","https://github.com/DavidAnson/markdownlint","^(?<file>.+?):(?<line>\\d+)(?::(?<column>\\d+))? (?<severity>error|warning) (?<code>MD\\d+)(?:/\\S+)? (?<message>.*)$"),c("sqlfluff",["sql"],["sqlfluff"],[".sqlfluff","pyproject.toml"],[".sql"],["sqlfluff","lint","--format","sarif","{file}"],"sarif","https://docs.sqlfluff.com/"),c("hadolint",["dockerfile"],["hadolint"],[".hadolint.yaml"],[".dockerfile"],["hadolint","--format","checkstyle","{file}"],"checkstyle","https://github.com/hadolint/hadolint",void 0,void 0,[0,1],void 0,["Dockerfile","Containerfile"]),c("tflint",["terraform"],["tflint"],[".tflint.hcl"],[".tf"],["tflint","--format","checkstyle"],"checkstyle","https://github.com/terraform-linters/tflint",void 0,void 0,[0,2]),c("cmake-lint",["cmake"],["cmake-lint"],[".cmake-format.py","CMakeLists.txt"],[".cmake"],["cmake-lint","{file}"],"regex","https://cmake-format.readthedocs.io/","^(?<file>.+?):(?<line>\\d+),(?<column>\\d+): \\[(?<code>(?<severity>[A-Z])\\d+)\\] (?<message>.*)$",void 0,[0,1],0,["CMakeLists.txt"]),c("htmlhint",["html"],["htmlhint"],[".htmlhintrc"],[".html",".htm"],["htmlhint","--format","checkstyle","--nocolor","{file}"],"checkstyle","https://htmlhint.com/"),c("jsonlint",["json"],["jsonlint"],[".jsonlintrc",".jsonlintrc.json",".jsonlintrc.yaml",".jsonlintrc.yml",".jsonlintrc.js",".jsonlintrc.cjs","jsonlint.config.js","jsonlint.config.cjs"],[".json"],["jsonlint","-q","{file}"],"regex","https://github.com/prantlf/jsonlint","^(?:Error: )?(?<message>Parse (?<severity>error) on line (?<line>\\d+)(?:, column (?<column>\\d+))?:[^\\n]*)$",["@prantlf/jsonlint","jsonlint"]),c("taplo-check",["toml"],["taplo"],["taplo.toml"],[".toml"],["taplo","check","--colors","never","{file}"],"regex","https://taplo.tamasfe.dev/","^(?<severity>error): (?<message>[^\\n]+)\\n\\s*\u250C\u2500 (?<file>.+):(?<line>\\d+):(?<column>\\d+)"),c("xmllint",["xml"],["xmllint"],[".xmllintrc"],[".xml",".xsd",".xsl"],["xmllint","--noout","{file}"],"regex","https://gnome.pages.gitlab.gnome.org/libxml2/xmllint.html","^(?<file>.+?):(?<line>\\d+): (?<severity>(?:parser |validity )?(?:error|warning)) : (?<message>.*)$",void 0,[0,1,2,3,4])];function c(t,e,n,i,r,f,s,l,o,d,x=[0,1],u,h){return{id:t,name:t,kind:"linter",languages:e,executables:n,configFiles:i,documentation:l,...d&&{dependencies:d},linter:{extensions:r,...h&&{fileNames:h},check:{command:f,successExitCodes:x},diagnostics:{format:s,...o&&{pattern:o},...u!==void 0&&{columnBase:u}}}}}a(c,"recipe");import F from"node:path";import{fileURLToPath as ee}from"node:url";function M(t,e){if(t.trim().length===0)return[];switch(e.format){case"pi-json":return B(t);case"eslint-json":return G(t);case"sarif":return W(t);case"checkstyle":return Z(t);case"gcc":case"clang":return H(t);case"regex":return U(t,g(e.pattern),e.columnBase??1)}}a(M,"parseDiagnostics");function B(t){let e=JSON.parse(t);return Array.isArray(e.diagnostics)?e.diagnostics.flatMap(y):[]}a(B,"parsePiJson");function G(t){return JSON.parse(t).flatMap(n=>Array.isArray(n.messages)?n.messages.flatMap(i=>y(i).map(r=>({...r,...n.filePath&&{file:n.filePath}}))):[])}a(G,"parseEslintJson");function W(t){return(JSON.parse(t).runs??[]).flatMap(n=>(n.results??[]).flatMap(i=>{let r=i.locations?.[0]?.physicalLocation,f=r?.region??{},s=i.message;return y({file:r?.artifactLocation?.uri,line:f.startLine,column:f.startColumn,message:s?.text,code:i.ruleId,severity:Q(i.level)})}))}a(W,"parseSarif");function Z(t){let e=[];for(let n of t.matchAll(/<file\s+([^>]+)>([\s\S]*?)<\/file>/gu)){let i=z(g(n[1])).name;for(let r of g(n[2]).matchAll(/<error\s+([^>]+?)\/?>(?:<\/error>)?/gu)){let f=z(g(r[1]));e.push(...y({file:i,line:Number(f.line),column:Number(f.column??1),message:f.message,code:f.source,severity:f.severity}))}}return e}a(Z,"parseCheckstyle");function z(t){return Object.fromEntries([...t.matchAll(/([\w-]+)="([^"]*)"/gu)].map(e=>[g(e[1]),Y(g(e[2]))]))}a(z,"xmlAttributes");function H(t){return X(t,/^(?<file>.+?):(?<line>\d+):(?<column>\d+):\s*(?<severity>fatal error|error|warning|note|info|hint):\s*(?<message>.*?)(?:\s+\[(?<code>[^\]]+)\])?$/u)}a(H,"parseCompilerLines");function U(t,e,n){return[...t.replaceAll(`\r
|
|
2
|
-
`,`
|
|
3
|
-
`).matchAll(new RegExp(e,"gmu"))].flatMap(i=>i.groups===void 0?[]:y({...i.groups,...i.groups.column!==void 0&&{column:Number(i.groups.column)+(1-n)}}))}a(U,"parseRegexLines");function X(t,e){return t.split(/\r?\n/u).flatMap(n=>{let i=n.match(e)?.groups;return i===void 0?[]:y(i)})}a(X,"parseMatchingLines");function y(t){if(typeof t!="object"||t===null)return[];let e=t,n=_(e.line??e.startLine),i=_(e.column??e.startColumn,1),r=typeof e.message=="string"?e.message:void 0;return n===void 0||r===void 0?[]:[{...typeof e.file=="string"&&{file:e.file},code:q(e.code??e.ruleId,"lint"),message:r,line:n,column:i??1,severity:K(e.severity)}]}a(y,"normalizeDiagnostic");function _(t,e){let n=typeof t=="string"?Number.parseInt(t,10):t;return typeof n=="number"&&Number.isInteger(n)&&n>=1?n:e}a(_,"numberValue");function q(t,e){return typeof t=="string"||typeof t=="number"?String(t):e}a(q,"stringValue");function K(t){if(t===2)return"error";if(t===1)return"warning";let e=q(t,"warning").toLowerCase();return e.includes("error")||e==="e"||e==="f"||e==="fatal"?"error":e==="info"||e==="note"||e==="notice"?"info":e==="hint"?"hint":"warning"}a(K,"severityValue");function Q(t){return t==="error"||t==="warning"||t==="note"?t:"warning"}a(Q,"sarifSeverity");function Y(t){return t.replace(/&#(x[0-9a-f]+|\d+);/giu,(e,n)=>{let i=n.toLowerCase().startsWith("x")?Number.parseInt(n.slice(1),16):Number(n);return i<=1114111?String.fromCodePoint(i):e}).replaceAll(""",'"').replaceAll("'","'").replaceAll("<","<").replaceAll(">",">").replaceAll("&","&")}a(Y,"decodeXml");var m=class t{constructor(e,n,i=new Map){this.linters=e;this.availableBuiltIns=n;this.evidence=i}static{a(this,"LintCommandRegistry")}static async fromDirectory(e,n={}){let i=await S(e,"linters",o=>I(o).linters,n),r=n.environment??process.env,f=await Promise.all(i.entries.filter(o=>o.layer==="built-in").map(async o=>({id:o.id,available:await w(o.config.check,e,r)}))),s=await L(e,p),l=[...i.entries].sort((o,d)=>o.layer==="built-in"&&d.layer==="built-in"?(s.get(d.id)?.score??0)-(s.get(o.id)?.score??0):0);return new t(l,new Set(f.filter(o=>o.available&&(!n.requireBuiltInEvidence||(s.get(o.id)?.score??0)>0)).map(o=>o.id)),s)}static fromConfig(e){return new t(Object.entries(e.linters).map(([n,i])=>({id:n,config:i,layer:"project",sourcePath:"<memory>"})),new Set)}resolve(e,n){return this.resolveEntry(e,n)?.config}resolveEntry(e,n){return D(this.linters,this.availableBuiltIns,this.evidence,e,n)}get entries(){return this.linters}};async function k(t,e){let n;try{n=await $(t.check,e)}catch(l){return{ok:!1,diagnostics:[],failure:`command could not start: ${l instanceof Error?l.message:String(l)}`}}let i=t.diagnostics.format==="regex"||t.diagnostics.format==="clang"?[n.stdout,n.stderr].filter(l=>l.trim().length>0).join(`
|
|
4
|
-
`):n.stdout.trim().length>0?n.stdout:n.stderr,r;try{r=M(i,t.diagnostics)}catch{return{ok:!1,diagnostics:[],failure:`invalid ${t.diagnostics.format} diagnostics: ${i.trim().slice(0,200)||"empty command output"}`}}let f=n.ok&&(n.exitCode===0||r.length>0),s=t.check.cwd==="file"?F.dirname(e.filePath):e.projectRoot;return r=r.filter(l=>{if(l.file===void 0)return!0;let o=l.file.startsWith("file:")?ee(l.file):l.file;return O(F.resolve(s,o),e.filePath)}).map(({file:l,...o})=>o),{ok:f,diagnostics:r,...!f&&{failure:n.stderr.trim().slice(0,200)||`command exited with code ${String(n.exitCode)}`}}}a(k,"runConfiguredLinter");function J(t){return{kind:"linter",name:"command-lint",priority:100,extensions:["*"],detect:a(()=>Promise.resolve(!0),"detect"),async lint({filePath:e,fix:n},i){let r=t.resolve(e,i.cwd);if(r===void 0)return{ok:!0,diagnostics:[]};let f=n===!0&&r.fix!==void 0?r.fix:r.check,s=await k({...r,check:f},{projectRoot:i.cwd,filePath:e});return{ok:s.ok,diagnostics:s.diagnostics}}}}a(J,"createCommandLinter");import{copyFile as te,mkdtemp as ne,rm as ie}from"node:fs/promises";import C from"node:path";var V={protocol:A,apiVersion:1,id:"lint",setup(t){for(let e of p)t.addToolRecipe(e);t.addSetupCheck({id:"effective-config",inspect:re}),t.addCheck({id:"config",title:"Linter",async run(e){try{let n=await m.fromDirectory(e.cwd,{environment:e.env}),i=oe(n,e.files,e.cwd);return i.length===0?[{status:"skip",message:"No linter matches the inspected project files"}]:await Promise.all(i.map(async({entry:r,source:f})=>{let s=`${r.id} [${r.layer}] command ${JSON.stringify(r.config.check.command)}`,l=await ne(C.join(C.dirname(f),".pi-agent-ide-doctor-")),o=C.join(l,C.basename(f));try{await te(f,o);let d=await k(r.config,{projectRoot:e.cwd,filePath:o,env:e.env});return d.ok?{status:"pass",message:`${s}: probe passed`,detail:r.sourcePath}:{status:"fail",message:`${s}: probe failed`,detail:d.failure??r.sourcePath}}catch(d){return{status:"fail",message:`${s}: ${d instanceof Error?d.message:String(d)}`,detail:r.sourcePath}}finally{await ie(l,{recursive:!0,force:!0})}}))}catch(n){return[{status:"fail",message:n instanceof Error?n.message:String(n)}]}}})}};async function re(t){try{let e=await m.fromDirectory(t.cwd,{environment:t.env}),n=[],i=new Map;for(let[r,f]of t.detectedLanguages){let s=f.map(l=>e.resolveEntry(l,t.cwd)).find(l=>l!==void 0);s!==void 0&&(n.push({kind:"linter",languageId:r,toolId:s.id}),await w(s.config.check,t.cwd,t.env)||i.set(s.id,{id:`linter-${s.id}-unavailable`,message:`Configured linter ${s.id} cannot run ${JSON.stringify(s.config.check.command)}`}))}return{selections:n,actions:[...i.values()]}}catch(e){return{actions:[{id:"linter-config-invalid",message:`Linter configuration cannot load: ${e instanceof Error?e.message:String(e)}`}]}}}a(re,"inspectLinterSetup");function oe(t,e,n){let i=new Map;for(let r of e){let f=t.resolveEntry(r,n);f!==void 0&&!i.has(f.id)&&i.set(f.id,{entry:f,source:r})}return[...i.values()]}a(oe,"applicableLinters");async function le(t){let e=new Map,n=a((s,l=!1)=>{let o=JSON.stringify([s,l]),d=e.get(o);return d===void 0&&(d=ae(s,l),e.set(o,d)),d},"registryFor"),i=a(async(s,l)=>{let o=await E(l,s,"linters",p);return o===void 0?void 0:{projectRoot:o,external:o!==se.resolve(l)}},"resolveProject"),r={kind:"linter",name:"pi-agent-ide-lint",priority:200,extensions:["*"],detect:a(async s=>(await n(s.cwd),!0),"detect"),async lint(s,l){let o=await i(s.filePath,l.cwd);if(o===void 0)return{ok:!0,diagnostics:[]};let d=await n(o.projectRoot,o.external);return J(d).lint(s,{cwd:o.projectRoot})}},f={protocol:b,apiVersion:4,id:"lint",setup(s){s.addTool(r),s.addDiagnosticSource({id:"lint",async diagnose(l,o){let d=await i(l,o.cwd);if(d===void 0)return{status:"unavailable",diagnostics:[],reason:"No local linter project found for this file"};let x=await n(d.projectRoot,d.external);o.signal.throwIfAborted();let u=x.resolve(l,d.projectRoot);if(!u)return{status:"unavailable",diagnostics:[],reason:"No linter configured for this file"};let h=R(u.check.command),v=await k(u,{projectRoot:d.projectRoot,filePath:l,signal:o.signal});return!v.ok&&v.diagnostics.length===0?{status:"unavailable",diagnostics:[],reason:v.failure??"Lint check failed",source:h}:{status:"ready",diagnostics:v.diagnostics,source:h}}})}};await Promise.all([P(t,f),N(t,V)])}a(le,"registerLint");async function ae(t,e){let n=e?t:process.env.PI_AGENT_IDE_CONFIG_DIR??t;return m.fromDirectory(n,{includeGlobal:!e,requireBuiltInEvidence:e})}a(ae,"loadRegistry");export{le as default};
|
|
1
|
+
import{a as Q,b as K,c as W}from"./chunk-DEP55R35.js";import{e as O,f as U}from"./chunk-T7I2VX3J.js";import{a as F}from"./chunk-MGCHOGQD.js";import{a as L,b as N}from"./chunk-T6LX2RX5.js";import{a as z}from"./chunk-L7JMDDSD.js";import{a as B,b as V}from"./chunk-O6LE42GK.js";import{a as _}from"./chunk-6CZO43OH.js";import{a as j,b as M}from"./chunk-OBNING2A.js";import"./chunk-S3ZPXWX7.js";import{a as H}from"./chunk-5VSE5X5R.js";import{d as $,e as D}from"./chunk-N34ATN52.js";import{a as x}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import{Value as Ne}from"typebox/value";import{access as oe}from"node:fs/promises";import ae from"node:path";var Y={protocol:L,apiVersion:1,id:"changes",setup(n){n.addSetupCheck({id:"git",async inspect(e){return await ie(e.cwd)?await $("git",e.cwd,e.env)?{}:{actions:[{id:"git-unavailable",message:"Git integration is unavailable because Git was not found"}]}:{}}}),n.addCheck({id:"git",title:"Git changes",async run(e){let t=await D("git",["--version"],e.cwd,e.env);return[t.ok?{status:"pass",message:"Git is available",detail:t.detail}:{status:"warn",message:"Git is not available; change anchors and index tools are disabled",detail:t.detail}]}})}};async function ie(n){try{return await oe(ae.join(n,".git")),!0}catch{return!1}}s(ie,"isGitProject");import{mkdtemp as se,rm as de,writeFile as ce}from"node:fs/promises";import ue from"node:os";import m from"node:path";var b=class n{constructor(e,t){this.executor=e;this.repositoryRoot=t}static{s(this,"GitChangesBackend")}static async create(e,t,r){let o=await e.exec("git",["rev-parse","--show-toplevel"],{cwd:t,...r!==void 0&&{signal:r}});return o.code!==0?{status:"unavailable",reason:"no-worktree",message:o.stderr.trim()||"not inside a Git worktree"}:{status:"ready",backend:new n(e,m.resolve(o.stdout.trim()))}}async readTrackedFile(e,t,r){let o=m.resolve(t,e),a=m.relative(this.repositoryRoot,o);return a===".."||a.startsWith(`..${m.sep}`)||m.isAbsolute(a)?{status:"unavailable",reason:"outside-worktree",message:`${o} is outside ${this.repositoryRoot}`}:this.readTrackedRepositoryFile(a.split(m.sep).join("/"),r)}async readTrackedRepositoryFile(e,t){let r=await this.git(["rev-parse","--verify","HEAD"],t);if(r.code!==0)return{status:"unavailable",reason:"missing-head",message:r.stderr.trim()||"Git HEAD does not exist"};let o=await this.git(["--literal-pathspecs","ls-tree","-z","HEAD","--",e],t);if(o.code!==0)return{status:"unavailable",reason:"head-file-lookup-failed",message:o.stderr.trim()||`could not inspect HEAD:${e}`};let a=le(o.stdout);if(a===void 0)return{status:"untracked"};let i=await this.readBlob(a.blob,"HEAD",e,t);if(i.status!=="found")return i;let c=await this.git(["--literal-pathspecs","ls-files","--stage","-z","--",e],t);if(c.code!==0)return{status:"unavailable",reason:"index-file-lookup-failed",message:c.stderr.trim()||`could not inspect the index entry for ${e}`};let d=ge(c.stdout);if(d.some(({stage:g})=>g!==0))return{status:"unavailable",reason:"conflicted",message:`${e} has unresolved Git index entries`};let u=d.find(({stage:g})=>g===0),l="";if(u!==void 0){let g=await this.readBlob(u.blob,"index",e,t);if(g.status!=="found")return g;l=g.text}return{status:"found",head:r.stdout.trim(),repositoryPath:e,repositoryRoot:this.repositoryRoot,headText:i.text,indexText:l,indexMode:u?.mode??a.mode}}async writeIndexFile(e,t,r,o){let a=await se(m.join(ue.tmpdir(),"pi-agent-index-")),i=m.join(a,"content");try{await ce(i,r,"utf8");let c=await this.git(["hash-object","-w",`--path=${e}`,i],o);if(c.code!==0||c.stdout.trim().length===0)throw new Error(c.stderr.trim()||`could not write a Git blob for ${e}`);let d=await this.git(["update-index","--add","--cacheinfo",t,c.stdout.trim(),e],o);if(d.code!==0)throw new Error(d.stderr.trim()||`could not update the Git index entry for ${e}`)}finally{await de(a,{recursive:!0,force:!0})}}async readBlob(e,t,r,o){let a=await this.git(["cat-file","blob",e],o);return a.code!==0?{status:"unavailable",reason:t==="HEAD"?"head-file-lookup-failed":"index-file-lookup-failed",message:a.stderr.trim()||`could not read ${t}:${r}`}:{status:"found",text:a.stdout}}git(e,t){return this.executor.exec("git",e,{cwd:this.repositoryRoot,...t!==void 0&&{signal:t}})}};function le(n){let e=n.split("\0",1)[0];if(e===void 0||e.length===0)return;let t=e.indexOf(" ");if(t===-1)return;let[r,o,a]=e.slice(0,t).split(" ",3);return r===void 0||o!=="blob"||a===void 0?void 0:{mode:r,blob:a,path:e.slice(t+1)}}s(le,"parseTreeEntry");function ge(n){return n.split("\0").filter(Boolean).flatMap(e=>{let t=e.indexOf(" ");if(t===-1)return[];let[r,o,a]=e.slice(0,t).split(" ",3),i=Number(a);return r===void 0||o===void 0||!Number.isInteger(i)?[]:[{mode:r,blob:o,stage:i,path:e.slice(t+1)}]})}s(ge,"parseIndexEntries");function q(n){return{exec:s((e,t,r)=>n.exec(e,t,r),"exec")}}s(q,"extensionGitExecutor");var f=class n{constructor(e){this.git=e}static{s(this,"ChangeService")}static async create(e,t,r){let o=await b.create(e,t,r);return o.status==="unavailable"?o:{status:"ready",service:new n(o.backend)}}async inspect(e){if(e.worktreeText.includes("\0"))return{status:"unavailable",reason:"binary",message:"worktree file contains binary content"};let t=await this.git.readTrackedFile(e.source,e.cwd,e.signal);if(t.status!=="found")return t.status==="untracked"?{status:"not-applicable",reason:"untracked"}:t;if(t.headText.includes("\0")||t.indexText.includes("\0"))return{status:"unavailable",reason:"binary",message:"Git file state contains binary content"};let r=Q(t.repositoryPath,t.headText,t.indexText,e.worktreeText);return r.length===0?{status:"not-applicable",reason:"clean"}:{status:"applicable",head:t.head,repositoryRoot:t.repositoryRoot,repositoryPath:t.repositoryPath,groups:r}}async changeIndex(e,t,r){let o=await this.inspect(e);if(o.status!=="applicable")return o;let a=o.groups.find(u=>u.selector===t);if(a===void 0)return A(t,o.groups.map(({selector:u})=>u));let i=r==="stage"?"staged":"unstaged";if(a.state===i)return{status:"unchanged",state:i,group:a};let c=x(a.segments[0]),d={head:o.head,repositoryPath:o.repositoryPath,headStart:c.headStart,headEnd:c.headEnd,replacementText:r==="stage"?c.worktreeText:c.headText};try{await this.applyIndexUpdate(d,e.signal)}catch(u){return{status:"unavailable",reason:"index-write-failed",message:pe(u)}}return{status:"applied",state:i,group:a}}async prepareUndo(e,t){let r=await this.inspect(e);if(r.status!=="applicable")return r;let o=r.groups.find(d=>d.selector===t);if(o===void 0)return A(t,r.groups.map(({selector:d})=>d));let a=K(e.worktreeText,o);if(a===void 0)return A(t,r.groups.map(({selector:d})=>d));let i=x(o.segments[0]),c=o.state==="unstaged"?void 0:{head:r.head,repositoryPath:r.repositoryPath,headStart:i.headStart,headEnd:i.headEnd,replacementText:i.headText};return{status:"applied",worktreeText:a,group:o,...c!==void 0&&{indexUpdate:c}}}async applyIndexUpdate(e,t){let r=await this.git.readTrackedRepositoryFile(e.repositoryPath,t);if(r.status!=="found")throw new Error(r.status==="untracked"?`${e.repositoryPath} is no longer tracked by HEAD`:r.message);if(r.head!==e.head)throw new Error(`Git HEAD changed while updating ${e.repositoryPath}`);let o=W(r.headText,r.indexText,e.headStart,e.headEnd,e.replacementText);o!==r.indexText&&await this.git.writeIndexFile(e.repositoryPath,r.indexMode,o,t)}};function A(n,e){return{status:"unavailable",reason:"stale-selector",message:`${n} is not available in the current file state`,availableSelectors:e}}s(A,"staleSelector");function pe(n){return n instanceof Error?n.message:String(n)}s(pe,"errorMessage");var T="pi-agent-ide-changes/change",fe=/^CHANGE#[0-9A-F]{4,64}$/,he=/^[A-Za-z][A-Za-z\d+.-]*:\/\//,G=class extends H{static{s(this,"ChangeTextAnchor")}constructor(e){super(e.selector,e.currentStartLine)}};function X(n){return{resolver:me(s(async t=>{if(he.test(t.source))return;let r=await f.create(n,t.cwd,t.signal);if(r.status!=="ready")throw new Error(r.message);return r.service.inspect({source:t.source,worktreeText:t.content,cwd:t.cwd,...t.signal!==void 0&&{signal:t.signal}})},"inspect"))}}s(X,"createChangeAnchorRegistration");function me(n){return{id:"git-change",description:"Use the complete `CHANGE#HASH` shown beside a current Git change.",renderFull(e){return e},renderCompact(e){return e},async tryResolve(e,t){if(!fe.test(e))return{kind:"not-handled"};try{let r=await n(t);if(r===void 0)return{kind:"not-handled"};if(r.status==="unavailable")return{kind:"failed",error:new Error(r.message)};let o=r.status==="applicable"?r.groups.find(a=>a.selector===e):void 0;return o===void 0?{kind:"rejected",rejection:{code:"stale",reason:`Change anchor ${e} is stale or unknown`}}:{kind:"resolved",anchor:new G(o)}}catch(r){return{kind:"failed",error:r}}}}}s(me,"createChangeAnchorResolver");import{diffLines as ye}from"diff";var xe="filesystem";function Z(n){return{id:"current-git-changes",async present(e,t){if(t.purpose!=="read"||t.resolvedBy!==xe)return e;let r=await f.create(n,t.cwd,t.signal);if(r.status!=="ready")return e;let o=await r.service.inspect({source:t.source,worktreeText:e.content,cwd:t.cwd,...t.signal!==void 0&&{signal:t.signal}});return o.status!=="applicable"?e:we(e,o.groups)}}}s(Z,"createCurrentChangePresenter");function we(n,e){let t=new Map;for(let r of e)be(n,r,t);return{...n,lines:n.lines.map(r=>ve(r,t.get(r.lineNumber)))}}s(we,"presentChangeGroups");function be(n,e,t){let r=x(e.segments[0]),o=ye(r.headText,r.worktreeText),a=e.currentStartLine,i,c;for(let d of o){let u=ke(d.value);if(d.removed){let l=Ce(n,a),g=R(t,l.lineNumber),p=l.after?g.after:g.before;for(let h of u){let w={kind:"synthetic",rows:p,index:p.length};p.push({marker:"-",prefix:"|",content:h}),i??=w,c=w}continue}if(d.added){for(let l of u){let g=R(t,a),p={kind:"current",lineNumber:a};g.added=!0,i??=p,c=p,a++}continue}a+=u.length}if(i!==void 0&&c!==void 0){let d=`${e.selector} \xB7 ${e.state}`;Te(i,c)?I(t,i,`<!-- change: ${d} -->`):(I(t,i,`<!-- change-begin: ${d} -->`),I(t,c,`<!-- change-end: ${d} -->`))}}s(be,"presentChangeGroup");function Te(n,e){return n.kind==="current"&&e.kind==="current"?n.lineNumber===e.lineNumber:n.kind==="synthetic"&&e.kind==="synthetic"?n.rows===e.rows&&n.index===e.index:!1}s(Te,"sameTarget");function I(n,e,t){if(e.kind==="current"){R(n,e.lineNumber).annotations.push(t);return}let r=x(e.rows[e.index]);e.rows[e.index]={...r,suffix:`${r.suffix??""} ${t}`}}s(I,"annotateTarget");function ve(n,e){if(e===void 0)return n;let t=e.annotations.length===0?"":` ${e.annotations.join(" ")}`;return{...n,presentation:{...n.presentation,...e.added&&{marker:"+"},before:[...n.presentation?.before??[],...e.before],after:[...e.after,...n.presentation?.after??[]],suffix:`${n.presentation?.suffix??""}${t}`}}}s(ve,"presentLine");function R(n,e){let t=n.get(e);if(t!==void 0)return t;let r={before:[],after:[],annotations:[],added:!1};return n.set(e,r),r}s(R,"presentationsFor");function Ce(n,e){return e<=n.lines.length?{lineNumber:Math.max(1,e),after:!1}:{lineNumber:n.lines.length,after:!0}}s(Ce,"placementFor");function ke(n){if(n.length===0)return[];let e=n.split(/\r\n|\r|\n/u);return e.at(-1)===""&&e.pop(),e}s(ke,"splitLines");var v=class{static{s(this,"IndexMutationQueue")}tail=Promise.resolve();run(e){let t=this.tail.then(e,e);return this.tail=t.then(()=>{},()=>{}),t}};import{createHash as Ee}from"node:crypto";import{realpathSync as Pe}from"node:fs";import te from"node:path";import{fileURLToPath as Ae}from"node:url";var k=class{static{s(this,"LastTextTransactionStore")}#e=new Map;observe(e){let t=J(e.resourceSource,e.cwd);if(e.postProcessing==="final"){let r=this.#e.get(t);r&&r.afterDigest===C(e.before.content)?this.#e.set(t,{...r,afterDigest:C(e.after.content)}):this.#e.delete(t);return}if(e.intent!=="edit"||!e.existed||e.before.content===e.after.content){this.#e.delete(t);return}this.#e.set(t,{before:e.before.content,afterDigest:C(e.after.content)})}restore(e,t,r){let o=J(e,t),a=this.#e.get(o);if(a===void 0)throw new Error(`No last text transaction is available for ${e}.`);if(a.afterDigest!==C(r))throw this.#e.delete(o),new Error(`${e} changed after its last text transaction; refusing to overwrite newer text.`);return a.before}};function J(n,e){return n.startsWith("file://")?ee(Ae(new URL(n))):/^[a-z][a-z\d+.-]*:/iu.test(n)?n:ee(te.resolve(e,n))}s(J,"sourceKey");function ee(n){try{return Pe.native(n)}catch{return te.normalize(n)}}s(ee,"canonicalFile");function C(n){return Ee("sha256").update(n).digest("hex")}s(C,"textDigest");import{readFile as Ge}from"node:fs/promises";import Ie from"node:path";import{defineTool as Re,withFileMutationQueue as Se}from"@earendil-works/pi-coding-agent";import{Type as S}from"typebox";var P=S.Object({file:S.String({description:"Path to the tracked text file"}),change:S.String({description:"Complete CHANGE#HASH anchor shown by read",pattern:"^CHANGE#[0-9A-F]{4,64}$"})},{additionalProperties:!1});function ne(n,e,t){n.registerTool(E("stage",e,t)),n.registerTool(E("unstage",e,t))}s(ne,"registerIndexChangeTools");function E(n,e,t){let r=n==="stage"?"staged":"unstaged",o=n==="stage"?"Staged":"Unstaged";return Re({name:n,label:n,promptSnippet:`${o.slice(0,-1)} a selected Git change`,description:`Use ${n} to ${n==="stage"?"add one current Git change to the index":"remove one current Git change from the index"}. Select the change with a CHANGE# anchor; worktree content is kept.`,parameters:P,async execute(a,i,c,d,u){let l=He(i.file,u.cwd);return Se(l,()=>t.run(async()=>{let g=await Ge(l,"utf8"),p=await f.create(e,u.cwd,c);if(p.status!=="ready")throw new Error(p.message);let h=await p.service.changeIndex({source:l,worktreeText:g,cwd:u.cwd,...c!==void 0&&{signal:c}},i.change,n);if(h.status==="unavailable")throw new Error(h.message);if(h.status==="not-applicable")throw new Error(`${n} is not applicable to ${l}: ${h.reason}`);let w=h.status==="unchanged";return{content:[{type:"text",text:w?`${i.change} is already ${r} in ${i.file}.`:`${o} ${i.change} in ${i.file}.`}],details:{action:n,change:i.change,file:l,state:r,unchanged:w}}}))}})}s(E,"createIndexChangeTool");function He(n,e){let t=n.startsWith("@")?n.slice(1):n;return Ie.resolve(e,t)}s(He,"resolveFile");import{diffChars as $e}from"diff";import{Type as y}from"typebox";var De=y.Object({file:y.Optional(y.String({description:"File to restore; may be omitted to inherit the previous batched source"})),change:y.Optional(y.String({description:"Complete CHANGE#HASH anchor shown by read, or last for this file's latest text-editor transaction",pattern:"^(?:CHANGE#[0-9A-F]{4,64}|last)$"})),transaction:y.Optional(y.String({description:"APPLY# receipt returned by a successful Apply transaction",pattern:"^APPLY#[0-9A-F]{12}$"}))},{additionalProperties:!1});function re(n,e,t,r){return{name:"undo",description:"Use undo to revert an APPLY# transaction receipt, a selected uncommitted Git change, or the latest text-editor transaction for one file. Apply receipts restore every touched path atomically; CHANGE# restores that change to HEAD in both worktree and index; last restores one file's latest text edit.",promptSnippet:"Restore an Apply transaction, Git change, or latest text edit",direct:{matches:s(o=>o!==null&&typeof o=="object"&&"transaction"in o&&typeof o.transaction=="string","matches"),async execute(o,a){if(a.change!==void 0)throw new Error("transaction cannot be combined with change");let i=String(a.transaction),c=await r(i,o.signal);return{source:i,summary:`Restored ${String(c.restored.length)} paths from ${i}.`,data:{kind:"apply-undo",ok:!0,transaction:i,restored:c.restored}}}},parameters:De,intent:"restore",source:{field:"file",inherited:!0},anchors:[{field:"change",sourceField:"file",kinds:[T],nonAnchorValues:["last"]}],async mutate(o,a){if(a.change===void 0)throw new Error("change is required when transaction is omitted");let i=o.sourceFor("file"),c,d;if(a.change==="last")c=e.restore(i,o.cwd,o.sourceDocument.content);else{await o.resolveAnchor("change");let u=await f.create(n,o.cwd,o.signal);if(u.status!=="ready")throw new Error(u.message);let l=await u.service.prepareUndo({source:i,worktreeText:o.sourceDocument.content,cwd:o.cwd,...o.signal!==void 0&&{signal:o.signal}},a.change);if(l.status!=="applied")throw l.status==="unavailable"?new Error(l.message):new Error(`Undo is not applicable to ${i}: ${l.reason}`);if(c=l.worktreeText,l.indexUpdate!==void 0){let g=l.indexUpdate;d=s(()=>t.run(()=>u.service.applyIndexUpdate(g,o.signal)),"afterWrite")}}return{edits:new Map([[i,{changes:Le(o.sourceDocument.content,c),action:"edited"}]]),...d!==void 0&&{afterWrite:d}}}}}s(re,"createUndoMutationTool");function Le(n,e){let t=[],r=0,o,a=0,i="",c=s(()=>{o!==void 0&&(t.push({from:o,to:o+a,insert:i}),o=void 0,a=0,i="")},"flush");for(let d of $e(n,e)){if(!d.added&&!d.removed){c(),r+=d.value.length;continue}o??=r,d.removed?(r+=d.value.length,a+=d.value.length):i+=d.value}return c(),t}s(Le,"createTextChanges");async function Oe(n){U(n,[await O({id:"git-changes",description:"Git change anchors, staging, and safe undo",triggers:["stage","unstage","undo"].map(d=>({tool:d}))})]);let e=q(n),t=new k,r=new v,o=Z(e),a=X(e),i={protocol:j,apiVersion:M,id:"current-git-changes",setup(d){d.addView({view:"changes",presenter:o}),d.describe('views: ["changes"] \u2014 uncommitted edits in tracked files, staged/unstaged state, and CHANGE# anchors for stage, unstage and undo.')}},c={protocol:B,apiVersion:V,id:"current-git-changes",setup(d){d.addAnchorResolver({...a,kind:T,type:"auxiliary"}),d.onDidEdit(u=>{t.observe(u)}),d.addMutationTool(re(e,t,r,d.restoreApplyUndo));for(let u of["stage","unstage"]){let l=E(u,e,r);d.addScriptIndexOperation({name:u,parameters:P,execute:s((g,p,h)=>l.execute(`apply-${u}`,Ne.Decode(P,g),p,void 0,h),"execute")})}d.addTextPresenter({presenter:o})}};await Promise.all([F(n,Y),_(n,i),z(n,c)]),ne(n,e,r)}s(Oe,"registerGitChanges");export{Oe as default};
|