pi-agent-ide 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/README.md +81 -23
- 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 +1 -0
- package/dist/{chunk-LY6U5EAD.js → chunk-2527OQ4Y.js} +1 -1
- package/dist/chunk-3XJ3KDPZ.js +16 -0
- package/dist/chunk-5JELU6RV.js +7 -0
- package/dist/chunk-DDKHZZDO.js +5 -0
- package/dist/chunk-FEDVTZJG.js +1 -0
- package/dist/chunk-HSM6R7IB.js +27 -0
- package/dist/chunk-K5G4FDXD.js +1 -0
- package/dist/chunk-M5IVSCR2.js +1 -0
- package/dist/chunk-OYWIZII6.js +1 -0
- package/dist/chunk-P7XO5CIP.js +2 -0
- package/dist/chunk-PCZH7GOX.js +26 -0
- package/dist/{chunk-DQXPQOF7.js → chunk-SQ7ZTGOP.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 -0
- package/dist/entry-18.js +1 -1
- package/dist/entry-19.js +1 -1
- package/dist/entry-20.js +1 -1
- package/dist/entry-21.js +1 -1
- package/dist/entry-22.js +1 -2
- package/dist/entry-23.js +2 -1
- package/dist/entry-24.js +1 -1
- package/dist/entry-25.js +1 -1
- package/dist/entry-26.js +1 -1
- package/dist/entry-27.js +1 -12
- package/dist/entry-28.js +12 -1
- package/dist/entry-29.js +1 -1
- package/dist/entry-30.js +1 -1
- package/dist/entry-31.js +1 -1
- package/dist/entry-32.js +1 -4
- package/dist/entry-33.js +3 -8
- package/dist/entry-34.js +9 -1
- package/dist/entry-35.js +1 -1
- package/dist/entry-36.js +1 -1
- package/dist/entry-37.js +1 -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 -18
- package/dist/entry-42.js +18 -1
- package/dist/entry-43.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +1 -1
- package/dist/entry-46.js +1 -7
- package/dist/entry-47.js +7 -11
- package/dist/entry-48.js +11 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +1 -1
- package/dist/entry-51.js +1 -1
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-54.js +1 -1
- package/dist/entry-55.js +1 -1
- package/dist/entry-56.js +1 -0
- package/dist/entry-57.js +0 -1
- package/dist/entry-58.js +1 -0
- package/dist/entry-59.js +0 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-61.js +1 -1
- package/dist/entry-62.js +1 -1
- package/dist/entry-63.js +1 -1
- package/dist/entry-64.js +1 -1
- package/dist/entry-65.js +1 -0
- package/dist/entry-66.js +0 -1
- package/dist/entry-67.js +1 -0
- package/dist/entry-68.js +0 -1
- package/dist/entry-69.js +1 -1
- package/dist/entry-70.js +1 -1
- package/dist/entry-71.js +1 -203
- package/dist/entry-72.js +254 -25
- package/dist/entry-73.js +30 -2
- package/dist/entry-74.js +2 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-76.js +1 -1
- package/dist/entry-77.js +3 -3
- package/dist/entry-78.js +3 -1
- package/dist/entry-79.js +1 -1
- package/dist/entry-80.js +1 -1
- package/dist/entry-81.js +1 -0
- package/dist/pi-agent-ide.js +3 -3
- package/docs/configuration.md +3 -1
- package/docs/development.md +0 -6
- package/docs/tools.md +12 -0
- package/node_modules/pi-agent-doctor/package.json +6 -6
- package/node_modules/pi-agent-doctor/runtime/entry-22.js +1 -0
- 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-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-26.js +2 -0
- package/node_modules/pi-agent-ide-ast/package.json +12 -11
- package/node_modules/pi-agent-ide-ast/runtime/entry-27.js +0 -1
- package/node_modules/pi-agent-ide-ast/runtime/entry-28.js +2 -0
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +8 -6
- package/node_modules/pi-agent-ide-changes/package.json +8 -8
- package/node_modules/pi-agent-ide-changes/runtime/entry-29.js +0 -1
- package/node_modules/pi-agent-ide-formatter/package.json +4 -4
- package/node_modules/pi-agent-ide-languages/package.json +3 -3
- package/node_modules/pi-agent-ide-lint/package.json +8 -8
- package/node_modules/pi-agent-ide-lint/src/command-linter.ts +3 -1
- package/node_modules/pi-agent-ide-lsp/package.json +10 -10
- package/node_modules/pi-agent-ide-lsp/runtime/entry-34.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 +11 -11
- package/node_modules/pi-agent-read/runtime/entry-41.js +0 -1
- package/node_modules/pi-agent-read/runtime/entry-42.js +2 -0
- package/node_modules/pi-agent-read/src/api/read-parameters.ts +2 -2
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +11 -6
- package/node_modules/pi-agent-resource/package.json +2 -2
- package/node_modules/pi-agent-search/package.json +7 -7
- package/node_modules/pi-agent-search/runtime/entry-46.js +0 -1
- package/node_modules/pi-agent-search-text/package.json +9 -9
- package/node_modules/pi-agent-search-text/runtime/entry-48.js +1 -0
- package/node_modules/pi-agent-search-text/src/resolvers.ts +32 -27
- package/node_modules/pi-agent-search-text/src/search-session.ts +27 -1
- package/node_modules/pi-agent-text/package.json +3 -3
- package/node_modules/pi-agent-text/runtime/entry-50.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-51.js +2 -0
- package/node_modules/pi-agent-text-anchor-exact/index.ts +3 -3
- package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-52.js +0 -1
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-53.js +2 -0
- package/node_modules/pi-agent-text-anchor-exact/src/config.ts +2 -2
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-54.js +0 -1
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-55.js +2 -0
- package/node_modules/pi-agent-text-editor/package.json +25 -25
- package/node_modules/pi-agent-text-editor/runtime/entry-71.js +0 -1
- package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +125 -3
- package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +14 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +32 -3
- package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +21 -19
- package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +37 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +85 -34
- package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +2 -3
- package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +589 -241
- package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +5 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-config.ts +3 -3
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +9 -1
- package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +53 -0
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +11 -41
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +8 -18
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +11 -41
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -19
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-74.js +2 -0
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-76.js +1 -0
- package/node_modules/pi-agent-web/package.json +7 -7
- package/node_modules/pi-agent-web/src/resolver.ts +128 -1
- package/node_modules/pi-agent-web-html/package.json +3 -3
- package/node_modules/pi-agent-web-image/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/node_modules/pi-agent-web-text/runtime/entry-81.js +2 -0
- package/package.json +44 -39
- package/src/api/path-identity.ts +15 -0
- package/src/composite/builtin-extensions.ts +7 -2
- package/src/composite/module-labels.ts +4 -0
- package/src/composite/module-settings.ts +34 -14
- package/src/composite/preferences.ts +46 -3
- package/src/composite/selection.ts +5 -1
- package/src/doctor/inventory.ts +7 -2
- 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-pdf/package.json +4 -4
- 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-26.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-23.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
- 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-81.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-77.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/resolver.ts +128 -1
- package/src/extensions/pi-agent-read/package.json +11 -11
- package/src/extensions/pi-agent-read/runtime/entry-41.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-42.js +2 -0
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +2 -2
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +11 -6
- package/src/extensions/pi-agent-search/package.json +7 -7
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +9 -9
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-48.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-49.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +32 -27
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +27 -1
- package/src/extensions/pi-agent-search/runtime/entry-46.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-47.js +2 -0
- package/src/extensions/pi-agent-text-editor/package.json +25 -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-51.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/index.ts +3 -3
- 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-52.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-53.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/config.ts +2 -2
- 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-54.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-55.js +2 -0
- 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-stale-anchor/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-74.js +2 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-71.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-72.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +125 -3
- package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +14 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +32 -3
- package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +21 -19
- package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +37 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +85 -34
- package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +2 -3
- package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +589 -241
- package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +5 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-config.ts +3 -3
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +9 -1
- package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +53 -0
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +11 -41
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +8 -18
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +11 -41
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -19
- package/src/pi-agent-ide.ts +15 -2
- package/src/plugins/pi-agent-ide-ast/package.json +12 -11
- package/src/plugins/pi-agent-ide-ast/runtime/entry-27.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-28.js +2 -0
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +8 -6
- package/src/plugins/pi-agent-ide-changes/package.json +8 -8
- package/src/plugins/pi-agent-ide-changes/runtime/entry-29.js +0 -1
- package/src/plugins/pi-agent-ide-debugger/index.ts +3 -9
- package/src/plugins/pi-agent-ide-debugger/src/adapter-executables.ts +31 -0
- package/src/plugins/pi-agent-ide-debugger/src/breakpoint-view.ts +3 -1
- package/src/plugins/pi-agent-ide-debugger/src/catalog.ts +24 -23
- package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +5 -2
- package/src/plugins/pi-agent-ide-debugger/src/doctor-plugin.ts +55 -17
- package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +55 -22
- package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
- package/src/plugins/pi-agent-ide-languages/package.json +3 -3
- package/src/plugins/pi-agent-ide-lint/package.json +8 -8
- package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +3 -1
- package/src/plugins/pi-agent-ide-lsp/package.json +10 -10
- package/src/plugins/pi-agent-ide-lsp/runtime/entry-34.js +2 -0
- package/src/plugins/pi-agent-ide-processes/src/registry.ts +6 -0
- package/src/plugins/pi-agent-ide-processes/src/ui.ts +28 -11
- package/src/plugins/pi-agent-ide-terminal/index.ts +1 -1
- package/src/plugins/pi-agent-ide-terminal/src/process-provider.ts +2 -0
- package/src/plugins/pi-agent-ide-terminal/src/search.ts +32 -2
- package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +5 -4
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +2 -2
- package/src/plugins/pi-agent-ide-terminal/src/types.ts +3 -1
- package/src/plugins/pi-agent-ide-terminal/src/ui.ts +1 -1
- package/src/plugins/pi-agent-ide-vision/index.ts +232 -0
- package/src/plugins/pi-agent-ide-vision/src/vision.ts +530 -0
- package/src/plugins/pi-agent-ide-vision/src/windows-display-capture.ps1 +30 -0
- package/src/plugins/pi-agent-ide-vision/src/windows-window-capture.ps1 +33 -0
- package/dist/chunk-5PLV4HLG.js +0 -1
- package/dist/chunk-BGUSBUUD.js +0 -26
- package/dist/chunk-G725MARR.js +0 -16
- package/dist/chunk-HKXDP2FD.js +0 -7
- package/dist/chunk-J4RTW44E.js +0 -1
- package/dist/chunk-QH4ZUDOD.js +0 -1
- package/dist/chunk-WGGIQ7IJ.js +0 -1
- package/dist/chunk-ZG2MWXCR.js +0 -2
- package/dist/chunk-ZUMN6U77.js +0 -27
- package/dist/entry-17.js +0 -1
- package/docs/evaluation.md +0 -14
- package/node_modules/pi-agent-doctor/runtime/entry-17.js +0 -1
- package/node_modules/pi-agent-filesystem/runtime/entry-22.js +0 -2
- package/node_modules/pi-agent-ide-ast/runtime/entry-26.js +0 -1
- package/node_modules/pi-agent-ide-changes/runtime/entry-28.js +0 -1
- package/node_modules/pi-agent-image/runtime/entry-34.js +0 -1
- package/node_modules/pi-agent-resource/runtime/entry-42.js +0 -1
- package/node_modules/pi-agent-text-anchor-constant/runtime/entry-50.js +0 -2
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-51.js +0 -1
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-53.js +0 -1
- package/node_modules/pi-agent-text-editor/runtime/entry-55.js +0 -1
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-74.js +0 -1
- package/node_modules/pi-agent-web/runtime/entry-76.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-23.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-22.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-77.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-76.js +0 -2
- package/src/extensions/pi-agent-read/runtime/entry-37.js +0 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-47.js +0 -2
- package/src/extensions/pi-agent-search/runtime/entry-43.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-50.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-51.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-53.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-72.js +0 -2
- package/src/extensions/pi-agent-text-editor/runtime/entry-55.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-26.js +0 -1
- package/src/plugins/pi-agent-ide-changes/runtime/entry-28.js +0 -1
- /package/node_modules/{pi-agent-filesystem-image → pi-agent-filesystem}/runtime/entry-23.js +0 -0
- /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-24.js +0 -0
- /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-25.js +0 -0
- /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-30.js +0 -0
- /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-31.js +0 -0
- /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-32.js +0 -0
- /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-33.js +0 -0
- /package/node_modules/{pi-agent-invariant → pi-agent-image}/runtime/entry-35.js +0 -0
- /package/node_modules/{pi-agent-pdf → pi-agent-invariant}/runtime/entry-36.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-37.js +0 -0
- /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-43.js +0 -0
- /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-47.js +0 -0
- /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-49.js +0 -0
- /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor}/runtime/entry-72.js +0 -0
- /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-73.js +0 -0
- /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-75.js +0 -0
- /package/node_modules/{pi-agent-web-html → pi-agent-web}/runtime/entry-77.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-78.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-79.js +0 -0
- /package/node_modules/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-80.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-24.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-25.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-78.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-79.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-80.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-73.js +0 -0
- /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-30.js +0 -0
- /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-31.js +0 -0
- /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-32.js +0 -0
- /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-33.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.0 — 2026-09-16
|
|
4
|
+
|
|
5
|
+
### Agent vision
|
|
6
|
+
|
|
7
|
+
- Let agents discover running processes and read process metadata.
|
|
8
|
+
- Let agents inspect application windows, full displays, and rendered web pages as images. Agent-owned windows are available by default; arbitrary windows and full displays require separate opt-in settings.
|
|
9
|
+
- Add image sequences for observing changing interfaces and media over time.
|
|
10
|
+
- Let agents choose sequence duration, frame interval, image scale, normalized image regions, and grid cells.
|
|
11
|
+
- Add executable allowlists for desktop applications that agents may inspect without unrestricted window access.
|
|
12
|
+
- Support Linux and macOS capture through `node-screenshots`, plus visible Windows-host windows and displays from WSL.
|
|
13
|
+
|
|
14
|
+
### Apply
|
|
15
|
+
|
|
16
|
+
- Keep successful independent changes when another operation in the same transaction fails, and report the outcome of each operation.
|
|
17
|
+
- Add selection-set replacements, removals, copies, and moves for exact matches and structural-search results.
|
|
18
|
+
- Add whole-file create, copy, move, and delete operations to Apply scripts.
|
|
19
|
+
- Refresh open files after `flush()`, preserve line endings for line-based edits, and skip post-processing for files that were subsequently moved or deleted.
|
|
20
|
+
|
|
21
|
+
### Windows
|
|
22
|
+
|
|
23
|
+
- Add native Windows support for Agent IDE debugger workflows, filesystem identity, language detection, command launchers, and executable discovery.
|
|
24
|
+
- Improve debugger support across the Windows language toolchains that are available on the machine.
|
|
25
|
+
|
|
26
|
+
### Settings
|
|
27
|
+
|
|
28
|
+
- Add editable settings for sequence duration, frame interval, image scale, and allowed executable names.
|
|
29
|
+
|
|
30
|
+
## 0.5.1 — 2026-09-14
|
|
31
|
+
|
|
32
|
+
### Sessions and processes
|
|
33
|
+
|
|
34
|
+
- Keep active terminal and debugger resources alive across extension reloads, so agents can reconnect to the same `shell:` and `debug:` sessions.
|
|
35
|
+
- Add terminal input mode to the process panel. Press `i` in a terminal detail view to send text and keys, and press Escape to return to the normal view.
|
|
36
|
+
- Keep foreground terminal waits running in the background when an agent turn is interrupted instead of reporting them as aborted.
|
|
37
|
+
- Bound terminal-search output in the TUI while keeping the complete search result available to the agent.
|
|
38
|
+
|
|
39
|
+
### Reading and search
|
|
40
|
+
|
|
41
|
+
- Return a bounded hex and ASCII preview for unsupported HTTP binary responses instead of downloading the full body or failing without useful content.
|
|
42
|
+
- Preserve native image reads when a server reports a generic binary content type for a known image URL.
|
|
43
|
+
- Keep search results when a file or terminal log changes during the search. Stale results remain visible, but unsafe anchors are omitted.
|
|
44
|
+
|
|
3
45
|
## 0.5.0 — 2026-09-13
|
|
4
46
|
|
|
5
47
|
### Debugging
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
<h1 align="center">Pi Agent IDE</h1>
|
|
6
6
|
|
|
7
|
-
<p align="center">Agent
|
|
7
|
+
<p align="center">Pi Agent IDE is an agent-native IDE extension for the <a href="https://pi.dev/">Pi coding agent</a>. It adds guarded editing, code search, AST/LSP navigation, persistent terminals, debugging, transactional changes, and observability tools.</p>
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
10
|
<a href="https://www.npmjs.com/package/pi-agent-ide"><img src="https://img.shields.io/npm/v/pi-agent-ide" alt="npm version"></a>
|
|
@@ -12,31 +12,87 @@
|
|
|
12
12
|
<a href="https://github.com/alexshpunt/pi-agent-ide/actions/workflows/ci.yml"><img src="https://github.com/alexshpunt/pi-agent-ide/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI status"></a>
|
|
13
13
|
<a href="https://github.com/alexshpunt/pi-agent-ide/actions/workflows/ci.yml"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2Falexshpunt%2F0d28d39557e2a9976c4548e7737c102d%2Fraw%2Funit.json" alt="Unit test count"></a>
|
|
14
14
|
<a href="https://github.com/alexshpunt/pi-agent-ide/actions/workflows/ci.yml"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2Falexshpunt%2F0d28d39557e2a9976c4548e7737c102d%2Fraw%2Fintegration.json" alt="Integration test count"></a>
|
|
15
|
+
<a href="https://huggingface.co/spaces/alexshpunt/benchmark-explorer?card=harness%3Api-agent-ide%40latest"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fhuggingface.co%2Fdatasets%2Falexshpunt%2Fexplicit-edit-benchmark%2Fresolve%2Fmain%2Fbadges%2Fpi-agent-ide.json" alt="Explicit Edit Benchmark score"></a>
|
|
15
16
|
<a href="./LICENSE"><img src="https://img.shields.io/npm/l/pi-agent-ide" alt="MIT license"></a>
|
|
16
17
|
</p>
|
|
17
18
|
|
|
18
|
-
##
|
|
19
|
+
## Summary
|
|
19
20
|
|
|
20
|
-
Pi Agent IDE is
|
|
21
|
+
Pi Agent IDE is a set of agent-facing tools built to give a coding agent the same practical capabilities that a programmer expects from an IDE.
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
There are two common views of coding agents. One says that an agent only needs a shell and can build everything else for itself. The other says that useful tooling makes an agent more effective. Both are partly right. Stronger models can often make precise edits and recover with little help. Smaller models are more likely to lose context, choose an unsafe edit, or fail on the mechanics of the task. Pi Agent IDE gives models direct tools without taking the shell away.
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
The project started as another take on hash-based editing. It later brought back edits by exact string occurrence, with every occurrence checked before a change is applied. The result is a hybrid approach rather than one required selection method.
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
## Gallery
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
-
|
|
35
|
-
- `/agent-ide-processes` shows terminal and debugger activity, while `/pi-agent-ide-doctor` checks the languages and tools available in the current project.
|
|
29
|
+
| Read and guarded tool editing | Transactional Apply |
|
|
30
|
+
| --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
31
|
+
|  |  |
|
|
32
|
+
| Web reading | Search and replace |
|
|
33
|
+
|  |  |
|
|
34
|
+
| Background processes | Source-level debugging |
|
|
35
|
+
|  |  |
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
## Core principles
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
### One interface for each intent
|
|
40
|
+
|
|
41
|
+
The agent should express what it wants to do without choosing a different tool for every implementation behind it.
|
|
42
|
+
|
|
43
|
+
`read` is the main interface to the environment. It reads text, source code, raw bytes, web pages, images, PDFs, terminal sessions, debugger sessions, diagnostics, running processes, application windows, and full displays. The same interface can ask for AST structure, language-server information, anchors, or other views. The agent chooses the information it needs while the parsing, conversion, and resource handling stay behind one facade.
|
|
44
|
+
|
|
45
|
+
`search` follows the same rule. It searches files, text, symbols, syntax trees, and supported live resources through one interface.
|
|
46
|
+
|
|
47
|
+
Editing tools state concrete intentions such as `write`, `replace`, `insert`, `delete`, `copy`, and `move`. Simple edits use guarded operations that verify the selected text or resource. Independent edits can be submitted together as a tool-call batch. For conditional or multi-file work, `apply` gives the agent isolated JavaScript over immutable file snapshots and the same guarded editing model, then validates and commits the staged changes as one transaction. This lets models use scripts for complex work without reducing an edit to an unchecked rewrite.
|
|
48
|
+
|
|
49
|
+
### IDE tools
|
|
50
|
+
|
|
51
|
+
The shell remains available, but it behaves like part of an IDE. The agent can start long-running and interactive processes, leave them in the background, reconnect after an extension reload, and receive completion or stale-process notifications. Aborting an agent turn does not kill the process.
|
|
52
|
+
|
|
53
|
+
Debugger sessions are also addressable resources. The agent can set breakpoints, inspect source and variables, step through a program, and reconnect after a reload. Formatting, diagnostics, AST views, language-server views, terminal output, and debugger state work through the same resource model. This support is currently focused on Linux and WSL.
|
|
54
|
+
|
|
55
|
+
Agent vision uses that resource model instead of adding a separate screenshot workflow. The agent can discover a process, inspect its metadata, read an application window, capture a full display, or render a web page through `read`. Image and sequence views support downscaling, normalized regions, and grid-cell selection, so the model can inspect a useful area without loading every source pixel. Window and display access is guarded by ownership, executable allowlists, and separate opt-in settings.
|
|
56
|
+
|
|
57
|
+
### Extensible by protocol
|
|
58
|
+
|
|
59
|
+
The visible tools stay small because their internals are protocols. HTTP reads, filesystem reads, terminal and debugger resources, file formats, AST views, language-server views, converters, search backends, anchors, formatters, and diagnostics can be added or replaced independently.
|
|
60
|
+
|
|
61
|
+
The goal is simple primitives on the outside and composable complexity on the inside. New capabilities should extend an existing intent-shaped interface instead of adding another one-off tool.
|
|
62
|
+
|
|
63
|
+
### Make recovery cheap
|
|
64
|
+
|
|
65
|
+
Agents can edit through exact strings, hash anchors, search results, AST matches, and language-server symbols. If one method fails, the tool explains why, shows the available alternatives, and points the agent to a more precise method. The goal is not to punish a bad selection with stricter guardrails. Smaller models will make mistakes. Recovery should cost as little time and context as possible.
|
|
66
|
+
|
|
67
|
+
The tools are designed to combine. A common flow is `search` followed by `replace`: the agent finds the intended occurrences, then edits all selected matches in one guarded operation. The same model supports structural changes and renames through search, AST, and LSP without requiring a separate workflow for each one.
|
|
68
|
+
|
|
69
|
+
### Observability
|
|
70
|
+
|
|
71
|
+
Powerful agents still need to be observable. A person should be able to see whether the harness is efficient, whether the agent is solving the real task, which tools fit its work, and where weak points or corner cases appear.
|
|
72
|
+
|
|
73
|
+
This is more than presentation. Observable behavior provides the evidence that drives tool design, regression fixes, and benchmark work.
|
|
74
|
+
|
|
75
|
+
### Data-driven development
|
|
76
|
+
|
|
77
|
+
Daily use and judgement still matter, but features should not be built on vibes alone. Changes are measured on real tasks to find where agents fail, which model families work better or worse with the tools, and how Pi Agent IDE compares with other harnesses.
|
|
78
|
+
|
|
79
|
+
The [Explicit Edit Benchmark](https://github.com/alexshpunt/explicit-edit-benchmark) was created for this purpose. It measures how easily agents can use editing tools on exact, deterministic tasks. These tasks are especially useful for smaller models and models with limited reasoning, where tool design has a larger effect on reliability.
|
|
80
|
+
|
|
81
|
+
Version 0.5.1 scores **93.8%** on `gpt-5.6-luna` with low reasoning: 224 of the 226 tasks solved
|
|
82
|
+
in the end, 208 of them on the first attempt. The full observation, including the two tasks it
|
|
83
|
+
did not solve, is in the [published data](https://huggingface.co/datasets/alexshpunt/explicit-edit-benchmark).
|
|
84
|
+
|
|
85
|
+
Agent results are stochastic and no benchmark captures everything. We publish the score we actually get and build broader statistics instead of selecting only favorable runs.
|
|
86
|
+
|
|
87
|
+
Pi Agent IDE is experimental and under active development. Interfaces and behavior may change.
|
|
88
|
+
|
|
89
|
+
## Customization
|
|
90
|
+
|
|
91
|
+
Pi Agent IDE follows Pi's permissive, YOLO-style default: the agent can use the tools without asking for approval at every step. You can make it as strict as your work requires.
|
|
92
|
+
|
|
93
|
+
- [Settings](./docs/configuration.md) control built-in tools, project mappings, search, and presentation.
|
|
94
|
+
- [File hooks](./docs/user-hooks.md) can inspect, change, or deny reads and edits.
|
|
95
|
+
- [Extensions](./docs/extensions.md) can add or replace protocols, resolvers, anchors, search backends, and other behavior.
|
|
40
96
|
|
|
41
97
|
## Installation
|
|
42
98
|
|
|
@@ -50,7 +106,7 @@ Pi packages run with your full system permissions. Review the package before ins
|
|
|
50
106
|
|
|
51
107
|
## Check project tools
|
|
52
108
|
|
|
53
|
-
Pi Agent IDE includes formatter, linter, and
|
|
109
|
+
Pi Agent IDE includes formatter, linter, LSP, and debugger mappings. It finds each tool from the project that owns the file, including project-local binaries and commands on your `PATH`. Settings from one project do not leak into another.
|
|
54
110
|
|
|
55
111
|
Start Pi in your project directory, then run:
|
|
56
112
|
|
|
@@ -66,20 +122,22 @@ Doctor also reports optional system Chrome/Chromium support for browser-rendered
|
|
|
66
122
|
|
|
67
123
|
Run doctor again after installing or changing project tools. For configuration paths, precedence, and command flags, see [Configuration](./docs/configuration.md#doctor).
|
|
68
124
|
|
|
125
|
+
## Feedback and contributions
|
|
126
|
+
|
|
127
|
+
Pi Agent IDE is used actively in real development, but I can only reproduce the models, tools, environments, and workflows available to me. Everyone works differently, and I cannot find or cover every case on my own. I can fix problems when I encounter them or when someone reports them.
|
|
128
|
+
|
|
129
|
+
If something breaks, behaves badly, or does not fit your workflow, please [open an issue](https://github.com/alexshpunt/pi-agent-ide/issues). Bug reports, ideas, and questions are welcome. Pull requests are welcome too. Every contribution will be considered, and I am fully open to making the project much better with help from its users.
|
|
130
|
+
|
|
69
131
|
## Documentation
|
|
70
132
|
|
|
71
133
|
| Document | Contents |
|
|
72
134
|
| ------------------------------------------ | -------------------------------------------------------------------- |
|
|
73
|
-
| [Tools and workflow](./docs/tools.md) | Read, search, editing, anchors, and feedback
|
|
135
|
+
| [Tools and workflow](./docs/tools.md) | Read, vision, search, editing, anchors, and feedback |
|
|
74
136
|
| [Architecture](./docs/architecture.md) | Module boundaries, protocols, and the umbrella extension |
|
|
75
137
|
| [Configuration](./docs/configuration.md) | Run doctor, configure project tools and search, or disable built-ins |
|
|
138
|
+
| [File hooks](./docs/user-hooks.md) | Inspect, change, or deny reads and edits |
|
|
76
139
|
| [Writing extensions](./docs/extensions.md) | Add resolvers, anchors, search backends, and IDE plugins |
|
|
77
140
|
| [Development](./docs/development.md) | Work from a checkout, test, and run modular mode |
|
|
78
|
-
| [Evaluation](./docs/evaluation.md) | Compare Pi Agent IDE with vanilla Pi on repeatable tasks |
|
|
79
|
-
|
|
80
|
-
## Repository
|
|
81
|
-
|
|
82
|
-
Executable behavior is defined by the source and tests. The documents above explain the intended boundaries, extension contracts, and development workflows.
|
|
83
141
|
|
|
84
142
|
## License
|
|
85
143
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as s}from"./chunk-S3ZPXWX7.js";import{a as o}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as i}from"typebox/value";import{Type as n}from"typebox";var l=n.Object({path:n.Optional(n.String({description:"What to read: a file or directory path, URL, returned temp: or SEARCH# reference, or one of the source forms listed in the description. Supply a path; an empty call cannot select a source."})),offset:n.Optional(n.Number({description:"For raw: sources, use a zero-based byte offset; negative offsets count from the file end. For other sources: first line to return, numbered from 1. Omit or use 0 to start at line 1; -1 starts at the last line, -10 at the tenth line from the end. For path#anchor or a SEARCH selection, count from its containing line instead: 0 or 1 starts there, 2 starts one line later, -1 one line earlier. For image and sequence views, offset is a zero-based row-major grid cell index and requires limit."})),limit:n.Optional(n.Number({description:"For raw: sources, use a non-negative byte count (0 reads no bytes). Otherwise, maximum lines from the selected starting position. Output is bounded; omit for the default read. For image and sequence views, limit is the square grid cell size in pixels; omit offset to select cell 0, or omit both for the bounded full image."})),views:n.Optional(n.Array(n.String(),{description:`Optional additions to the returned text. Use the views listed in the tool description. Combine views when needed, for example ["anchors", "ast"] for source text with editable line references and scope boundaries. Omit for the source's default presentation.`}))});var a=e.Function([],e.Unknown()),u=e.Object({resolver:e.Unknown(),matchesCall:e.Optional(a),renderCall:e.Optional(a),priority:e.Optional(e.Number()),renderResult:e.Optional(a),preserveTruncatedOutput:e.Optional(e.Boolean())}),R=e.Object({resolver:e.Unknown(),priority:e.Optional(e.Number())}),c=e.Object({id:e.String({pattern:"\\S"}),priority:e.Optional(e.Number()),resolve:a}),y=e.Object({view:e.String({pattern:"\\S"}),includes:e.Optional(e.Array(e.String({pattern:"\\S"}))),presenter:e.Object({id:e.String(),present:a}),priority:e.Optional(e.Number())}),p=e.Object({resolvedBy:e.String({pattern:"\\S"}),contentKind:e.Union([e.Literal("text"),e.Literal("any")])}),g=e.Union([e.Object({stage:e.Literal("pre-read"),handler:a}),e.Object({stage:e.Literal("read"),when:p,handler:a}),e.Object({stage:e.Literal("post-read"),handler:a})]);function T(t){if(!i.Check(R,t))return!1;let r=t,d=r.resolver;return typeof d.id=="string"&&d.id.length>0&&typeof d.tryResolve=="function"&&(!("priority"in r)||typeof r.priority=="number")}o(T,"isTextTargetResolverRegistration");function O(t){if(!i.Check(u,t))return!1;let r=t;return s(r.resolver)?r.resolver.id!=="any"&&(!("priority"in r)||typeof r.priority=="number")&&(!("matchesCall"in r)||typeof r.matchesCall=="function")&&(!("renderCall"in r)||typeof r.renderCall=="function")&&"matchesCall"in r=="renderCall"in r&&(!("renderResult"in r)||typeof r.renderResult=="function"):!1}o(O,"isResourceResolverRegistration");function S(t){return i.Check(g,t)}o(S,"isReadHandlerRegistration");function C(t){return i.Check(y,t)}o(C,"isReadViewRegistration");function k(t){return i.Check(c,t)}o(k,"isFragmentResolverRegistration");function w(t){return m(t)?t.kind==="not-handled"?!0:t.kind==="failed"?typeof t.message=="string"&&t.message.length>0:t.kind==="resolved"&&typeof t.originLine=="number":!1}o(w,"isReadFragmentResolution");function m(t){return typeof t=="object"&&t!==null}o(m,"isRecord");export{l as a,T as b,O as c,S as d,C as e,k as f,w as g};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as j,
|
|
1
|
+
import{a as j,m as M}from"./chunk-FEDVTZJG.js";import{a as _}from"./chunk-L7JMDDSD.js";import{a as N,b as O}from"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import"./chunk-5VSE5X5R.js";import{a as C,b as R,c as A,d as $,g as F}from"./chunk-Z3VC3S2T.js";import{a as k}from"./chunk-ZC65Z3CK.js";import{a as c}from"./chunk-EI7MMDWY.js";var h=[],y=[],P=[];function b(n,t,e){if(t.some(i=>i.name===e))throw new Error(`[pi-agent-ide] ${n} "${e}" is already registered. Use a unique name.`)}c(b,"assertUniqueName");function q(n){let t=new Set;for(let e of n){let i=`${e.kind}:${e.name}`;if(t.has(i))throw new Error(`[pi-agent-ide] ${e.kind} "${e.name}" is registered twice by one plugin.`);switch(t.add(i),e.kind){case"compiler":{b(e.kind,y,e.name);break}case"formatter":{b(e.kind,h,e.name);break}case"linter":{b(e.kind,P,e.name);break}}}for(let e of n)switch(e.kind){case"compiler":{y.push(e);break}case"formatter":{h.push(e);break}case"linter":{P.push(e);break}}}c(q,"registerTools");async function L(n,t){let e=[];for(let i of n)try{await i.detect(t)&&e.push(i)}catch(o){console.error(`[pi-agent-ide] detect failed for "${i.name}":`,o)}return e.sort((i,o)=>o.priority-i.priority),H(e),e}c(L,"filterActive");function H(n){let t=new Map;for(let e of n)for(let i of e.extensions){let o=`${i}@${e.priority}`,a=t.get(o);if(a!==void 0)throw new Error(`[pi-agent-ide] priority conflict: tools "${a}" and "${e.name}" both claim "${i}" at priority ${e.priority}.`);t.set(o,e.name)}}c(H,"assertNoPriorityConflicts");async function G(n){let[t,e]=await Promise.all([L(h,n),L(y.filter(i=>i.syntaxOnly===!0),n)]);return{ctx:n,formatters:t,compilers:e,linters:[]}}c(G,"warmupFormatting");function T(){h.length=0,y.length=0,P.length=0}c(T,"resetRegistry");import{readFile as D}from"node:fs/promises";import g from"node:path";var v=class{constructor(t,e={}){this.sources=t;this.options=e}static{c(this,"DiagnosticStore")}files=new Map;dirty=new Set;sent=new Map;queue=[];running=0;disposed=!1;changeListeners=new Set;onDidChange(t){return this.changeListeners.add(t),()=>this.changeListeners.delete(t)}schedule(t,e,{cwd:i}){this.disposed||this.ensure(t,e,i)}async read(t,{cwd:e,mode:i,signal:o}){o?.throwIfAborted(),this.assertActive();let a=g.resolve(e,t),s=await D(a,"utf8");this.assertActive();let r=this.ensure(a,s,e);i==="complete"?await this.waitComplete(r,o):i!=="snapshot"&&await K(Promise.all(r.jobs),this.options.readWaitMs??5e3),o?.throwIfAborted(),this.assertActive();let d=await D(a,"utf8");this.assertActive();let l=this.ensure(a,d,e);if(i==="complete"&&l!==r)throw Object.assign(new Error("File changed during diagnostics"),{code:"DIAGNOSTICS_STALE"});return{filePath:a,content:l.content,results:[...l.results.values()]}}async waitComplete(t,e){let i=e?AbortSignal.any([e,t.controller.signal]):t.controller.signal;i.throwIfAborted();let o=[];await new Promise((a,s)=>{let r=c(m=>s(Object.assign(new Error(m),{code:m,details:[...t.results.values()]})),"fail"),d=c(()=>{let m=[...t.results.values()];m.some(w=>w.status==="unavailable")?r("DIAGNOSTICS_UNAVAILABLE"):m.every(w=>w.status==="ready")&&a()},"check"),l=c(()=>s(i.reason),"abort"),f=this.onDidChange(d),u=setTimeout(()=>r("DIAGNOSTICS_TIMEOUT"),this.options.checkTimeoutMs??3e4);i.addEventListener("abort",l,{once:!0});let p=c(()=>{clearTimeout(u),f(),i.removeEventListener("abort",l)},"cleanup");Promise.resolve().then(d),o.push(p)}).finally(()=>{for(let a of o)a()})}async takeNotifications(t){let e=[];for(let i of[...this.dirty]){if(i.cwd!==g.resolve(t)||(this.dirty.delete(i),!await this.isCurrent(i)))continue;let o=[...i.results.values()].filter(d=>d.status!=="pending"&&d.status!=="unavailable"&&d.diagnostics.length>0),a=this.key(i.filePath,i.cwd),s=JSON.stringify(o);if(this.sent.get(a)===s||(this.sent.set(a,s),o.length===0))continue;let r=o.map(d=>{let l=["error","warning","info","hint"].flatMap(f=>{let u=d.diagnostics.filter(p=>p.severity===f).length;return u>0?[`${u} ${f}`]:[]});return`${d.source} ${l.join(", ")}${d.status==="snapshot"?" (snapshot; completion unknown)":d.status==="unversioned"?" (unversioned)":""}`}).join("; ");e.push({filePath:g.relative(t,i.filePath),results:o,text:`${JSON.stringify(g.relative(t,i.filePath))}: ${r}.`})}return e}dispose(){this.disposed=!0,this.changeListeners.clear();for(let t of this.files.values())t.controller.abort();this.files.clear(),this.dirty.clear(),this.sent.clear(),this.pump()}key(t,e){return JSON.stringify([g.resolve(e),g.resolve(e,t)])}ensure(t,e,i){let o=this.key(t,i),a=this.files.get(o);if(a?.content===e)return a;a?.controller.abort(),a&&this.dirty.delete(a);let s={cwd:g.resolve(i),filePath:g.resolve(i,t),content:e,controller:new AbortController,results:new Map,jobs:[],publications:new Map};this.files.set(o,s),this.sources.length===0&&s.results.set("diagnostics",{source:"diagnostics",status:"unavailable",diagnostics:[],reason:"No diagnostic sources registered"}),this.dirty.add(s);for(let r of this.sources){s.results.set(r.id,{source:r.id,status:"pending",diagnostics:[]});let d=new Promise(l=>{this.queue.push(async()=>{try{await this.check(s,r)}finally{l()}})});s.jobs.push(d)}return queueMicrotask(()=>this.pump()),s}pump(){for(;this.running<(this.options.concurrency??4)&&this.queue.length>0;){let t=this.queue.shift();if(!t)break;this.running++,t().finally(()=>{this.running--,this.pump()})}}active(t){return!this.disposed&&!t.controller.signal.aborted}assertActive(){if(this.disposed)throw new Error("Diagnostics session has ended")}async isCurrent(t){if(!this.active(t))return!1;let e=await D(t.filePath,"utf8").catch(()=>{});return this.active(t)&&e===t.content}async publish(t,e,i){let o=(t.publications.get(e)??0)+1;if(t.publications.set(e,o),!await this.isCurrent(t)||t.publications.get(e)!==o)return;let a={...i,source:i.source??e};if(JSON.stringify(t.results.get(e))===JSON.stringify(a))return;t.results.set(e,a),this.dirty.add(t);let s=[...t.results.values()].some(r=>r.status!=="pending"&&r.status!=="unavailable"&&r.diagnostics.length>0);s||this.sent.delete(this.key(t.filePath,t.cwd));for(let r of this.changeListeners)r(t.cwd,s)}async check(t,e){if(!await this.isCurrent(t))return;let i=new AbortController,o=AbortSignal.any([i.signal,t.controller.signal]);if(o.aborted)return;let a,s;try{let r=new Promise((l,f)=>{s=c(()=>f(o.reason),"onAbort"),o.addEventListener("abort",s,{once:!0}),a=setTimeout(()=>i.abort(new Error("Diagnostic check timed out")),this.options.checkTimeoutMs??3e4)}),d=await Promise.race([e.diagnose(t.filePath,{cwd:t.cwd,content:t.content,signal:o,publish:c(l=>{o.aborted||this.publish(t,e.id,l)},"publish")}),r]);await this.publish(t,e.id,d)}catch(r){await this.publish(t,e.id,{status:"unavailable",diagnostics:[],reason:r instanceof Error?r.message:String(r)})}finally{clearTimeout(a),s&&o.removeEventListener("abort",s)}}};async function K(n,t){let e;try{await Promise.race([n,new Promise(i=>{e=setTimeout(i,t)})])}finally{clearTimeout(e)}}c(K,"waitAtMost");function V(){let n=new Map,t=[],e=new v(t),i=Promise.resolve();return{diagnostics:e,registerPlugin(o){if(o.id.trim().length===0)return Promise.reject(new Error("Plugin ID must not be empty"));let a=n.get(o.id);if(a!==void 0)return a;let s=i.then(async()=>{let r=[],d=[],l=!0,f={addTool(u){if(!l)throw new Error(`Plugin ${o.id} setup is already complete`);Z(u),r.push(u)},addDiagnosticSource(u){if(!l)throw new Error(`Plugin ${o.id} setup is already complete`);tt(u),d.push(u)},readDiagnostics(u,p){return e.read(u,p)}};try{await o.setup(f)}catch(u){throw l=!1,u}l=!1,Q(t,d),q(r),t.push(...d)});return n.set(o.id,s),i=s.catch(()=>{}),s.catch(()=>{n.delete(o.id)}),s},async waitForPendingPlugins(){await Promise.all(n.values())}}}c(V,"createIdeCore");function Q(n,t){let e=new Set(n.map(i=>i.id));for(let i of t){if(e.has(i.id))throw new Error(`Diagnostic source ${i.id} is already registered`);e.add(i.id)}}c(Q,"assertUniqueDiagnosticSources");function Z(n){if(!U(n))throw new TypeError("IDE tool must be an object");let t=n.kind,e=t==="compiler"?n.compile:t==="formatter"?n.format:t==="linter"?n.lint:void 0;if(e===void 0||typeof e!="function"||typeof n.detect!="function"||typeof n.name!="string"||n.name.trim().length===0||typeof n.priority!="number"||!Number.isFinite(n.priority)||!Array.isArray(n.extensions)||n.extensions.length===0||n.extensions.some(i=>typeof i!="string"||i.length===0))throw new TypeError("Invalid pi-agent-ide tool contribution")}c(Z,"assertIdeTool");function tt(n){if(!U(n)||typeof n.id!="string"||n.id.trim().length===0||typeof n.diagnose!="function")throw new TypeError("Invalid pi-agent-ide diagnostic source contribution")}c(tt,"assertDiagnosticSource");function U(n){return typeof n=="object"&&n!==null}c(U,"isRecord");function J(n,t,e=console.error){let i=new Map,o=!1,a=Promise.resolve();return{schedule(s){if(o||i.has(s))return;let r=setTimeout(()=>{i.delete(s),a=a.then(async()=>{o||await n(s)}).catch(e)},t);i.set(s,r)},dispose(){o=!0;for(let s of i.values())clearTimeout(s);i.clear()}}}c(J,"createDiagnosticDelivery");import{Text as Y}from"@earendil-works/pi-tui";var S="ide-diagnostic-summary";function W(n){return{filePath:n.filePath,sources:n.results.map(t=>{let e={error:0,warning:0,info:0,hint:0};for(let i of t.diagnostics)e[i.severity]++;return{source:t.source,status:t.status,counts:e}})}}c(W,"diagnosticEntryData");function E(n,t,e=!1){return{render(i){let o=n.sources.filter(r=>r.status!=="pending"&&r.status!=="unavailable"&&Object.values(r.counts).some(d=>d>0));if(o.length===0)return[];let a=o.map(r=>`${x(r.counts,t)} ${t.fg("dim",`(${I(r.source)})`)}`+(r.status==="ready"?"":` \xB7 ${t.fg("dim",r.status)}`)).join(" \xB7 "),s=[`${t.fg("accent","Diagnostics")} ${t.fg("toolTitle",I(n.filePath))} \xB7 ${a}`];if(e)for(let r of o)s.push(` ${t.fg("dim",I(r.source))} \xB7 ${x(r.counts,t)} \xB7 ${t.fg("dim",r.status)}`);return new Y(s.join(`
|
|
2
2
|
`),0,0).render(i)},invalidate(){}}}c(E,"renderDiagnosticEntry");function B(n){n.registerEntryRenderer(S,(t,e,i)=>{let o=k(t.data);return"files"in o?et(o.files,i,e.expanded):E(o,i,e.expanded)})}c(B,"registerDiagnosticEntryRenderer");function et(n,t,e=!1){return{render(i){let o=n.filter(d=>d.sources.some(l=>l.status!=="pending"&&l.status!=="unavailable"&&Object.values(l.counts).some(f=>f>0)));if(o.length===1&&o[0])return E(o[0],t,e).render(i);if(o.length===0)return[];let a={error:0,warning:0,info:0,hint:0},s=new Set;for(let d of o)for(let l of d.sources)if(!(l.status==="pending"||l.status==="unavailable")){s.add(l.source);for(let f of["error","warning","info","hint"])a[f]+=l.counts[f]}let r=new Y(`${t.fg("accent","Diagnostics")} \xB7 ${o.length} files \xB7 ${x(a,t)} \xB7 ${s.size} tools`,0,0).render(i);return e?[...r,...o.flatMap(d=>E(d,t,!0).render(i))]:r},invalidate(){}}}c(et,"renderDiagnosticBatch");function x(n,t){return["error","warning","info","hint"].filter(e=>n[e]>0).map(e=>{let i=n[e],o=e==="info"||i===1?e:`${e}s`,a=i>0&&(e==="error"||e==="warning")?e:"muted";return t.fg(a,`${i} ${o}`)}).join(", ")}c(x,"renderCounts");function I(n){return n.replace(/[\u0000-\u001f\u007f-\u009f]/g," ")}c(I,"plain");import X from"node:path";async function z(n){if(!X.isAbsolute(n.resourceSource))return{formatting:{status:"unavailable"}};let t;try{let e=await G({cwd:n.cwd}),i=X.extname(n.resourceSource).toLowerCase(),o=c(d=>d.extensions.includes(i)||d.extensions.includes("*"),"matches"),a=e.compilers.find(o);if(a&&(await a.compile({filePath:n.resourceSource},e.ctx)).syntaxErrors.length>0)return{formatting:{status:"skipped-syntax"}};let s=e.formatters.find(o);if(!s)return{formatting:{status:"unavailable"}};t=s.name;let r=await s.format({filePath:n.resourceSource},e.ctx);return r.formatter===null?{formatting:{status:"unavailable"}}:(t=r.formatter??s.name,{formatting:{status:r.ok?r.edits>0?"changed":"unchanged":"failed",formatter:t},...r.ok?{diffStatuses:[{text:`Formatted (${t})`,tone:"success",formatter:t}]}:{diffStatuses:[{text:`Formatting failed (${t})`,tone:"error"}]}})}catch{return{diffStatuses:[{text:"Formatting failed",tone:"error"}],formatting:{status:"failed",...t===void 0?{}:{formatter:t}}}}}c(z,"runIdePostEditGate");import it from"node:path";async function nt(n){T();let t=V();B(n);let e=n.events.on($,s=>{if(!F(s))throw new Error("Invalid pi-agent-ide plugin registration request");s.accept(t.registerPlugin(s.plugin))});n.on("session_shutdown",()=>{e(),t.diagnostics.dispose(),T()}),M(n,{id:"pi-agent-ide",handler:c(s=>n.getFlag("pi-agent-ide-no-post-processing")===!0?Promise.resolve({formatting:{status:"disabled"}}):z(s),"handler")}),n.events.emit(A,{protocol:C,apiVersion:4}),await _(n,{protocol:N,apiVersion:O,id:"ide-diagnostics",setup(s){s.onDidEdit(r=>{n.getFlag("pi-agent-ide-no-post-processing")===!0||r.postProcessing==="deferred"||it.isAbsolute(r.resourceSource)&&j(()=>t.diagnostics.schedule(r.resourceSource,r.after.content,{cwd:r.cwd}))})}});let i=!1,o=J(async s=>{let r=await t.diagnostics.takeNotifications(s);i||r.length===0||(n.sendMessage({customType:"ide-diagnostics",display:!1,content:`File diagnostics:
|
|
3
3
|
${r.map(d=>d.text).join(`
|
|
4
4
|
`)}`},{triggerTurn:!0,deliverAs:"steer"}),n.appendEntry(S,{files:r.map(W)}))},n.getFlag("pi-agent-ide-no-diagnostic-buffer")===!0?0:5e3),a=t.diagnostics.onDidChange((s,r)=>{r&&o.schedule(s)});n.on("session_shutdown",()=>{i=!0,o.dispose(),a()}),await t.waitForPendingPlugins()}c(nt,"registerPiAgentIde");export{nt as default};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{a as b,d as A}from"./chunk-ITSNK5YG.js";import{a as N}from"./chunk-22CLOM2D.js";import{b as F,d as $}from"./chunk-526E364R.js";import{f as M}from"./chunk-YHUTTZC6.js";import{a as u}from"./chunk-EI7MMDWY.js";import L from"node:path";import{truncateHead as _,DEFAULT_MAX_BYTES as ee,DEFAULT_MAX_LINES as te}from"@earendil-works/pi-coding-agent";import{Text as S}from"@earendil-works/pi-tui";import{Type as O}from"typebox";import{Value as re}from"typebox/value";var I=O.Union([O.String({minLength:1}),N]),v=O.Object({before:I,after:I},{additionalProperties:!1});async function ne(e,o,c){if(!re.Check(v,o))throw Object.assign(new Error("Use before and after source strings or read request objects"),{code:"INVALID_ARGUMENTS"});let n=o,r=u(async l=>{let t=typeof l=="string"?{path:l}:l,p=await e.read(t,c,"script");if(p.isError||p.details.failure)throw Object.assign(new Error(p.details.failure?.message??"Comparison read failed"),{code:p.details.failure?.code??"READ_FAILED",details:p.details.failure});if(p.script===void 0)throw Object.assign(new Error("Source has no comparable text data"),{code:"UNSUPPORTED_CONTENT"});return B(p.script,t.path??"source")},"resolve"),s=await r(n.before),a=await r(n.after),i=b(s.source,s.content,a.content,a.source);return{kind:"diff",ok:!0,equal:s.content===a.content,before:s,after:a,...i}}u(ne,"executeDiff");function B(e,o){if(e.kind==="text")return{source:e.source,sources:[e.source],content:e.content};if(e.kind==="resources"){let c=e.resources.map(n=>B(n,o));return{source:e.source??o,sources:c.flatMap(n=>n.sources),content:c.map(n=>n.content).join(`
|
|
2
|
+
`)}}if(e.kind==="bytes")throw Object.assign(new Error(`Byte sources are not text: ${e.source}`),{code:"UNSUPPORTED_CONTENT"});if(e.blocks.length===0||e.blocks.some(c=>c.type!=="text"))throw Object.assign(new Error(`Source is not text: ${e.source}`),{code:"UNSUPPORTED_CONTENT"});return{source:e.source,sources:[e.source],content:e.blocks.flatMap(c=>c.type==="text"?[c.text]:[]).join(`
|
|
3
|
+
`)}}u(B,"comparisonText");function R(e){return e!==null&&typeof e=="object"&&"kind"in e&&e.kind==="diff"&&"ok"in e&&e.ok===!0}u(R,"isDiffOutcome");function j(e,o=process.cwd()){let c=u(r=>L.isAbsolute(r)?L.relative(o,r)||".":r,"displaySource"),n=`Diff: ${c(e.before.source)} \u2192 ${c(e.after.source)}`;return{results:[new A({ok:!0,path:n,beforeContentMap:{[n]:e.before.content},afterContent:e.after.content,diffs:[e.diff]})]}}u(j,"diffPresentation");function k(e){return e.equal?`No differences: ${e.before.source} \u2192 ${e.after.source}`:e.diff}u(k,"diffText");function Ee(e){return{content:[{type:"text",text:k(e)}],details:{}}}u(Ee,"diffReadResult");function De(e,o,c){e.registerTool({name:"diff",label:"Diff",parameters:v,promptSnippet:"Compare two text-readable sources without changing them",description:"Use diff to compare two sources without modifying them. before and after accept a source string or a read request {path, offset?, limit?, views?}. Use any source that read can resolve as text. Omit limit to compare complete resolved text; read presentation limits do not clip comparison inputs. Multiple resolved resources are joined with one newline separator in resolver order. Diff line numbers are relative to each selected text, not the original file when a window is selected. Native non-text content is rejected. Output uses the existing text diff and a shared output budget; oversized output has a full temporary reference. The same diff function is available inside Apply.",renderCall(n,r){return new S(r.fg("toolTitle",r.bold("Diff")),0,0)},renderResult(n,r,s,a){let i=n.details;if(i?.comparison?.equal)return new S(k(i.comparison),0,0);let l=o.getToolRenderer("diff")?.renderResult;return l?l(n,r,s,a):new S(n.content.filter(t=>t.type==="text").map(t=>t.text).join(`
|
|
4
|
+
`),0,0)},async execute(n,r,s,a,i){let l=c();if(l===void 0)throw new Error("Diff requires the read extension");let t=await ne(l,r,{cwd:i.cwd,signal:s}),p=k(t),y=_(p).truncated?await l.saveTemporary(p):void 0,f=y===void 0?"":`
|
|
5
|
+
Full diff: ${y}`;return{content:[{type:"text",text:y===void 0?p:_(p,{maxLines:te-2,maxBytes:ee-Buffer.byteLength(f)}).content+f}],details:{...j(t,i.cwd),comparison:t,temporarySource:y}}}})}u(De,"registerDiff");import{parser as q}from"@lezer/javascript";import{TreeFragment as U}from"@lezer/common";var oe=new Set(["read","search","diff","open","createFile","deleteFile","copyFile","moveFile","flush","result"]);function V(e,o=q.parse(e)){let c=[];o.iterate({enter(r){if(r.name==="AssignmentExpression"){let t=r.node.firstChild;t?.name==="VariableName"&&c.push({name:e.slice(t.from,t.to),from:0,to:e.length})}if(r.name!=="VariableDefinition")return;let s=r.node.parent;for(;s?.parent&&!["VariableDeclaration","ParamList","Block","Script"].includes(s.name);)s=s.parent;let a=s?.name==="VariableDeclaration"&&s.firstChild?.name==="var",i=new Set(["Script","FunctionDeclaration","FunctionExpression","ArrowFunction",...a?[]:["Block"]]),l=r.node.parent;for(l?.name==="FunctionDeclaration"&&(l=l.parent);l?.parent&&!i.has(l.name);)l=l.parent;c.push({name:e.slice(r.from,r.to),from:l?.from??0,to:l?.to??e.length})}});let n=[];return o.iterate({enter(r){if(r.name!=="CallExpression")return;let s=r.node.firstChild;if(s?.name!=="VariableName")return;let a=e.slice(s.from,s.to);if(!oe.has(a)||c.some(t=>t.name===a&&t.from<=r.from&&t.to>=r.to))return;let i=r.node.getChild("ArgList")?.getChild("ObjectExpression"),l=Object.create(null);if(!i){let t=r.node.getChild("ArgList"),p=t?e.slice(t.from+1,t.to).replace(/\)$/,""):"";p&&(l.arguments={text:p.length>160?p.slice(0,120)+"\u2026":p,literal:!1})}for(let t of i?.getChildren("Property")??[]){let p=t.firstChild,y=(p?e.slice(p.from,p.to):"").replace(/^["']|["']$/g,"");if(!/^[a-zA-Z_$][\w$]*$/.test(y)){for(let Q of["path","query","target","before","after"])delete l[Q];let w=e.slice(t.from,t.to);l[`argument@${t.from}`]={text:w.length>160?w.slice(0,160)+"\u2026":w,literal:!1};continue}let f=t.lastChild;if(!f||f.type.isError||f.name===":")continue;let g=e.slice(f.from,f.to),d=g.replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t"),h=/^(?:["'])(?:\d+#[0-9A-F]+|CHANGE#[0-9A-F]+|begin|end|scope-(?:begin|end)-[^"']+)["']$/.test(g);l[y]={text:d.length>160&&!h?`${d.slice(0,100)}\u2026${d.slice(-40)} (${g.length} source chars)`:d,literal:["String","Number","BooleanLiteral","Null"].includes(f.name)&&f.lastChild?.type.isError!==!0}}return n.push({name:a,from:r.from,to:r.to,path:l.path,query:l.query,target:l.target,before:l.before,after:l.after,arguments:l}),!1}}),n}u(V,"parseApplyCalls");function ie(e,o=V(e),c,n=r=>r){let r=0,s=[],a=u(i=>n(i.split(`
|
|
6
|
+
`).map(l=>l.length>200?l.slice(0,200)+"\u2026":l).join(`
|
|
7
|
+
`)),"codePreview");for(let i of o)s.push(a(e.slice(r,i.from))),s.push(c?.(i)??`${i.name}(${i.path?i.path.literal?i.path.text:`\u2039${i.path.text}\u203A`:"\u2026"})`),r=i.to;return s.push(a(e.slice(r))),s.join("")}u(ie,"compactApplySource");function J(e,o){let c="",n="",r=[];return s=>{if(s===c)return n;let a=0;for(;a<c.length&&a<s.length&&c[a]===s[a];)a++;r=U.applyChanges(r,[{fromA:a,toA:c.length,fromB:a,toB:s.length}]);let i=q.parse(s,r);return r=U.addTree(i),n=ie(s,V(s,i),e,o),c=s,n}}u(J,"createApplySourceProjection");import{lstat as G,unlink as se}from"node:fs/promises";import Y from"node:path";import z from"fs-extra";import{Type as x}from"typebox";import{Value as ae}from"typebox/value";var T=x.String({minLength:1,description:"Local regular file path, relative to cwd or absolute."}),le=x.Object({path:T},{additionalProperties:!1}),ce=x.Object({path:T,target:T,overwrite:x.Optional(x.Boolean({description:"Allow replacing an existing regular target file. Defaults to false."}))},{additionalProperties:!1});function E(e){return e!==null&&typeof e=="object"&&"kind"in e&&e.kind==="file-operation"}u(E,"isFileOperationResult");function D(e){return[`${e.operation}: ${e.effect}`,e.path,e.target===void 0?void 0:`Target: ${e.target}`,e.error===void 0?void 0:`${e.error.code}: ${e.error.message}`].filter(o=>o!==void 0).join(`
|
|
8
|
+
`)}u(D,"formatFileOperation");async function Ue(e,o,c,n){let r=!1,s,a;try{let i=e==="delete"?le:ce;if(!ae.Check(i,o))throw Object.assign(new Error("Invalid file operation arguments"),{code:"INVALID_ARGUMENTS"});let l=o;s=Y.resolve(c,l.path),a=l.target===void 0?void 0:Y.resolve(c,l.target),n?.throwIfAborted();let t=await pe(s);if(a!==void 0){let p=await fe(a);if(p!==void 0){if(!p.isFile()||p.isSymbolicLink())throw Object.assign(new Error("Target must be a regular file"),{code:"INVALID_FILE_TYPE"});if(s===a||t.ino===p.ino&&t.dev===p.dev)throw Object.assign(new Error("Source and target are the same file"),{code:"SAME_FILE"});if(l.overwrite!==!0)throw Object.assign(new Error("Target exists; use overwrite: true to replace it"),{code:"EEXIST"})}}return n?.throwIfAborted(),r=!0,e==="delete"?await se(s):a!==void 0&&(e==="copy"?await z.copy(s,a,{overwrite:l.overwrite===!0,errorOnExist:!0}):await z.move(s,a,{overwrite:l.overwrite===!0})),{kind:"file-operation",operation:e,ok:!0,effect:"applied",path:s,...a===void 0?{}:{target:a}}}catch(i){return{kind:"file-operation",operation:e,ok:!1,effect:r?"unknown":"not-applied",...s===void 0?{}:{path:s},...a===void 0?{}:{target:a},error:{code:i!==null&&typeof i=="object"&&"code"in i?String(i.code):"FILE_OPERATION_FAILED",message:i instanceof Error?i.message:String(i)}}}}u(Ue,"executeFileOperation");async function pe(e){let o=await G(e);if(!o.isFile()||o.isSymbolicLink())throw Object.assign(new Error("Source must be a regular file"),{code:"INVALID_FILE_TYPE"});return o}u(pe,"regularFile");async function fe(e){try{return await G(e)}catch(o){if(o!==null&&typeof o=="object"&&"code"in o&&o.code==="ENOENT")return;throw o}}u(fe,"optionalStat");import{Text as de}from"@earendil-works/pi-tui";function K(e){let o=e.select(),c=e.mutationValues().filter(ue);return o.files.map(n=>{let r=c.flatMap(i=>i.files.filter(l=>l.source===n.source).map(l=>({outcome:i,changed:l}))),s=e.mutationPresentation(n.source)?.data,a=s?.afterContent===n.after?s:void 0;return new A({ok:!0,path:n.source,files:[{path:n.source,action:n.before===null?"created":"edited"}],snapshot:{content:n.before??""},beforeContentMap:{[n.source]:n.before},afterContent:n.after??"",afterDocument:a?.afterDocument,resultPresentation:a?.resultPresentation,scopeMarkers:a?.scopeMarkers,hints:a?.hints,warnings:a?.warnings,diffStatuses:a?.diffStatuses,diffs:[b(n.source,n.before??"",n.after??"").diff],operations:r.map(({outcome:i,changed:l})=>({operation:i.operation==="remove"?"delete":i.operation,changes:l.changes.length})),formatting:a?.formatting??r.at(-1)?.changed.formatting})})}u(K,"finalApplyMutations");function ue(e){return e!==null&&typeof e=="object"&&"operation"in e&&"files"in e&&Array.isArray(e.files)&&"effect"in e}u(ue,"isMutation");import{highlightCode as Z}from"@earendil-works/pi-coding-agent";import{wrapTextWithAnsi as W,visibleWidth as X,truncateToWidth as me}from"@earendil-works/pi-tui";function nt(e,o,c,n=process.cwd()){let r=e.select(),s=[...r.automatic,...r.explicit.filter(t=>t.kind==="operation")].filter(t=>R(t.value)&&!t.value.equal),a=s.flatMap(t=>R(t.value)?[j(t.value,n)]:[]),i=new Set(s.flatMap(t=>t.presentation?.content??[]));if(r.files.length===0){let t=[...r.automatic.map(p=>p.presentation),...r.explicit.map(p=>p.kind==="operation"?p.presentation:void 0)].filter(p=>p!==void 0);return{comparisons:a,cwd:n,blocks:[...o.content.filter(p=>!i.has(p)).flatMap(p=>p.type==="text"?[{text:H(p.text),read:t.find(m=>m.content.includes(p))}]:[])]}}let l=K(e);return{...l.length>0?{mutations:{results:l}}:{},comparisons:a,cwd:n,blocks:[...r.explicit.flatMap(t=>t.kind==="operation"&&R(t.value)&&!t.value.equal?[]:E(t.value)?[{text:D(t.value)}]:t.kind==="operation"?t.presentation?.content.flatMap(p=>p.type==="text"?[{text:p.text,read:t.presentation}]:[])??[]:[{text:H(typeof t.value=="string"?t.value:t.value===void 0?"undefined":JSON.stringify(t.value,null,2))}]),...r.automatic.flatMap(({value:t,presentation:p})=>{if(E(t))return[{text:D(t)}];if(t!==null&&typeof t=="object"&&"kind"in t&&t.kind==="index-operation")return p?.content.flatMap(m=>m.type==="text"?[{text:m.text}]:[])??[];if(t===null||typeof t!="object"||!("errors"in t)||!Array.isArray(t.errors))return[];if("operations"in t&&Array.isArray(t.operations)){let m=t.operations.filter(f=>f!==null&&typeof f=="object"&&"status"in f&&f.status==="applied").length;if(m===t.operations.length)return[];let y=t.operations.filter(f=>f!==null&&typeof f=="object"&&"status"in f&&f.status!=="applied").map(f=>({text:we(f)}));return[{text:`Apply partially applied: ${m} of ${t.operations.length} operations completed.`},...y]}return t.errors.flatMap(m=>m!==null&&typeof m=="object"&&"message"in m&&typeof m.message=="string"?[{text:m.message}]:[])}),...c===void 0?[]:[{text:c instanceof Error?c.message:JSON.stringify(c)}]]}}u(nt,"createApplyDisplay");function P(e,o,c,n,r,s,a=!1){let i=Math.max(1,c);if(i<5)return e.split(`
|
|
9
|
+
`).flatMap(d=>W(d,i));let l=i-4,t=u(d=>o.fg("borderMuted",d),"border"),m=me(` ${n==="call"?"Apply \xB7 JavaScript":"Result"} `,i-4,""),y=[t(`${n==="call"?"\u256D":"\u251C"}\u2500`)+o.fg(a?"error":"accent",m)+t(`${"\u2500".repeat(Math.max(0,i-X(m)-3))}${n==="call"?"\u256E":"\u2524"}`)],f=`${t("\u2502")}${" ".repeat(i-2)}${t("\u2502")}`;for(let d of e.split(`
|
|
10
|
+
`)){let h=s==="diff"?o.fg(d.startsWith("+")?"toolDiffAdded":d.startsWith("-")?"toolDiffRemoved":"toolDiffContext",d):s?Z(d,s).join(`
|
|
11
|
+
`):o.fg("toolOutput",d);for(let w of W(h,l))y.push(`${t("\u2502")} ${w}${" ".repeat(Math.max(0,l-X(w)))} ${t("\u2502")}`)}n==="call"&&y.push(f),r&&y.push(t(`\u2570${"\u2500".repeat(i-2)}\u256F`));let g=o.getBgAnsi("toolPendingBg");return y.map(d=>g+M(d,g)+"\x1B[0m")}u(P,"applyFrameRows");function ge(e){return(o,c,n)=>{let r=n.state,s=r.projectSource??=J(e?i=>e(i,c):void 0,e?i=>Z(i,"javascript").join(`
|
|
12
|
+
`):void 0),a=o!==null&&typeof o=="object"&&"source"in o&&typeof o.source=="string"?o.source:"";return{invalidate(){},render(i){return P(r.codeView||n.expanded?r.displaySource??a:ye(s(r.displaySource??a)),c,i,"call",!r.applyResultReady,r.codeView||n.expanded||!e?"javascript":void 0)}}}}u(ge,"createApplyCallRenderer");function ye(e,o=F){let c=e.split(`
|
|
13
|
+
`);if(c.length<=o)return e;let n=Math.max(2,o-1),r=Math.ceil(n/2),s=Math.floor(n/2),a=c.length-r-s;return[...c.slice(0,r),`\u2026 ${a} lines omitted \u2026`,...c.slice(-s)].join(`
|
|
14
|
+
`)}u(ye,"compactApplyPreview");var ot=ge();function he(e){return(o,c,n,r)=>{r.state.applyResultReady=!0;let s=o.details;r.state.displaySource=s?.displaySource;let a=s?.display,i=a?.blocks??[{text:r.isError?"Apply failed":"Apply finished"}],l=$({kind:"source"}),t=i.map(f=>l(f.read??{content:[{type:"text",text:f.text}],details:xe(f.text)},c,n,{...r,isError:!1,lastComponent:void 0})),p=a?.mutations,m=(a?.comparisons??[]).flatMap(f=>[e?.(f,n,c.expanded,a?.cwd??process.cwd())??new de((f.results??[]).flatMap(d=>d.data.diffs??[]).join(`
|
|
15
|
+
`),0,0)]),y=p===void 0?void 0:e?.(p,n,c.expanded,a?.cwd??process.cwd());return{invalidate(){y?.invalidate();for(let f of m)f.invalidate()},render(f){let g=[];for(let d of t){let h=d.render(Math.max(1,f-4));h.length!==0&&(g.length>0&&g.push(""),g.push(...h))}for(let d of m)g.length>0&&g.push(""),g.push(...d.render(Math.max(1,f-4)));if(y!==void 0){let d=y.render(Math.max(1,f-4));g.length>0&&d.length>0&&g.push(""),g.push(...d)}else p!==void 0&&g.push(...(p.results??[]).map(d=>d.path??"Changed file"));return g.length===0&&i.length>0&&i.every(d=>d.read?.details.diagnosticCheck?.complete&&d.read.details.diagnosticCheck.count===0)?P("",n,f,"result",!0).slice(-1):P(g.length===0?"No output":g.join(`
|
|
16
|
+
`),n,f,"result",!0,void 0,r.isError)}}}}u(he,"createApplyResultRenderer");function we(e){if(e===null||typeof e!="object")return String(e);let o="index"in e?Number(e.index)+1:"?",c="kind"in e?String(e.kind):"operation",n="status"in e?String(e.status):"unknown",r="error"in e&&e.error!==null&&typeof e.error=="object"?`: ${"code"in e.error?String(e.error.code):"ERROR"}: ${"message"in e.error?String(e.error.message):"Operation failed"}`:"";return`Operation ${o} (${c}): ${n}${r}`}u(we,"formatDisplayOutcome");function H(e){if(/^(?:Undo transaction:|Undo available)/u.test(e.trim()))return"";try{let o=JSON.parse(e);return JSON.stringify(C(o),null,2)}catch{return e.replace(/APPLY#[0-9A-F]{12}/gu,"Apply transaction")}}u(H,"redactApplyReceipts");function C(e){return Array.isArray(e)?e.map(C):e===null||typeof e!="object"?e:Object.fromEntries(Object.entries(e).filter(([o])=>o!=="transaction").map(([o,c])=>[o,C(c)]))}u(C,"redactTransactionKeys");function xe(e){try{let o=JSON.parse(e);return o!==null&&typeof o=="object"?{source:"result.json"}:{}}catch{return{}}}u(xe,"jsonDetails");var it=he();export{ne as a,Ee as b,De as c,Ue as d,K as e,nt as f,ge as g,ot as h,he as i,it as j};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import"./chunk-3YK4XMWB.js";import{a as J,b as V,c as z,d as U,f as q}from"./chunk-T6LX2RX5.js";import{d as L,e as h}from"./chunk-M5MJP7Z2.js";import{a as E}from"./chunk-WZI4YC2O.js";import{d as N}from"./chunk-N34ATN52.js";import{a as O}from"./chunk-ZC65Z3CK.js";import{a as _,b as F,c as M}from"./chunk-JMVDFOTQ.js";import{a as d}from"./chunk-EI7MMDWY.js";import{mkdir as ie,readFile as B,writeFile as re}from"node:fs/promises";async function G(n,t){await ie(L(n),{recursive:!0});let e=[],o=t.filter(s=>s.recipe.formatter!==void 0),i=t.filter(s=>s.recipe.linter!==void 0),r=t.filter(s=>s.recipe.lsp!==void 0);if(o.length>0){let s=h(n,"formatters"),c=await S(s,{version:1,formatters:{}}),u=P(c,"formatters");for(let l of o)u[l.recipe.id]??=l.recipe.formatter;await R(s,c)&&e.push(s)}if(i.length>0){let s=h(n,"linters"),c=await S(s,{version:1,linters:{}}),u=P(c,"linters");for(let l of i)u[l.recipe.id]??=l.recipe.linter;await R(s,c)&&e.push(s)}if(r.length>0){let s=h(n,"lsp-servers"),c=await S(s,{version:1,servers:{}}),u=P(c,"servers");for(let l of r){let a=O(l.recipe.lsp);u[l.recipe.id]??={command:a.command,transport:"stdio",rootMarkers:a.rootMarkers,...a.initializationOptions!==void 0&&{initializationOptions:a.initializationOptions},...a.settings!==void 0&&{settings:a.settings},...a.requireRootMarker!==void 0&&{requireRootMarker:a.requireRootMarker},languages:Object.fromEntries(Object.entries(a.languageIds).map(([p,f])=>[p,{extensions:f,...a.fileNames?.[p]&&{fileNames:a.fileNames[p]}}])),capabilities:["diagnostics"]}}await R(s,c)&&e.push(s)}return e}d(G,"writeSuggestedConfigs");async function S(n,t){try{let e=JSON.parse(await B(n,"utf8"));if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`${n} must contain an object`);return e}catch(e){if(typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT")return t;throw e}}d(S,"readObject");function P(n,t){let e=n[t];if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`${t} must be an object`);return e}d(P,"objectMember");async function R(n,t){let e=`${JSON.stringify(t,null,2)}
|
|
2
|
+
`;return await B(n,"utf8").catch(()=>{})===e?!1:(await re(n,e,"utf8"),!0)}d(R,"writeJson");var C=class{static{d(this,"DoctorCore")}plugins=new Map;languages=[];recipes=[];setupChecks=[];checks=[];queue=Promise.resolve();registerPlugin(t){let e=this.plugins.get(t.id);if(e!==void 0)return e;let o=this.queue.then(async()=>{let i=!0,r=[],s=[],c=[],u=[],l={addLanguage:d(a=>{b(a,r,t.id,"language",()=>i)},"addLanguage"),addToolRecipe:d(a=>{b(a,s,t.id,"tool recipe",()=>i)},"addToolRecipe"),addSetupCheck:d(a=>{b(a,c,t.id,"setup check",()=>i)},"addSetupCheck"),addCheck:d(a=>{b(a,u,t.id,"check",()=>i)},"addCheck")};try{await t.setup(l)}finally{i=!1}W(this.languages,r,"language"),W(this.recipes,s,"tool recipe"),this.languages.push(...r),this.recipes.push(...s),this.setupChecks.push(...c),this.checks.push(...u)});return this.plugins.set(t.id,o),this.queue=o.catch(()=>{}),o.catch(()=>{this.plugins.delete(t.id)}),o}async waitForPlugins(){await Promise.all(this.plugins.values())}snapshot(){return{languages:[...this.languages],recipes:[...this.recipes],setupChecks:[...this.setupChecks],checks:[...this.checks]}}};async function H(n,t){let e=[],o=[];for(let i of n.setupChecks)try{let r=await i.value.inspect(t);e.push(...(r.selections??[]).map(s=>({...s,pluginId:i.pluginId}))),o.push(...(r.actions??[]).map(s=>({...s,pluginId:i.pluginId})))}catch{}return{selections:e,actions:o}}d(H,"runContributedSetupChecks");async function X(n,t){let e=[];for(let o of n.checks)try{e.push({pluginId:o.pluginId,title:o.value.title,findings:await o.value.run(t)})}catch(i){e.push({pluginId:o.pluginId,title:o.value.title,findings:[{status:"fail",message:i instanceof Error?i.message:String(i)}]})}return e}d(X,"runContributedChecks");function W(n,t,e){for(let o of t){let i=n.find(r=>r.value.id===o.value.id)?.pluginId;if(i!==void 0)throw new Error(`${e} ${o.value.id} is already owned by doctor plugin ${i}`)}}d(W,"assertAvailable");function b(n,t,e,o,i){if(!i())throw new Error(`Doctor plugin ${e} setup is complete`);if(!/^[a-z0-9][a-z0-9.-]*$/u.test(n.id))throw new Error(`Invalid ${o} ID: ${n.id}`);if(t.some(r=>r.value.id===n.id))throw new Error(`Doctor plugin ${e} registered ${o} ${n.id} twice`);t.push({pluginId:e,value:n})}d(b,"add");import fe from"node:path";import{readFile as se}from"node:fs/promises";async function Y(n,t,e,o=process.env){let i=await E(n,e.map(c=>c.value)),r=await ce(n),s=[];for(let c of e){let u=c.value;if(u.languages.every(v=>!t.has(v)))continue;let l=[],a=1,p=i.get(u.id),f=p?.config;f!==void 0&&(a+=6,l.push(`project config: ${f}`)),r.has(`${u.kind}:${u.id}`)&&(a+=6,l.push("Pi Agent IDE config"));let w=p?.dependency;w!==void 0&&(a+=4,l.push(`project dependency: ${w}`));let m=await ae(n,u.executables,o);m!==void 0&&(a+=3,l.push(`executable: ${m}`)),s.push({pluginId:c.pluginId,recipe:u,score:a,evidence:l,...m&&{executable:m}})}return s.sort((c,u)=>u.score-c.score||c.recipe.id.localeCompare(u.recipe.id))}d(Y,"discoverRecipeCandidates");function K(n,t,e=[]){let o=new Map,i=new Map(e.map(r=>[`${r.kind}:${r.languageId}`,r.toolId]));for(let r of t)for(let s of["formatter","linter","lsp"]){let c=i.get(`${s}:${r}`),u=c===void 0?4:7,l=n.filter(p=>p.recipe.kind===s&&p.recipe.languages.includes(r)&&p.executable!==void 0&&p.recipe.id!==c&&p.score>=u),a=l[0];a!==void 0&&(l.filter(p=>p.score===a.score).length>1||o.set(`${a.recipe.kind}:${a.recipe.id}`,a))}return[...o.values()]}d(K,"selectSuggestedRecipes");async function ae(n,t,e){for(let o of t)if(await N(o,n,e))return o}d(ae,"firstExecutable");async function ce(n){let t=new Set;for(let[e,o,i]of[["formatters","formatters","formatter"],["linters","linters","linter"],["lsp-servers","servers","lsp"]])try{let r=JSON.parse(await se(h(n,e),"utf8"));if(typeof r!="object"||r===null||Array.isArray(r))continue;let c=r[o];if(typeof c=="object"&&c!==null&&!Array.isArray(c))for(let u of Object.keys(c))t.add(`${i}:${u}`)}catch{}return t}d(ce,"managedRecipeIds");import{execFile as de}from"node:child_process";import{readdir as ue}from"node:fs/promises";import y from"node:path";import{promisify as le}from"node:util";var pe=le(de),ge=new Set([".git",".hg",".svn","node_modules","vendor","build","dist","coverage",".cache",".next","target"]);async function Q(n,t){t?.throwIfAborted();try{let o=(await pe("git",["ls-files","--cached","--others","--exclude-standard","-z"],{cwd:n,encoding:"utf8",maxBuffer:16777216,signal:t})).stdout.split("\0").filter(Boolean).map(i=>y.resolve(n,i)).filter(i=>!ee(i));return t?.throwIfAborted(),o.length>0?o:await k(n,t)}catch{return t?.throwIfAborted(),k(n,t)}}d(Q,"collectProjectFiles");function Z(n,t,e=process.platform){let o=new Map,i=e==="win32"?y.win32:y;for(let r of t){let s=new Set(r.extensions.map(a=>a.toLowerCase())),c=d(a=>e==="win32"?a.toLowerCase():a,"normalizeName"),u=new Set(r.fileNames?.map(c)),l=n.filter(a=>!a.split(y.sep).join("/").includes("/.pi/pi-agent-ide/")&&(s.has(i.extname(a).toLowerCase())||u.has(c(i.basename(a)))));l.length>0&&o.set(r.id,l)}return o}d(Z,"detectProjectLanguages");async function k(n,t){t?.throwIfAborted();let e=[];for(let o of await ue(n,{withFileTypes:!0})){if(o.isDirectory()&&ge.has(o.name))continue;let i=y.join(n,o.name);ee(i)||(o.isDirectory()?e.push(...await k(i,t)):o.isFile()&&e.push(i))}return e}d(k,"walk");function ee(n){return n.split(y.sep).join("/").includes("/.pi/pi-agent-ide/")}d(ee,"isManagedIdeConfig");async function $(n,t,e=process.env,o){o?.throwIfAborted();let i=await Q(t,o);o?.throwIfAborted();let r=Z(i,n.languages.map(p=>p.value)),s=new Set(r.keys()),c={cwd:t,files:i,detectedLanguageIds:s,detectedLanguages:r,env:e},[u,l]=await Promise.all([Y(t,s,n.recipes,e),H(n,c)]),a=new Map;for(let p of s)for(let f of["formatter","linter","lsp"]){if(l.selections.some(g=>g.languageId===p&&g.kind===f))continue;let w=u.filter(g=>g.recipe.kind===f&&g.recipe.languages.includes(p)),m=d(g=>g.score-(g.executable===void 0?0:3),"nativeScore"),v=Math.max(1,...w.map(m));for(let g of w){if(g.executable!==void 0||m(g)!==v||v<=1)continue;let T=`${f}-${g.recipe.id}-unavailable`;a.set(T,{id:T,pluginId:g.pluginId,message:`Native project setup selects ${g.recipe.id}, but its executable is unavailable. Install ${g.recipe.executables.join(" or ")} and run Doctor again.`})}}return{cwd:t,files:i,detectedLanguages:r,candidates:u,selections:l.selections,actions:[...l.actions,...a.values()],suggestions:K(u,s,l.selections)}}d($,"inspectDoctorSetup");async function I(n,t,e=process.env){let o=await $(n,t,e),i=new Set(o.detectedLanguages.keys()),r={cwd:t,files:o.files,detectedLanguageIds:i,detectedLanguages:o.detectedLanguages,env:e},s=await X(n,r),c=[{status:"pass",message:`Project: ${t}`},o.files.length>0?{status:"pass",message:`${o.files.length} project files inspected`}:{status:"warn",message:"No project files found"},i.size>0?{status:"pass",message:`Detected: ${[...i].join(", ")}`}:{status:"warn",message:"No registered project languages detected"}];return{...o,sections:[{title:"Project",pluginId:"doctor",findings:c},...s]}}d(I,"runDoctor");function D(n){let t=["Pi Agent IDE doctor",""];for(let e of n.sections){t.push(`${e.title} (${e.pluginId})`);for(let o of e.findings)t.push(` ${o.status.toUpperCase().padEnd(4)} ${o.message}`),o.detail!==void 0&&t.push(` \`${o.detail}\``);t.push("")}if(n.actions.length>0){t.push("Setup needs attention");for(let e of n.actions)t.push(` ${e.message} [${e.pluginId}]`);t.push("")}if(n.suggestions.length>0){t.push("Suggested configuration");for(let e of n.suggestions){let o=e.evidence.length>0?` \u2014 ${e.evidence.join(", ")}`:"";t.push(` ${e.recipe.kind.padEnd(9)} ${e.recipe.id} [${e.pluginId}]${o}`)}t.push("")}return t.join(`
|
|
3
|
+
`).trimEnd()}d(D,"formatDoctorReport");function j(n){return n.actions.length>0||n.suggestions.length>0||n.sections.some(t=>t.findings.some(e=>e.status==="fail"))}d(j,"doctorNeedsWork");function te(n){let t=n.candidates.map(e=>({owner:e.pluginId,id:e.recipe.id,kind:e.recipe.kind,languages:e.recipe.languages,evidence:e.evidence,documentation:e.recipe.documentation}));return["Finish configuring Pi Agent IDE for this project.","Preserve existing formatter, linter, compiler, and style rules. Do not invent or replace native project settings.","Do not install packages, write credentials, or change source files without the user's normal confirmation.","Pi Agent IDE project configs live in .pi/pi-agent-ide/.","Use only the relevant plugin contributions listed below; each owner remains responsible for its own scope.","",D(n),"","Relevant registered recipes:",JSON.stringify(t,null,2),"",`Project root: ${fe.resolve(n.cwd)}`].join(`
|
|
4
|
+
`)}d(te,"buildDoctorAgentPrompt");import{createHash as me}from"node:crypto";var he="doctor",x=3;function ne(n,t){let e=_(n,ye(t));e!==void 0&&e.catch(()=>{})}d(ne,"registerDoctorTipProvider");function ye(n){return{protocol:F,apiVersion:M,id:he,async getTip(t){let e=await n(t),o=we(e);if(o.length===0)return;let i=o.slice(0,x).map(r=>`\u2022 ${r.message}`);return o.length>x&&i.push(`\u2022 ${o.length-x} more`),{id:`doctor-setup-${De(o)}`,title:o.length===1?"Project setup needs attention":`${o.length} project setup items`,body:[...i,"Run /pi-agent-ide-doctor"].join(`
|
|
5
|
+
`)}}}}d(ye,"createDoctorTipProvider");function we(n){let t=n.actions.map(o=>({id:`action:${o.pluginId}:${o.id}`,message:o.message})),e=n.suggestions.map(o=>{let i=o.recipe.languages.filter(s=>n.detectedLanguages.has(s)).join(", "),r={debugger:"debugging",formatter:"formatting",linter:"linting",lsp:"language support"}[o.recipe.kind];return{id:`suggestion:${o.pluginId}:${o.recipe.kind}:${o.recipe.id}`,message:`Use ${o.recipe.name} for ${i} ${r}`}});return[...t,...e].sort((o,i)=>o.id.localeCompare(i.id))}d(we,"setupItems");function De(n){return me("sha256").update(n.map(t=>`${t.id}\0${t.message}`).join("\0")).digest("hex").slice(0,12)}d(De,"fingerprint");async function oe(n){let t=new C;ne(n,async i=>(await t.waitForPlugins(),$(t.snapshot(),i.cwd,process.env,i.signal)));let e,o=n.events.on(U,i=>{if(!q(i))throw new Error("Invalid doctor plugin registration request");i.accept(t.registerPlugin(i.plugin))});n.on("session_shutdown",o),n.registerCommand("pi-agent-ide-doctor",{description:"Check and configure Pi Agent IDE for this project",handler:d(async(i,r)=>{await t.waitForPlugins();let s=await I(t.snapshot(),r.cwd);A(n,D(s));let c=new Set(i.trim().split(/\s+/u).filter(Boolean));if(s.suggestions.length>0&&!c.has("--no-apply")&&(c.has("--apply")||r.hasUI&&await r.ui.confirm("Apply suggested configuration?","Add detected tools to .pi/pi-agent-ide/. Existing entries and native tool settings are kept."))){let a=await G(r.cwd,s.suggestions),p=a.length===0?"Pi Agent IDE configs are already up to date":`Updated ${a.length} Pi Agent IDE config ${a.length===1?"file":"files"}`;r.ui.notify(p,"info"),s=await I(t.snapshot(),r.cwd),A(n,D(s))}if(!j(s)&&!c.has("--agent"))return;(c.has("--agent")||r.hasUI&&await r.ui.confirm("Ask the agent to finish setup?","The agent will receive this redacted report and relevant plugin recipes."))&&(e=r.cwd,n.sendUserMessage(te(s)))},"handler")}),n.on("agent_end",async(i,r)=>{let s=e;if(s===void 0)return;e=void 0;let c=await I(t.snapshot(),s,process.env);A(n,`Doctor recheck after agent setup
|
|
6
|
+
|
|
7
|
+
${D(c)}`),j(c)?r.ui.notify("Pi Agent IDE setup still needs attention","warning"):r.ui.notify("Pi Agent IDE setup is ready","info")}),n.events.emit(z,{protocol:J,apiVersion:1}),await t.waitForPlugins()}d(oe,"registerDoctor");function A(n,t){n.sendMessage({customType:"pi-agent-ide-doctor",content:t,display:!0},{triggerTurn:!1})}d(A,"sendReport");export{oe as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{a as L}from"./chunk-M5IVSCR2.js";import{a as U}from"./chunk-6CZO43OH.js";import{a as M,b as $}from"./chunk-OBNING2A.js";import{a as k}from"./chunk-ZTYWHL2F.js";import{a as O,b as T}from"./chunk-7UGNGK7Y.js";import{a as c}from"./chunk-EI7MMDWY.js";import{execFile as Z}from"node:child_process";import ee from"node:os";import{promisify as ne}from"node:util";import{createCanvas as _,loadImage as te}from"@napi-rs/canvas";var p=ne(Z),I=20*1024*1024,B={durationSeconds:2,intervalSeconds:.5,scale:.5},W=new Set;function F(e){let n=D({mode:"sequence",durationSeconds:Number(e.durationSeconds??2),intervalSeconds:Number(e.intervalSeconds??.5),scale:Number(e.scale??.5)});B={durationSeconds:n.durationSeconds,intervalSeconds:n.intervalSeconds,scale:n.scale},W=new Set((e.allowedExecutables??"").split(",").map(r=>r.trim().toLowerCase()).filter(Boolean))}c(F,"configureVision");function y(){return B}c(y,"getVisionDefaults");function H(e){let n=e.includes("\\")?e.slice(e.lastIndexOf("\\")+1):e,r=n.trim().split(/\s+/u)[0]??"",t=r.slice(r.lastIndexOf("/")+1);return W.has((e.includes("\\")?n:t).toLowerCase())}c(H,"isExecutableAllowed");function j(e,n){let r=e?.filter(a=>/^(?:image|sequence)(?::|$)/u.test(a))??[];if(r.length===0)return;if(r.length>1)throw new Error("Use only one image or sequence view");let t=r[0],i=t.indexOf(":"),s=t.slice(0,i<0?void 0:i),o={};if(i>=0&&re(t.slice(i+1),o),s==="image"&&(o.duration!==void 0||o.interval!==void 0))throw new Error("duration and interval are supported only by the sequence view");return D({mode:s,durationSeconds:o.duration??n.durationSeconds,intervalSeconds:o.interval??n.intervalSeconds,scale:o.scale??n.scale,...o.region===void 0?{}:{region:o.region}})}c(j,"parseVisionView");function re(e,n){if(e.length===0)throw new Error("View parameters cannot be empty");let r=e.split(",");for(let t=0;t<r.length;t+=1){let i=r[t],s=i.indexOf("=");if(s<=0)throw new Error(`Invalid view parameter ${i}`);let o=i.slice(0,s),a=i.slice(s+1);if(o==="region"){let l=[a,r[t+1],r[t+2],r[t+3]].map(Number);if(l.some(m=>!Number.isFinite(m)))throw new Error("region requires x,y,width,height values");n.region={x:l[0],y:l[1],width:l[2],height:l[3]},t+=3;continue}if(o!=="duration"&&o!=="interval"&&o!=="scale")throw new Error(`Unknown view parameter ${o}`);let d=Number(a);if(!Number.isFinite(d))throw new Error(`View parameter ${o} must be a number`);if(n[o]!==void 0)throw new Error(`Duplicate view parameter ${o}`);n[o]=d}}c(re,"parseViewParameters");function G(e){if(!e.startsWith("display:"))return;if(e==="display:")return 0;let n=/^display:#(\d+)$/u.exec(e);if(n===null)throw new Error("Display sources use display: or display:#N with a zero-based index");let r=Number(n[1]);if(!Number.isSafeInteger(r))throw new Error("Display sources use display: or display:#N with a zero-based index");return r}c(G,"parseDisplaySource");async function E(e){let n=new Map(e.list().flatMap(i=>i.pid===void 0?[]:[[i.pid,i]]));if(process.platform!=="linux"&&process.platform!=="darwin")return[...n].map(([i,s])=>({pid:i,command:s.description,owned:!0,source:s.source}));let{stdout:r}=await p("ps",["-eo","pid=,ppid=,lstart=,args="],{maxBuffer:4*1024*1024}),t=r.split(`
|
|
2
|
+
`).flatMap(i=>{let s=/^\s*(\d+)\s+(\d+)\s+(\S+\s+\S+\s+\d+\s+\d+:\d+:\d+\s+\d+)\s+(.*)$/u.exec(i);if(s===null)return[];let o=Number(s[1]),a=n.get(o);return[{pid:o,parentPid:Number(s[2]),started:s[3],command:s[4]??"",owned:a!==void 0,...a===void 0?{}:{source:a.source}}]});return x()?[...t,...await oe()]:t}c(E,"listProcesses");async function oe(){try{let{stdout:e}=await p("powershell.exe",["-NoLogo","-NoProfile","-NonInteractive","-Command","Get-Process | Select-Object Id,ProcessName,Path,StartTime | ConvertTo-Json -Compress"],{maxBuffer:4194304}),n=JSON.parse(e);return(Array.isArray(n)?n:[n]).flatMap(t=>{if(typeof t!="object"||t===null||!("Id"in t)||typeof t.Id!="number")return[];let i="ProcessName"in t&&typeof t.ProcessName=="string"?t.ProcessName:"Windows process",s="Path"in t&&typeof t.Path=="string"?t.Path:void 0,o="StartTime"in t&&typeof t.StartTime=="string"?t.StartTime:void 0;return[{pid:t.Id,command:s??i,owned:!1,...o===void 0?{}:{started:o}}]})}catch{return[]}}c(oe,"listWindowsProcesses");async function A(e,n){if(!Number.isSafeInteger(e)||e<=0)throw new Error("Process PID must be a positive integer");let r=(await E(n)).find(t=>t.pid===e);if(r===void 0)throw new Error(`Process ${e} is not running`);return r}c(A,"readProcess");function D(e){let n=e.scale??1;if(!(n>0&&n<=1))throw new Error("Image scale must be greater than 0 and at most 1");let r=e.durationSeconds??0,t=e.intervalSeconds??1;if(e.mode==="sequence"){if(!(r>0&&r<=10))throw new Error("Sequence duration must be greater than 0 and at most 10 seconds");if(!(t>0))throw new Error("Sequence interval must be greater than 0 seconds");if(Math.floor(r/t)+1>20)throw new Error("Sequence capture is limited to 20 frames")}if(e.region!==void 0){let{x:i,y:s,width:o,height:a}=e.region;if(i<0||s<0||o<=0||a<=0||i+o>1||s+a>1)throw new Error("Image region x,y,width,height must fit within normalized bounds 0..1")}if(e.cellIndex!==void 0&&e.cellSize===void 0)throw new Error("Image offset requires limit to set the square grid cell size");if(e.cellSize!==void 0&&(!Number.isSafeInteger(e.cellSize)||e.cellSize<=0))throw new Error("Image limit must be a positive integer pixel size");if(e.cellIndex!==void 0&&(!Number.isSafeInteger(e.cellIndex)||e.cellIndex<0))throw new Error("Image offset must be a zero-based cell index");return e}c(D,"validateVisionOptions");async function b(e,n,r){let t=D(n),i=t.mode==="image"?1:Math.floor(t.durationSeconds/t.intervalSeconds)+1,s=[],o=0;for(let a=0;a<i;a+=1){r?.throwIfAborted(),a>0&&await de(t.intervalSeconds*1e3,r);let d=await e();if(o+=d.byteLength,o>I)throw new Error("Captured images exceed the 20MB aggregate limit");for(let l of await ie(d,t))s.push({type:"image",data:Buffer.from(l).toString("base64"),mimeType:"image/png"})}return s}c(b,"captureImages");async function ie(e,n){let r=await te(e),t=n.region??{x:0,y:0,width:1,height:1},i=Math.round(t.x*r.width),s=Math.round(t.y*r.height),o=Math.max(1,Math.round(t.width*r.width)),a=Math.max(1,Math.round(t.height*r.height)),d=n.scale??1,l=Math.max(1,Math.round(o*d)),m=Math.max(1,Math.round(a*d)),w=_(l,m);if(w.getContext("2d").drawImage(r,i,s,o,a,0,0,l,m),n.cellSize===void 0)return[await w.encode("png")];let u=Math.ceil(l/n.cellSize),f=Math.ceil(m/n.cellSize),h=n.cellIndex??0;if(h>=u*f)throw new Error(`Image cell offset ${h} exceeds the ${u}x${f} grid`);let K=h%u,Q=Math.floor(h/u),C=K*n.cellSize,V=Q*n.cellSize,P=Math.min(n.cellSize,l-C),S=Math.min(n.cellSize,m-V),q=_(P,S);return q.getContext("2d").drawImage(w,C,V,P,S,0,0,P,S),[await q.encode("png")]}c(ie,"selectImage");function J(){return{async captureWindow(e,n){if(n?.throwIfAborted(),x())return se(e,n);if(process.platform!=="linux"&&process.platform!=="darwin")throw new Error(`Window capture is unsupported on ${process.platform}`);let{Window:r}=await import("node-screenshots"),t;try{t=r.all()}catch(o){throw new Error(`Desktop window enumeration is unavailable: ${z(o)}`,{cause:o})}let i=t.find(o=>{try{return o.pid()===e}catch{return!1}});if(i===void 0)throw new Error(`No capturable desktop window belongs to PID ${e}`);let s=await i.captureImage();return n?.throwIfAborted(),new Uint8Array(await s.toPng())},async captureDisplay(e,n){if(n?.throwIfAborted(),x())return ae(e,n);if(process.platform!=="linux"&&process.platform!=="darwin"&&process.platform!=="win32")throw new Error(`Display capture is unsupported on ${process.platform}`);let{Monitor:r}=await import("node-screenshots"),t;try{t=r.all()}catch(o){throw new Error(`Desktop display enumeration is unavailable: ${z(o)}`,{cause:o})}let i=t[e];if(i===void 0)throw new Error(`Display index ${e} is unavailable; found ${t.length} display(s)`);let s=await i.captureImage();return n?.throwIfAborted(),new Uint8Array(await s.toPng())},async captureUrl(e,n){if(e.protocol!=="http:"&&e.protocol!=="https:")throw new Error("Web screenshots require an HTTP(S) URL");let{chromium:r}=await import("playwright-core"),t=await ce(),i=await r.launch({executablePath:t,headless:!0,chromiumSandbox:!1,timeout:3e4}),s=c(()=>{i.close()},"abort");n?.addEventListener("abort",s,{once:!0});try{let o=await i.newPage({viewport:{width:1280,height:720}});return await o.goto(e.href,{waitUntil:"domcontentloaded",timeout:3e4}),await o.waitForLoadState("networkidle",{timeout:1500}).catch(()=>{}),n?.throwIfAborted(),new Uint8Array(await o.screenshot({type:"png",fullPage:!0}))}finally{n?.removeEventListener("abort",s),await i.close().catch(()=>{})}}}}c(J,"createCaptureBackend");async function se(e,n){let r=new URL("windows-window-capture.ps1",new URL("../src/plugins/pi-agent-ide-vision/src/vision.ts",import.meta.url).href);n?.throwIfAborted();let{stdout:t}=await p("wslpath",["-w",r.pathname],{signal:n}),{stdout:i}=await p("powershell.exe",["-NoLogo","-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-File",t.trim(),"-ProcessId",String(e)],{encoding:"buffer",maxBuffer:I,signal:n});return new Uint8Array(i)}c(se,"captureWslWindow");async function ae(e,n){let r=new URL("windows-display-capture.ps1",new URL("../src/plugins/pi-agent-ide-vision/src/vision.ts",import.meta.url).href);n?.throwIfAborted();let{stdout:t}=await p("wslpath",["-w",r.pathname],{signal:n}),{stdout:i}=await p("powershell.exe",["-NoLogo","-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-File",t.trim(),"-DisplayIndex",String(e)],{encoding:"buffer",maxBuffer:I,signal:n});return new Uint8Array(i)}c(ae,"captureWslDisplay");function x(){return process.platform==="linux"&&(process.env.WSL_DISTRO_NAME!==void 0||ee.release().toLowerCase().includes("microsoft"))}c(x,"isWsl");async function ce(){let e=process.env.PI_AGENT_IDE_BROWSER_PATH;if(e!==void 0)return e;let{stdout:n}=await p("bash",["-lc","command -v google-chrome-stable || command -v google-chrome || command -v chromium || command -v chromium-browser"]),r=n.trim();if(r.length===0)throw new Error("No Chrome or Chromium executable was found; set PI_AGENT_IDE_BROWSER_PATH");return r}c(ce,"resolveBrowser");function de(e,n){return new Promise((r,t)=>{let i=setTimeout(r,e),s=c(()=>{clearTimeout(i),t(n?.reason??new Error("Capture aborted"))},"abort");n?.addEventListener("abort",s,{once:!0}),i.unref()})}c(de,"delay");function z(e){return e instanceof Error?e.message:String(e)}c(z,"errorMessage");async function ue(e,n){let r=n?.preferences??{};F({durationSeconds:r["vision.sequenceDurationSeconds"],intervalSeconds:r["vision.sequenceIntervalSeconds"],scale:r["vision.imageScale"],allowedExecutables:r["vision.allowedExecutables"]});let t=L(e),i=J();await Promise.all([U(e,{protocol:M,apiVersion:$,id:"vision",setup(s){for(let a of["image","sequence"])s.addView({view:a,presenter:{id:`vision-${a}`,present:c(d=>d,"present")}});s.addHandler({stage:"pre-read",async handler(a){let d=a.request.path;if(d===void 0)return{kind:"continue",context:a};let l=G(d);if(l!==void 0){if(e.getFlag("pi-agent-ide-vision-displays")!==!0)return g(d,"Display capture is disabled. Enable --pi-agent-ide-vision-displays to allow it.");try{let u=await b(()=>i.captureDisplay(l,a.resolverContext.signal),R(a.request),a.resolverContext.signal);return v(d,u)}catch(u){return g(d,N(u))}}let m=X(d,"process:");if(m!==void 0){let u=await A(m,t);return v(d,[{type:"text",text:Y(u)}])}let w=X(d,"window:");if(w!==void 0){let u=await A(w,t);if(!u.owned&&!H(u.command)&&e.getFlag("pi-agent-ide-vision-arbitrary-windows")!==!0)return g(d,`Window capture for PID ${w} is denied because the process is neither Agent IDE-owned nor allowlisted by executable name. Enable --pi-agent-ide-vision-arbitrary-windows to allow it.`);try{let f=await b(()=>i.captureWindow(w,a.resolverContext.signal),R(a.request),a.resolverContext.signal);return v(d,f)}catch(f){return g(d,N(f))}}if(/^https?:\/\//iu.test(d)&&le(a.request)){let u=new URL(d);try{let f=await b(()=>i.captureUrl(u,a.resolverContext.signal),R(a.request),a.resolverContext.signal);return v(u.href,f)}catch(f){return g(u.href,N(f))}}return{kind:"continue",context:a}}});let o=y();s.describe(`Process metadata: process:PID. Visual capture: window:PID and display: or display:#N. HTTP(S) sources accept image and sequence screenshots. Use named view parameters such as sequence:duration=2,interval=0.5,scale=0.5 and image:scale=0.5,region=0.25,0.25,0.5,0.5. Duration is limited to 10 seconds and sequences to 20 frames. Defaults: duration=${o.durationSeconds}, interval=${o.intervalSeconds}, scale=${o.scale}. Region uses normalized x,y,width,height and runs before scaling. For captures, limit is a square grid cell size in output pixels and offset is one zero-based row-major cell index; limit without offset selects cell 0, while offset without limit is invalid. Omit both for the bounded transformed image.`),s.addPromptGuideline("Use search with process:<query> before reading process:PID or window:PID. Capture arbitrary desktop windows and full displays only when their dedicated flags are enabled; Agent IDE-owned terminal processes are allowed by default. Use a bounded sequence view only when one image is insufficient; set named duration, interval, scale and region parameters when the defaults do not fit. Use limit and offset to select one image grid cell.")}}),k(e,{protocol:O,apiVersion:T,id:"vision-processes",setup(s){s.addResolver({priority:-100,resolver:{id:"processes",async tryResolve(o){let a=/^process:(.*)$/isu.exec(o.query);if(a===null)return{kind:"not-handled"};let d=(a[1]??"").trim().toLowerCase();return{kind:"resolved",payload:(await E(t)).filter(m=>d.length===0||String(m.pid)===d||m.command.toLowerCase().includes(d)).slice(0,Math.min(o.limit??50,100))}},format(o){let a=o;return{content:[{type:"text",text:a.length===0?"No matching processes.":a.map(Y).join(`
|
|
3
|
+
|
|
4
|
+
`)}],details:{count:a.length,processes:a}}}}}),s.describe("process:<query> finds running processes by PID or command for process:PID metadata reads and guarded window:PID capture."),s.addPromptGuideline("Use process:<query> to discover a PID before selecting a process or window source.")}})])}c(ue,"registerVision");function X(e,n){if(!e.startsWith(n))return;let r=e.slice(n.length);if(!/^\d+$/u.test(r))throw new Error(`${n} sources require a numeric PID`);return Number(r)}c(X,"prefixedPid");function R(e){return{...j(e.views,y())??{mode:"image",...y()},...e.limit===void 0?{}:{cellSize:e.limit},...e.offset===void 0?{}:{cellIndex:e.offset}}}c(R,"options");function le(e){return e.views?.some(n=>/^(?:image|sequence)(?::|$)/u.test(n))===!0}c(le,"requestsScreenshot");function v(e,n){return{kind:"return",result:{content:n,details:{source:e,resolvedBy:"vision"}}}}c(v,"returned");function g(e,n){return{kind:"return",result:{content:[{type:"text",text:n}],details:{source:e,resolvedBy:"vision",failure:{code:"READ_FAILED",source:e,resolverId:"vision",message:n}},isError:!0}}}c(g,"failed");function N(e){return e instanceof Error?e.message:String(e)}c(N,"errorMessage");function Y(e){return[`PID: ${e.pid}`,`Command: ${e.command}`,`Owned by Agent IDE: ${e.owned?"yes":"no"}`,...e.parentPid===void 0?[]:[`Parent PID: ${e.parentPid}`],...e.started===void 0?[]:[`Started: ${e.started}`],...e.source===void 0?[]:[`Agent IDE source: ${e.source}`]].join(`
|
|
5
|
+
`)}c(Y,"formatProcess");export{ue as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as p,e as f,k as g}from"./chunk-O6LE42GK.js";import{a as o}from"./chunk-EI7MMDWY.js";import{AsyncLocalStorage as m}from"node:async_hooks";var c=new m,l=new m;function E(t){let e=l.getStore();e?e.push(t):t()}o(E,"afterPostEditScope");async function T(t){if(l.getStore())return t();let e=[];try{return await l.run(e,t)}finally{for(let r of e)r()}}o(T,"collectPostEditNotifications");function b(t,e){let r=c.getStore();return r?(r.set(t,e),!0):!1}o(b,"deferPostEdit");function h(t){return c.getStore()?.has(t)??!1}o(h,"hasDeferredPostEdit");function v(t){c.getStore()?.delete(t)}o(v,"forgetDeferredPostEdit");function k(){let t=new Map;return{run(e){return c.run(t,e)},forget(e){t.delete(e)},async finish(e){let r=[...t.values()];t.clear();let d=[],i=[];if(await T(async()=>{for(let a of r)try{let s=await a();d.push(s),e?.(s)}catch(s){i.push(s)}}),i.length>0)throw new AggregateError(i,`Some final post-processing failed; completed edits remain applied. ${i.map(a=>a instanceof Error?a.message:String(a)).join("; ")}`);return d}}}o(k,"createPostEditScope");import{Type as n}from"typebox";import{Value as u}from"typebox/value";var w=`${p}/post-edit/register`;function M(t){return u.Check(n.Object({formatting:n.Object({status:n.Union(["disabled","unavailable","skipped-syntax","unchanged","changed","failed","not-reported","deferred"].map(e=>n.Literal(e))),formatter:n.Optional(n.String())})}),t)}o(M,"isFormattingContribution");function _(t){return u.Check(n.Object({diffStatuses:n.Array(n.Object({text:n.String({minLength:1}),formatter:n.Optional(n.String()),tone:n.Optional(n.Union(["muted","success","warning","error"].map(e=>n.Literal(e))))}))}),t)}o(_,"isDiffStatusContribution");var x=n.Function([],n.Unknown()),y=n.Object({id:n.String({minLength:1}),handler:x}),P=n.Object({registration:y,accept:x});function S(t){return u.Check(y,t)}o(S,"isTextPostEditHandlerRegistration");function j(t){return u.Check(P,t)}o(j,"isTextPostEditHandlerRegistrationRequest");function I(t){if(typeof t!="object"||t===null)return!1;let e=t;return Array.isArray(e.hints)&&typeof e.scopeMarkers=="object"&&e.scopeMarkers!==null&&Array.isArray(e.warnings)}o(I,"isTextMutationResultContributionData");function F(t,e){if(!S(e))throw new TypeError("Invalid text editor post-edit handler registration");let r,d=o(()=>{let a={registration:e,accept(s){if(r!==void 0)throw new Error(`Post-edit handler ${e.id} was accepted more than once`);r=s}};return t.events.emit(w,a),r!==void 0},"announce"),i=o(()=>{},"unsubscribeReady");i=t.events.on(f,a=>{if(!g(a))throw new Error("Invalid pi-agent-text-editor core readiness event");if(!d())throw new Error("pi-agent-text-editor core announced readiness without accepting the post-edit handler");i()}),t.on("session_shutdown",()=>{i(),r?.()}),d()&&i()}o(F,"connectTextEditorPostEditHandler");export{E as a,T as b,b as c,h as d,v as e,k as f,w as g,M as h,_ as i,S as j,j as k,I as l,F as m};
|