@opensumi/ide-ai-native 3.7.2-next-1740448398.0 → 3.7.2-next-1741226843.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/lib/browser/ai-core.contextkeys.d.ts +0 -1
- package/lib/browser/ai-core.contextkeys.d.ts.map +1 -1
- package/lib/browser/ai-core.contextkeys.js +0 -1
- package/lib/browser/ai-core.contextkeys.js.map +1 -1
- package/lib/browser/ai-core.contribution.d.ts +2 -8
- package/lib/browser/ai-core.contribution.d.ts.map +1 -1
- package/lib/browser/ai-core.contribution.js +20 -149
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/chat/chat-agent.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-agent.service.js +0 -6
- package/lib/browser/chat/chat-agent.service.js.map +1 -1
- package/lib/browser/chat/chat-manager.service.d.ts +2 -30
- package/lib/browser/chat/chat-manager.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-manager.service.js +1 -45
- package/lib/browser/chat/chat-manager.service.js.map +1 -1
- package/lib/browser/chat/chat-model.d.ts +7 -34
- package/lib/browser/chat/chat-model.d.ts.map +1 -1
- package/lib/browser/chat/chat-model.js +57 -71
- package/lib/browser/chat/chat-model.js.map +1 -1
- package/lib/browser/chat/chat-proxy.service.d.ts +1 -6
- package/lib/browser/chat/chat-proxy.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-proxy.service.js +3 -54
- package/lib/browser/chat/chat-proxy.service.js.map +1 -1
- package/lib/browser/chat/chat.api.service.d.ts +1 -1
- package/lib/browser/chat/chat.api.service.d.ts.map +1 -1
- package/lib/browser/chat/chat.api.service.js +2 -2
- package/lib/browser/chat/chat.api.service.js.map +1 -1
- package/lib/browser/chat/chat.internal.service.d.ts +2 -8
- package/lib/browser/chat/chat.internal.service.d.ts.map +1 -1
- package/lib/browser/chat/chat.internal.service.js +13 -41
- package/lib/browser/chat/chat.internal.service.js.map +1 -1
- package/lib/browser/chat/chat.module.less +41 -17
- package/lib/browser/chat/chat.view.d.ts.map +1 -1
- package/lib/browser/chat/chat.view.js +14 -102
- package/lib/browser/chat/chat.view.js.map +1 -1
- package/lib/browser/components/ChatEditor.d.ts +0 -1
- package/lib/browser/components/ChatEditor.d.ts.map +1 -1
- package/lib/browser/components/ChatEditor.js +3 -3
- package/lib/browser/components/ChatEditor.js.map +1 -1
- package/lib/browser/components/ChatInput.d.ts.map +1 -1
- package/lib/browser/components/ChatInput.js.map +1 -1
- package/lib/browser/components/ChatMarkdown.d.ts +0 -1
- package/lib/browser/components/ChatMarkdown.d.ts.map +1 -1
- package/lib/browser/components/ChatMarkdown.js +2 -2
- package/lib/browser/components/ChatMarkdown.js.map +1 -1
- package/lib/browser/components/ChatReply.d.ts.map +1 -1
- package/lib/browser/components/ChatReply.js +4 -29
- package/lib/browser/components/ChatReply.js.map +1 -1
- package/lib/browser/components/ChatThinking.js +1 -1
- package/lib/browser/components/ChatThinking.js.map +1 -1
- package/lib/browser/components/WelcomeMsg.js.map +1 -1
- package/lib/browser/components/components.module.less +31 -33
- package/lib/browser/components/utils.d.ts +2 -2
- package/lib/browser/contrib/intelligent-completions/index.d.ts +9 -16
- package/lib/browser/contrib/intelligent-completions/index.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/index.js +1 -6
- package/lib/browser/contrib/intelligent-completions/index.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.d.ts +0 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.js +4 -26
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.d.ts +5 -5
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.js +48 -59
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.d.ts +0 -4
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.js +0 -7
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/source/base.d.ts +5 -14
- package/lib/browser/contrib/intelligent-completions/source/base.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/source/base.js +8 -29
- package/lib/browser/contrib/intelligent-completions/source/base.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/source/line-change.source.d.ts +3 -10
- package/lib/browser/contrib/intelligent-completions/source/line-change.source.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/source/line-change.source.js +22 -95
- package/lib/browser/contrib/intelligent-completions/source/line-change.source.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/source/lint-error.source.d.ts +3 -1
- package/lib/browser/contrib/intelligent-completions/source/lint-error.source.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/source/lint-error.source.js +20 -13
- package/lib/browser/contrib/intelligent-completions/source/lint-error.source.js.map +1 -1
- package/lib/browser/contrib/terminal/component/terminal-command-suggest-controller.js +2 -2
- package/lib/browser/contrib/terminal/component/terminal-command-suggest-controller.js.map +1 -1
- package/lib/browser/index.d.ts +3 -11
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +4 -56
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/languages/tree-sitter/wasm-manager.d.ts.map +1 -1
- package/lib/browser/languages/tree-sitter/wasm-manager.js +2 -14
- package/lib/browser/languages/tree-sitter/wasm-manager.js.map +1 -1
- package/lib/browser/layout/ai-layout.d.ts.map +1 -1
- package/lib/browser/layout/ai-layout.js +2 -2
- package/lib/browser/layout/ai-layout.js.map +1 -1
- package/lib/browser/layout/layout.module.less +9 -9
- package/lib/browser/layout/tabbar.view.d.ts.map +1 -1
- package/lib/browser/layout/tabbar.view.js +6 -5
- package/lib/browser/layout/tabbar.view.js.map +1 -1
- package/lib/browser/model/enhanceDecorationsCollection.d.ts +10 -14
- package/lib/browser/model/enhanceDecorationsCollection.d.ts.map +1 -1
- package/lib/browser/model/enhanceDecorationsCollection.js +53 -42
- package/lib/browser/model/enhanceDecorationsCollection.js.map +1 -1
- package/lib/browser/model/msg-history-manager.d.ts +1 -20
- package/lib/browser/model/msg-history-manager.d.ts.map +1 -1
- package/lib/browser/model/msg-history-manager.js +10 -46
- package/lib/browser/model/msg-history-manager.js.map +1 -1
- package/lib/browser/model/styles.module.less +7 -0
- package/lib/browser/preferences/schema.d.ts.map +1 -1
- package/lib/browser/preferences/schema.js +0 -69
- package/lib/browser/preferences/schema.js.map +1 -1
- package/lib/browser/types.d.ts +4 -74
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/types.js +1 -4
- package/lib/browser/types.js.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat-editor.controller.d.ts +1 -2
- package/lib/browser/widget/inline-chat/inline-chat-editor.controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat-editor.controller.js +49 -21
- package/lib/browser/widget/inline-chat/inline-chat-editor.controller.js.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat.feature.registry.d.ts +13 -3
- package/lib/browser/widget/inline-chat/inline-chat.feature.registry.d.ts.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat.feature.registry.js +72 -24
- package/lib/browser/widget/inline-chat/inline-chat.feature.registry.js.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat.service.d.ts +6 -1
- package/lib/browser/widget/inline-chat/inline-chat.service.d.ts.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat.service.js +17 -5
- package/lib/browser/widget/inline-chat/inline-chat.service.js.map +1 -1
- package/lib/browser/widget/inline-chat/inline-content-widget.d.ts +5 -2
- package/lib/browser/widget/inline-chat/inline-content-widget.d.ts.map +1 -1
- package/lib/browser/widget/inline-chat/inline-content-widget.js +42 -17
- package/lib/browser/widget/inline-chat/inline-content-widget.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-previewer.d.ts +5 -22
- package/lib/browser/widget/inline-diff/inline-diff-previewer.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-previewer.js +30 -61
- package/lib/browser/widget/inline-diff/inline-diff-previewer.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff.controller.d.ts +12 -8
- package/lib/browser/widget/inline-diff/inline-diff.controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff.controller.js +96 -68
- package/lib/browser/widget/inline-diff/inline-diff.controller.js.map +1 -1
- package/lib/browser/widget/inline-hint/inline-hint.controller.d.ts +1 -0
- package/lib/browser/widget/inline-hint/inline-hint.controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-hint/inline-hint.controller.js +5 -0
- package/lib/browser/widget/inline-hint/inline-hint.controller.js.map +1 -1
- package/lib/browser/widget/inline-input/inline-input-widget.d.ts +2 -12
- package/lib/browser/widget/inline-input/inline-input-widget.d.ts.map +1 -1
- package/lib/browser/widget/inline-input/inline-input-widget.js +18 -26
- package/lib/browser/widget/inline-input/inline-input-widget.js.map +1 -1
- package/lib/browser/widget/inline-input/inline-input.controller.d.ts +5 -14
- package/lib/browser/widget/inline-input/inline-input.controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-input/inline-input.controller.js +165 -321
- package/lib/browser/widget/inline-input/inline-input.controller.js.map +1 -1
- package/lib/browser/widget/inline-input/inline-input.module.less +0 -4
- package/lib/browser/widget/inline-input/inline-input.service.d.ts +7 -19
- package/lib/browser/widget/inline-input/inline-input.service.d.ts.map +1 -1
- package/lib/browser/widget/inline-input/inline-input.service.js +12 -72
- package/lib/browser/widget/inline-input/inline-input.service.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.d.ts +19 -9
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.js +39 -47
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.component.d.ts +4 -21
- package/lib/browser/widget/inline-stream-diff/live-preview.component.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.component.js +5 -37
- package/lib/browser/widget/inline-stream-diff/live-preview.component.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.d.ts +11 -7
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.js +77 -34
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.js.map +1 -1
- package/lib/common/index.d.ts +0 -10
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +1 -4
- package/lib/common/index.js.map +1 -1
- package/lib/common/types.d.ts +0 -17
- package/lib/common/types.d.ts.map +1 -1
- package/lib/common/utils.d.ts +0 -1
- package/lib/common/utils.d.ts.map +1 -1
- package/lib/common/utils.js +3 -5
- package/lib/common/utils.js.map +1 -1
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +0 -19
- package/lib/node/index.js.map +1 -1
- package/package.json +22 -33
- package/src/browser/ai-core.contextkeys.ts +0 -3
- package/src/browser/ai-core.contribution.ts +21 -167
- package/src/browser/chat/chat-agent.service.ts +0 -7
- package/src/browser/chat/chat-manager.service.ts +7 -83
- package/src/browser/chat/chat-model.ts +20 -86
- package/src/browser/chat/chat-proxy.service.ts +3 -55
- package/src/browser/chat/chat.api.service.ts +2 -2
- package/src/browser/chat/chat.internal.service.ts +6 -35
- package/src/browser/chat/chat.module.less +41 -17
- package/src/browser/chat/chat.view.tsx +45 -191
- package/src/browser/components/ChatEditor.tsx +10 -13
- package/src/browser/components/ChatInput.tsx +0 -1
- package/src/browser/components/ChatMarkdown.tsx +2 -4
- package/src/browser/components/ChatReply.tsx +9 -38
- package/src/browser/components/ChatThinking.tsx +1 -1
- package/src/browser/components/WelcomeMsg.tsx +1 -1
- package/src/browser/components/components.module.less +31 -33
- package/src/browser/contrib/intelligent-completions/index.ts +4 -19
- package/src/browser/contrib/intelligent-completions/intelligent-completions.contribution.ts +8 -32
- package/src/browser/contrib/intelligent-completions/intelligent-completions.controller.ts +67 -102
- package/src/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.ts +0 -11
- package/src/browser/contrib/intelligent-completions/source/base.ts +14 -39
- package/src/browser/contrib/intelligent-completions/source/line-change.source.ts +22 -129
- package/src/browser/contrib/intelligent-completions/source/lint-error.source.ts +31 -19
- package/src/browser/contrib/terminal/component/terminal-command-suggest-controller.tsx +1 -1
- package/src/browser/index.ts +6 -69
- package/src/browser/languages/tree-sitter/wasm-manager.ts +2 -12
- package/src/browser/layout/ai-layout.tsx +2 -5
- package/src/browser/layout/layout.module.less +9 -9
- package/src/browser/layout/tabbar.view.tsx +8 -10
- package/src/browser/model/enhanceDecorationsCollection.ts +77 -62
- package/src/browser/model/msg-history-manager.ts +2 -56
- package/src/browser/model/styles.module.less +7 -0
- package/src/browser/preferences/schema.ts +0 -69
- package/src/browser/types.ts +5 -100
- package/src/browser/widget/inline-chat/inline-chat-editor.controller.ts +65 -30
- package/src/browser/widget/inline-chat/inline-chat.feature.registry.ts +90 -23
- package/src/browser/widget/inline-chat/inline-chat.service.ts +17 -2
- package/src/browser/widget/inline-chat/inline-content-widget.tsx +69 -14
- package/src/browser/widget/inline-diff/inline-diff-previewer.ts +32 -87
- package/src/browser/widget/inline-diff/inline-diff.controller.ts +114 -90
- package/src/browser/widget/inline-hint/inline-hint.controller.ts +7 -1
- package/src/browser/widget/inline-input/inline-input-widget.tsx +12 -34
- package/src/browser/widget/inline-input/inline-input.controller.ts +242 -454
- package/src/browser/widget/inline-input/inline-input.module.less +0 -4
- package/src/browser/widget/inline-input/inline-input.service.ts +13 -92
- package/src/browser/widget/inline-stream-diff/inline-stream-diff.handler.tsx +67 -58
- package/src/browser/widget/inline-stream-diff/live-preview.component.tsx +6 -49
- package/src/browser/widget/inline-stream-diff/live-preview.decoration.tsx +112 -41
- package/src/common/index.ts +0 -15
- package/src/common/types.ts +0 -22
- package/src/common/utils.ts +2 -4
- package/src/node/index.ts +0 -21
- package/lib/browser/components/ChatContext/ContextSelector.d.ts +0 -12
- package/lib/browser/components/ChatContext/ContextSelector.d.ts.map +0 -1
- package/lib/browser/components/ChatContext/ContextSelector.js +0 -113
- package/lib/browser/components/ChatContext/ContextSelector.js.map +0 -1
- package/lib/browser/components/ChatContext/index.d.ts +0 -4
- package/lib/browser/components/ChatContext/index.d.ts.map +0 -1
- package/lib/browser/components/ChatContext/index.js +0 -100
- package/lib/browser/components/ChatContext/index.js.map +0 -1
- package/lib/browser/components/ChatContext/style.module.less +0 -201
- package/lib/browser/components/ChatHistory.d.ts +0 -21
- package/lib/browser/components/ChatHistory.d.ts.map +0 -1
- package/lib/browser/components/ChatHistory.js +0 -148
- package/lib/browser/components/ChatHistory.js.map +0 -1
- package/lib/browser/components/ChatToolRender.d.ts +0 -7
- package/lib/browser/components/ChatToolRender.d.ts.map +0 -1
- package/lib/browser/components/ChatToolRender.js +0 -71
- package/lib/browser/components/ChatToolRender.js.map +0 -1
- package/lib/browser/components/ChatToolRender.module.less +0 -86
- package/lib/browser/components/chat-history.css +0 -139
- package/lib/browser/context/llm-context.contribution.d.ts +0 -7
- package/lib/browser/context/llm-context.contribution.d.ts.map +0 -1
- package/lib/browser/context/llm-context.contribution.js +0 -21
- package/lib/browser/context/llm-context.contribution.js.map +0 -1
- package/lib/browser/context/llm-context.service.d.ts +0 -36
- package/lib/browser/context/llm-context.service.d.ts.map +0 -1
- package/lib/browser/context/llm-context.service.js +0 -170
- package/lib/browser/context/llm-context.service.js.map +0 -1
- package/lib/browser/contrib/intelligent-completions/source/trigger.source.d.ts +0 -13
- package/lib/browser/contrib/intelligent-completions/source/trigger.source.d.ts.map +0 -1
- package/lib/browser/contrib/intelligent-completions/source/trigger.source.js +0 -36
- package/lib/browser/contrib/intelligent-completions/source/trigger.source.js.map +0 -1
- package/lib/browser/contrib/intelligent-completions/source/typing.source.d.ts +0 -9
- package/lib/browser/contrib/intelligent-completions/source/typing.source.d.ts.map +0 -1
- package/lib/browser/contrib/intelligent-completions/source/typing.source.js +0 -36
- package/lib/browser/contrib/intelligent-completions/source/typing.source.js.map +0 -1
- package/lib/browser/mcp/base-apply.service.d.ts +0 -67
- package/lib/browser/mcp/base-apply.service.d.ts.map +0 -1
- package/lib/browser/mcp/base-apply.service.js +0 -290
- package/lib/browser/mcp/base-apply.service.js.map +0 -1
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts +0 -30
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts.map +0 -1
- package/lib/browser/mcp/mcp-server-proxy.service.js +0 -57
- package/lib/browser/mcp/mcp-server-proxy.service.js.map +0 -1
- package/lib/browser/mcp/mcp-server.feature.registry.d.ts +0 -20
- package/lib/browser/mcp/mcp-server.feature.registry.d.ts.map +0 -1
- package/lib/browser/mcp/mcp-server.feature.registry.js +0 -69
- package/lib/browser/mcp/mcp-server.feature.registry.js.map +0 -1
- package/lib/browser/mcp/mcp-tools-dialog.module.less +0 -44
- package/lib/browser/mcp/mcp-tools-dialog.view.d.ts +0 -8
- package/lib/browser/mcp/mcp-tools-dialog.view.d.ts.map +0 -1
- package/lib/browser/mcp/mcp-tools-dialog.view.js +0 -16
- package/lib/browser/mcp/mcp-tools-dialog.view.js.map +0 -1
- package/lib/browser/mcp/tools/components/EditFile.d.ts +0 -3
- package/lib/browser/mcp/tools/components/EditFile.d.ts.map +0 -1
- package/lib/browser/mcp/tools/components/EditFile.js +0 -101
- package/lib/browser/mcp/tools/components/EditFile.js.map +0 -1
- package/lib/browser/mcp/tools/components/SearchResult.d.ts +0 -11
- package/lib/browser/mcp/tools/components/SearchResult.d.ts.map +0 -1
- package/lib/browser/mcp/tools/components/SearchResult.js +0 -60
- package/lib/browser/mcp/tools/components/SearchResult.js.map +0 -1
- package/lib/browser/mcp/tools/components/Terminal.d.ts +0 -4
- package/lib/browser/mcp/tools/components/Terminal.d.ts.map +0 -1
- package/lib/browser/mcp/tools/components/Terminal.js +0 -64
- package/lib/browser/mcp/tools/components/Terminal.js.map +0 -1
- package/lib/browser/mcp/tools/components/index.module.less +0 -168
- package/lib/browser/mcp/tools/createNewFileWithText.d.ts +0 -9
- package/lib/browser/mcp/tools/createNewFileWithText.d.ts.map +0 -1
- package/lib/browser/mcp/tools/createNewFileWithText.js +0 -82
- package/lib/browser/mcp/tools/createNewFileWithText.js.map +0 -1
- package/lib/browser/mcp/tools/editFile.d.ts +0 -8
- package/lib/browser/mcp/tools/editFile.d.ts.map +0 -1
- package/lib/browser/mcp/tools/editFile.js +0 -95
- package/lib/browser/mcp/tools/editFile.js.map +0 -1
- package/lib/browser/mcp/tools/fileSearch.d.ts +0 -10
- package/lib/browser/mcp/tools/fileSearch.d.ts.map +0 -1
- package/lib/browser/mcp/tools/fileSearch.js +0 -94
- package/lib/browser/mcp/tools/fileSearch.js.map +0 -1
- package/lib/browser/mcp/tools/getDiagnosticsByPath.d.ts +0 -10
- package/lib/browser/mcp/tools/getDiagnosticsByPath.d.ts.map +0 -1
- package/lib/browser/mcp/tools/getDiagnosticsByPath.js +0 -118
- package/lib/browser/mcp/tools/getDiagnosticsByPath.js.map +0 -1
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.d.ts +0 -11
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.d.ts.map +0 -1
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.js +0 -118
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.js.map +0 -1
- package/lib/browser/mcp/tools/grepSearch.d.ts +0 -10
- package/lib/browser/mcp/tools/grepSearch.d.ts.map +0 -1
- package/lib/browser/mcp/tools/grepSearch.js +0 -118
- package/lib/browser/mcp/tools/grepSearch.js.map +0 -1
- package/lib/browser/mcp/tools/handlers/EditFile.d.ts +0 -10
- package/lib/browser/mcp/tools/handlers/EditFile.d.ts.map +0 -1
- package/lib/browser/mcp/tools/handlers/EditFile.js +0 -28
- package/lib/browser/mcp/tools/handlers/EditFile.js.map +0 -1
- package/lib/browser/mcp/tools/handlers/ListDir.d.ts +0 -21
- package/lib/browser/mcp/tools/handlers/ListDir.d.ts.map +0 -1
- package/lib/browser/mcp/tools/handlers/ListDir.js +0 -112
- package/lib/browser/mcp/tools/handlers/ListDir.js.map +0 -1
- package/lib/browser/mcp/tools/handlers/ReadFile.d.ts +0 -53
- package/lib/browser/mcp/tools/handlers/ReadFile.d.ts.map +0 -1
- package/lib/browser/mcp/tools/handlers/ReadFile.js +0 -161
- package/lib/browser/mcp/tools/handlers/ReadFile.js.map +0 -1
- package/lib/browser/mcp/tools/handlers/RunCommand.d.ts +0 -43
- package/lib/browser/mcp/tools/handlers/RunCommand.d.ts.map +0 -1
- package/lib/browser/mcp/tools/handlers/RunCommand.js +0 -104
- package/lib/browser/mcp/tools/handlers/RunCommand.js.map +0 -1
- package/lib/browser/mcp/tools/handlers/utils.d.ts +0 -2
- package/lib/browser/mcp/tools/handlers/utils.d.ts.map +0 -1
- package/lib/browser/mcp/tools/handlers/utils.js +0 -7
- package/lib/browser/mcp/tools/handlers/utils.js.map +0 -1
- package/lib/browser/mcp/tools/listDir.d.ts +0 -8
- package/lib/browser/mcp/tools/listDir.d.ts.map +0 -1
- package/lib/browser/mcp/tools/listDir.js +0 -64
- package/lib/browser/mcp/tools/listDir.js.map +0 -1
- package/lib/browser/mcp/tools/readFile.d.ts +0 -8
- package/lib/browser/mcp/tools/readFile.d.ts.map +0 -1
- package/lib/browser/mcp/tools/readFile.js +0 -81
- package/lib/browser/mcp/tools/readFile.js.map +0 -1
- package/lib/browser/mcp/tools/runTerminalCmd.d.ts +0 -13
- package/lib/browser/mcp/tools/runTerminalCmd.d.ts.map +0 -1
- package/lib/browser/mcp/tools/runTerminalCmd.js +0 -49
- package/lib/browser/mcp/tools/runTerminalCmd.js.map +0 -1
- package/lib/browser/widget/inline-input/model.d.ts +0 -34
- package/lib/browser/widget/inline-input/model.d.ts.map +0 -1
- package/lib/browser/widget/inline-input/model.js +0 -63
- package/lib/browser/widget/inline-input/model.js.map +0 -1
- package/lib/common/llm-context.d.ts +0 -40
- package/lib/common/llm-context.d.ts.map +0 -1
- package/lib/common/llm-context.js +0 -5
- package/lib/common/llm-context.js.map +0 -1
- package/lib/common/mcp-server-manager.d.ts +0 -40
- package/lib/common/mcp-server-manager.d.ts.map +0 -1
- package/lib/common/mcp-server-manager.js +0 -6
- package/lib/common/mcp-server-manager.js.map +0 -1
- package/lib/common/prompts/context-prompt-provider.d.ts +0 -14
- package/lib/common/prompts/context-prompt-provider.d.ts.map +0 -1
- package/lib/common/prompts/context-prompt-provider.js +0 -38
- package/lib/common/prompts/context-prompt-provider.js.map +0 -1
- package/lib/common/tool-invocation-registry.d.ts +0 -92
- package/lib/common/tool-invocation-registry.d.ts.map +0 -1
- package/lib/common/tool-invocation-registry.js +0 -90
- package/lib/common/tool-invocation-registry.js.map +0 -1
- package/lib/node/anthropic/anthropic-language-model.d.ts +0 -9
- package/lib/node/anthropic/anthropic-language-model.d.ts.map +0 -1
- package/lib/node/anthropic/anthropic-language-model.js +0 -26
- package/lib/node/anthropic/anthropic-language-model.js.map +0 -1
- package/lib/node/base-language-model.d.ts +0 -14
- package/lib/node/base-language-model.d.ts.map +0 -1
- package/lib/node/base-language-model.js +0 -140
- package/lib/node/base-language-model.js.map +0 -1
- package/lib/node/deepseek/deepseek-language-model.d.ts +0 -9
- package/lib/node/deepseek/deepseek-language-model.d.ts.map +0 -1
- package/lib/node/deepseek/deepseek-language-model.js +0 -26
- package/lib/node/deepseek/deepseek-language-model.js.map +0 -1
- package/lib/node/mcp/sumi-mcp-server.d.ts +0 -91
- package/lib/node/mcp/sumi-mcp-server.d.ts.map +0 -1
- package/lib/node/mcp/sumi-mcp-server.js +0 -175
- package/lib/node/mcp/sumi-mcp-server.js.map +0 -1
- package/lib/node/mcp-server-manager-impl.d.ts +0 -27
- package/lib/node/mcp-server-manager-impl.d.ts.map +0 -1
- package/lib/node/mcp-server-manager-impl.js +0 -128
- package/lib/node/mcp-server-manager-impl.js.map +0 -1
- package/lib/node/mcp-server.d.ts +0 -207
- package/lib/node/mcp-server.d.ts.map +0 -1
- package/lib/node/mcp-server.js +0 -92
- package/lib/node/mcp-server.js.map +0 -1
- package/lib/node/openai/openai-language-model.d.ts +0 -9
- package/lib/node/openai/openai-language-model.d.ts.map +0 -1
- package/lib/node/openai/openai-language-model.js +0 -29
- package/lib/node/openai/openai-language-model.js.map +0 -1
- package/src/browser/components/ChatContext/ContextSelector.tsx +0 -177
- package/src/browser/components/ChatContext/index.tsx +0 -151
- package/src/browser/components/ChatContext/style.module.less +0 -201
- package/src/browser/components/ChatHistory.tsx +0 -292
- package/src/browser/components/ChatToolRender.module.less +0 -86
- package/src/browser/components/ChatToolRender.tsx +0 -96
- package/src/browser/components/chat-history.css +0 -139
- package/src/browser/context/llm-context.contribution.ts +0 -14
- package/src/browser/context/llm-context.service.ts +0 -200
- package/src/browser/contrib/intelligent-completions/source/trigger.source.ts +0 -44
- package/src/browser/contrib/intelligent-completions/source/typing.source.ts +0 -34
- package/src/browser/mcp/base-apply.service.ts +0 -349
- package/src/browser/mcp/mcp-server-proxy.service.ts +0 -55
- package/src/browser/mcp/mcp-server.feature.registry.ts +0 -77
- package/src/browser/mcp/mcp-tools-dialog.module.less +0 -44
- package/src/browser/mcp/mcp-tools-dialog.view.tsx +0 -24
- package/src/browser/mcp/tools/components/EditFile.tsx +0 -144
- package/src/browser/mcp/tools/components/SearchResult.tsx +0 -92
- package/src/browser/mcp/tools/components/Terminal.tsx +0 -97
- package/src/browser/mcp/tools/components/index.module.less +0 -168
- package/src/browser/mcp/tools/createNewFileWithText.ts +0 -82
- package/src/browser/mcp/tools/editFile.ts +0 -100
- package/src/browser/mcp/tools/fileSearch.ts +0 -99
- package/src/browser/mcp/tools/getDiagnosticsByPath.ts +0 -122
- package/src/browser/mcp/tools/getOpenEditorFileDiagnostics.ts +0 -120
- package/src/browser/mcp/tools/grepSearch.ts +0 -121
- package/src/browser/mcp/tools/handlers/EditFile.ts +0 -21
- package/src/browser/mcp/tools/handlers/ListDir.ts +0 -117
- package/src/browser/mcp/tools/handlers/ReadFile.ts +0 -192
- package/src/browser/mcp/tools/handlers/RunCommand.ts +0 -115
- package/src/browser/mcp/tools/handlers/utils.ts +0 -3
- package/src/browser/mcp/tools/listDir.ts +0 -65
- package/src/browser/mcp/tools/readFile.ts +0 -81
- package/src/browser/mcp/tools/runTerminalCmd.ts +0 -45
- package/src/browser/widget/inline-input/model.ts +0 -74
- package/src/common/llm-context.ts +0 -47
- package/src/common/mcp-server-manager.ts +0 -51
- package/src/common/prompts/context-prompt-provider.ts +0 -46
- package/src/common/tool-invocation-registry.ts +0 -168
- package/src/node/anthropic/anthropic-language-model.ts +0 -25
- package/src/node/base-language-model.ts +0 -177
- package/src/node/deepseek/deepseek-language-model.ts +0 -25
- package/src/node/mcp/sumi-mcp-server.ts +0 -200
- package/src/node/mcp-server-manager-impl.ts +0 -156
- package/src/node/mcp-server.ts +0 -127
- package/src/node/openai/openai-language-model.ts +0 -25
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { Autowired, Injectable } from '@opensumi/di';
|
|
2
|
-
import { AppConfig, Throttler, URI } from '@opensumi/ide-core-browser';
|
|
3
|
-
import { IFileServiceClient } from '@opensumi/ide-file-service';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 并发限制器
|
|
7
|
-
*/
|
|
8
|
-
class ConcurrencyLimiter {
|
|
9
|
-
private maxConcurrent: number;
|
|
10
|
-
private currentCount: number;
|
|
11
|
-
private pendingQueue: (() => void)[];
|
|
12
|
-
/**
|
|
13
|
-
* @param {number} maxConcurrent - 最大并发数
|
|
14
|
-
*/
|
|
15
|
-
constructor(maxConcurrent) {
|
|
16
|
-
this.maxConcurrent = maxConcurrent; // 最大并发数
|
|
17
|
-
this.currentCount = 0; // 当前执行的任务数
|
|
18
|
-
this.pendingQueue = []; // 等待执行的任务队列
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* 执行异步任务
|
|
23
|
-
* @param {Function} fn - 要执行的异步函数
|
|
24
|
-
* @returns {Promise} 任务执行的结果
|
|
25
|
-
*/
|
|
26
|
-
async execute(fn) {
|
|
27
|
-
// 如果当前执行的任务数达到最大并发数,则加入等待队列
|
|
28
|
-
if (this.currentCount >= this.maxConcurrent) {
|
|
29
|
-
await new Promise<void>((resolve) => this.pendingQueue.push(resolve));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
this.currentCount++;
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
// 执行任务
|
|
36
|
-
const result = await fn();
|
|
37
|
-
return result;
|
|
38
|
-
} finally {
|
|
39
|
-
this.currentCount--;
|
|
40
|
-
// 如果等待队列中有任务,则允许执行下一个任务
|
|
41
|
-
if (this.pendingQueue.length > 0) {
|
|
42
|
-
const next = this.pendingQueue.shift();
|
|
43
|
-
next?.();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@Injectable()
|
|
50
|
-
export class ListDirHandler {
|
|
51
|
-
private readonly MAX_FILE_SIZE = 1024 * 1024; // 1MB
|
|
52
|
-
private readonly MAX_INDEXED_FILES = 50;
|
|
53
|
-
@Autowired(AppConfig)
|
|
54
|
-
private readonly appConfig: AppConfig;
|
|
55
|
-
|
|
56
|
-
@Autowired(IFileServiceClient)
|
|
57
|
-
private readonly fileSystemService: IFileServiceClient;
|
|
58
|
-
|
|
59
|
-
async handler(args: { relativeWorkspacePath: string }) {
|
|
60
|
-
const { relativeWorkspacePath } = args;
|
|
61
|
-
if (!relativeWorkspacePath) {
|
|
62
|
-
throw new Error('No list dir parameters provided. Need to give at least the path.');
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// 解析相对路径
|
|
66
|
-
const absolutePath = `${this.appConfig.workspaceDir}/${relativeWorkspacePath}`;
|
|
67
|
-
const fileStat = await this.fileSystemService.getFileStat(absolutePath, true);
|
|
68
|
-
// 验证路径有效性
|
|
69
|
-
if (!fileStat || !fileStat.isDirectory) {
|
|
70
|
-
throw new Error(`Could not find file ${relativeWorkspacePath} in the workspace.`);
|
|
71
|
-
}
|
|
72
|
-
// 过滤符合大小限制的文件
|
|
73
|
-
const filesWithinSizeLimit =
|
|
74
|
-
fileStat.children
|
|
75
|
-
?.filter((file) => !file.isDirectory && file.size !== void 0 && file.size <= this.MAX_FILE_SIZE)
|
|
76
|
-
.slice(0, this.MAX_INDEXED_FILES) || [];
|
|
77
|
-
|
|
78
|
-
// 记录需要分析的文件名
|
|
79
|
-
const filesToAnalyze = new Set(filesWithinSizeLimit.map((file) => new URI(file.uri).displayName));
|
|
80
|
-
|
|
81
|
-
// 创建并发限制器
|
|
82
|
-
const concurrencyLimiter = new ConcurrencyLimiter(4);
|
|
83
|
-
// 处理所有文件信息
|
|
84
|
-
const fileInfos = await Promise.all(
|
|
85
|
-
fileStat.children
|
|
86
|
-
?.sort((a, b) => b.lastModification - a.lastModification)
|
|
87
|
-
.map(async (file) => {
|
|
88
|
-
const uri = new URI(file.uri);
|
|
89
|
-
const filePath = `${absolutePath}/${uri.displayName}`;
|
|
90
|
-
let lineCount: number | undefined;
|
|
91
|
-
|
|
92
|
-
// 如果文件需要分析,则计算行数
|
|
93
|
-
if (filesToAnalyze.has(uri.displayName)) {
|
|
94
|
-
lineCount = await concurrencyLimiter.execute(async () => this.countFileLines(filePath));
|
|
95
|
-
}
|
|
96
|
-
return {
|
|
97
|
-
name: uri.displayName,
|
|
98
|
-
isDirectory: file.isDirectory,
|
|
99
|
-
size: file.size,
|
|
100
|
-
lastModified: file.lastModification,
|
|
101
|
-
numChildren: file.children?.length,
|
|
102
|
-
numLines: lineCount,
|
|
103
|
-
};
|
|
104
|
-
}) || [],
|
|
105
|
-
);
|
|
106
|
-
// TODO: 过滤忽略文件
|
|
107
|
-
return {
|
|
108
|
-
files: fileInfos,
|
|
109
|
-
directoryRelativeWorkspacePath: relativeWorkspacePath,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
async countFileLines(filePath: string) {
|
|
114
|
-
const file = await this.fileSystemService.readFile(URI.file(filePath).toString());
|
|
115
|
-
return file.toString().split('\n').length;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import { Autowired, Injectable } from '@opensumi/di';
|
|
2
|
-
import { FileSearchQuickCommandHandler } from '@opensumi/ide-addons/lib/browser/file-search.contribution';
|
|
3
|
-
import { AppConfig } from '@opensumi/ide-core-browser';
|
|
4
|
-
import { CancellationToken, URI } from '@opensumi/ide-core-common';
|
|
5
|
-
import { IEditorDocumentModelRef, IEditorDocumentModelService } from '@opensumi/ide-editor/lib/browser';
|
|
6
|
-
import { IFileServiceClient } from '@opensumi/ide-file-service';
|
|
7
|
-
|
|
8
|
-
@Injectable()
|
|
9
|
-
export class FileHandler {
|
|
10
|
-
private static readonly MAX_FILE_SIZE_BYTES = 2e6;
|
|
11
|
-
private static readonly MAX_LINES = 250;
|
|
12
|
-
private static readonly MAX_CHARS = 1e5;
|
|
13
|
-
private static readonly NEWLINE = '\n';
|
|
14
|
-
|
|
15
|
-
private fileResultMap: Map<
|
|
16
|
-
string,
|
|
17
|
-
{ content: string; startLineOneIndexed: number; endLineOneIndexedInclusive: number }
|
|
18
|
-
> = new Map();
|
|
19
|
-
|
|
20
|
-
@Autowired(IEditorDocumentModelService)
|
|
21
|
-
protected modelService: IEditorDocumentModelService;
|
|
22
|
-
|
|
23
|
-
@Autowired(FileSearchQuickCommandHandler)
|
|
24
|
-
protected fileSearchQuickCommandHandler: FileSearchQuickCommandHandler;
|
|
25
|
-
|
|
26
|
-
@Autowired(AppConfig)
|
|
27
|
-
protected appConfig: AppConfig;
|
|
28
|
-
|
|
29
|
-
@Autowired(IFileServiceClient)
|
|
30
|
-
protected fileSystemService: IFileServiceClient;
|
|
31
|
-
|
|
32
|
-
async findSimilarFiles(filePath: string, maxResults: number): Promise<string[]> {
|
|
33
|
-
const items = await this.fileSearchQuickCommandHandler.getQueryFiles(filePath, new Set(), CancellationToken.None);
|
|
34
|
-
return items
|
|
35
|
-
.slice(0, maxResults)
|
|
36
|
-
.map((item) => item.getUri()?.codeUri.fsPath)
|
|
37
|
-
.filter(Boolean) as string[];
|
|
38
|
-
}
|
|
39
|
-
// TODO: 错误应该给模型?
|
|
40
|
-
private createFileNotFoundError(filePath: string, similarFiles: string[]): Error {
|
|
41
|
-
const errorMessage =
|
|
42
|
-
similarFiles.length > 0
|
|
43
|
-
? `Could not find file '${filePath}'. Did you mean one of:\n${similarFiles
|
|
44
|
-
.map((file) => `- ${file}`)
|
|
45
|
-
.join('\n')}`
|
|
46
|
-
: `Could not find file '${filePath}' in the workspace.`;
|
|
47
|
-
|
|
48
|
-
return new Error(
|
|
49
|
-
JSON.stringify({
|
|
50
|
-
clientVisibleErrorMessage: errorMessage,
|
|
51
|
-
modelVisibleErrorMessage: errorMessage,
|
|
52
|
-
actualErrorMessage: `File not found: ${filePath}`,
|
|
53
|
-
}),
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
private createFileTooLargeError(fileSizeMB: string, fileStatsSize: number): Error {
|
|
58
|
-
return new Error(
|
|
59
|
-
JSON.stringify({
|
|
60
|
-
clientVisibleErrorMessage: `File is too large, >${fileSizeMB}MB`,
|
|
61
|
-
modelVisibleErrorMessage: `The file is too large to read, was >${fileSizeMB}MB`,
|
|
62
|
-
actualErrorMessage: `File is too large to read, was >${fileSizeMB}MB, size: ${fileStatsSize} bytes`,
|
|
63
|
-
}),
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
private trimContent(content: string, maxChars: number): string {
|
|
68
|
-
return content.slice(0, maxChars).split(FileHandler.NEWLINE).slice(0, -1).join(FileHandler.NEWLINE);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
private getLineRange(
|
|
72
|
-
fileParams: {
|
|
73
|
-
startLineOneIndexed?: number;
|
|
74
|
-
endLineOneIndexedInclusive?: number;
|
|
75
|
-
},
|
|
76
|
-
forceLimit: boolean,
|
|
77
|
-
): { start: number; end: number; didShorten: boolean; didSetDefault: boolean } {
|
|
78
|
-
let start = fileParams.startLineOneIndexed ?? 1;
|
|
79
|
-
let end = fileParams.endLineOneIndexedInclusive ?? start + FileHandler.MAX_LINES - 1;
|
|
80
|
-
let didShorten = false;
|
|
81
|
-
let didSetDefault = false;
|
|
82
|
-
|
|
83
|
-
if (forceLimit) {
|
|
84
|
-
return { start, end, didShorten, didSetDefault };
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (fileParams.endLineOneIndexedInclusive === undefined || fileParams.startLineOneIndexed === undefined) {
|
|
88
|
-
start = 1;
|
|
89
|
-
end = FileHandler.MAX_LINES;
|
|
90
|
-
didSetDefault = true;
|
|
91
|
-
} else if (fileParams.endLineOneIndexedInclusive - fileParams.startLineOneIndexed > FileHandler.MAX_LINES) {
|
|
92
|
-
end = fileParams.startLineOneIndexed + FileHandler.MAX_LINES;
|
|
93
|
-
didShorten = true;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return { start, end, didShorten, didSetDefault };
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
async readFile(fileParams: {
|
|
100
|
-
relativeWorkspacePath: string;
|
|
101
|
-
readEntireFile: boolean;
|
|
102
|
-
fileIsAllowedToBeReadEntirely?: boolean;
|
|
103
|
-
startLineOneIndexed?: number;
|
|
104
|
-
endLineOneIndexedInclusive?: number;
|
|
105
|
-
}) {
|
|
106
|
-
if (!fileParams) {
|
|
107
|
-
throw new Error('No read file parameters provided. Need to give at least the path.');
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const uri = new URI(`${this.appConfig.workspaceDir}/${fileParams.relativeWorkspacePath}`);
|
|
111
|
-
if (!uri) {
|
|
112
|
-
const similarFiles = await this.findSimilarFiles(fileParams.relativeWorkspacePath, 3);
|
|
113
|
-
throw this.createFileNotFoundError(fileParams.relativeWorkspacePath, similarFiles);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const fileSizeMB = (FileHandler.MAX_FILE_SIZE_BYTES / 1e6).toFixed(2);
|
|
117
|
-
const fileStats = await this.fileSystemService.getFileStat(uri.toString());
|
|
118
|
-
|
|
119
|
-
if (fileStats?.size && fileStats.size > FileHandler.MAX_FILE_SIZE_BYTES) {
|
|
120
|
-
throw this.createFileTooLargeError(fileSizeMB, fileStats.size);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
let modelReference: IEditorDocumentModelRef | undefined;
|
|
124
|
-
try {
|
|
125
|
-
modelReference = await this.modelService.createModelReference(uri);
|
|
126
|
-
const fileContent = modelReference.instance.getMonacoModel().getValue();
|
|
127
|
-
const fileLines = fileContent.split(FileHandler.NEWLINE);
|
|
128
|
-
|
|
129
|
-
const shouldLimitLines = !(fileParams.readEntireFile && fileParams.fileIsAllowedToBeReadEntirely);
|
|
130
|
-
const shouldForceLimitLines = fileParams.readEntireFile && !fileParams.fileIsAllowedToBeReadEntirely;
|
|
131
|
-
let didShortenCharRange = false;
|
|
132
|
-
|
|
133
|
-
if (shouldLimitLines) {
|
|
134
|
-
const {
|
|
135
|
-
start,
|
|
136
|
-
end,
|
|
137
|
-
didShorten: didShortenLineRange,
|
|
138
|
-
didSetDefault: didSetDefaultLineRange,
|
|
139
|
-
} = this.getLineRange(fileParams, shouldForceLimitLines);
|
|
140
|
-
|
|
141
|
-
const adjustedStart = Math.max(start, 1);
|
|
142
|
-
const adjustedEnd = Math.min(end, fileLines.length);
|
|
143
|
-
let selectedContent = fileLines.slice(adjustedStart - 1, adjustedEnd).join(FileHandler.NEWLINE);
|
|
144
|
-
|
|
145
|
-
if (selectedContent.length > FileHandler.MAX_CHARS) {
|
|
146
|
-
didShortenCharRange = true;
|
|
147
|
-
selectedContent = this.trimContent(selectedContent, FileHandler.MAX_CHARS);
|
|
148
|
-
}
|
|
149
|
-
// 文件的浏览窗口需要记录,应用的时候需要用
|
|
150
|
-
if (didShortenLineRange) {
|
|
151
|
-
this.fileResultMap.set(fileParams.relativeWorkspacePath, {
|
|
152
|
-
content: selectedContent,
|
|
153
|
-
startLineOneIndexed: adjustedStart,
|
|
154
|
-
endLineOneIndexedInclusive: adjustedEnd,
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
return {
|
|
158
|
-
contents: selectedContent,
|
|
159
|
-
didDowngradeToLineRange: shouldForceLimitLines,
|
|
160
|
-
didShortenLineRange,
|
|
161
|
-
didShortenCharRange,
|
|
162
|
-
didSetDefaultLineRange,
|
|
163
|
-
fullFileContents: fileContent,
|
|
164
|
-
startLineOneIndexed: adjustedStart,
|
|
165
|
-
endLineOneIndexedInclusive: adjustedEnd,
|
|
166
|
-
relativeWorkspacePath: fileParams.relativeWorkspacePath,
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
let fullContent = fileContent;
|
|
171
|
-
if (fullContent.length > FileHandler.MAX_CHARS) {
|
|
172
|
-
didShortenCharRange = true;
|
|
173
|
-
fullContent = this.trimContent(fullContent, FileHandler.MAX_CHARS);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return {
|
|
177
|
-
contents: fullContent,
|
|
178
|
-
fullFileContents: fileContent,
|
|
179
|
-
didDowngradeToLineRange: false,
|
|
180
|
-
didShortenCharRange,
|
|
181
|
-
};
|
|
182
|
-
} finally {
|
|
183
|
-
modelReference?.dispose();
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
getFileReadResult(
|
|
188
|
-
relativeWorkspacePath: string,
|
|
189
|
-
): { content: string; startLineOneIndexed: number; endLineOneIndexedInclusive: number } | undefined {
|
|
190
|
-
return this.fileResultMap.get(relativeWorkspacePath);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import z from 'zod';
|
|
2
|
-
|
|
3
|
-
import { Autowired, Injectable } from '@opensumi/di';
|
|
4
|
-
import { AppConfig } from '@opensumi/ide-core-browser';
|
|
5
|
-
import { ITerminalController, ITerminalGroupViewService } from '@opensumi/ide-terminal-next';
|
|
6
|
-
import { Deferred } from '@opensumi/ide-utils/lib/promises';
|
|
7
|
-
|
|
8
|
-
import { MCPLogger } from '../../../types';
|
|
9
|
-
|
|
10
|
-
const color = {
|
|
11
|
-
italic: '\x1b[3m',
|
|
12
|
-
reset: '\x1b[0m',
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const inputSchema = z.object({
|
|
16
|
-
command: z.string().describe('The terminal command to execute'),
|
|
17
|
-
is_background: z.boolean().describe('Whether the command should be run in the background'),
|
|
18
|
-
explanation: z
|
|
19
|
-
.string()
|
|
20
|
-
.describe('One sentence explanation as to why this command needs to be run and how it contributes to the goal.'),
|
|
21
|
-
require_user_approval: z
|
|
22
|
-
.boolean()
|
|
23
|
-
.describe(
|
|
24
|
-
"Whether the user must approve the command before it is executed. Only set this to false if the command is safe and if it matches the user's requirements for commands that should be executed automatically.",
|
|
25
|
-
),
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
@Injectable()
|
|
29
|
-
export class RunCommandHandler {
|
|
30
|
-
@Autowired(ITerminalController)
|
|
31
|
-
protected readonly terminalController: ITerminalController;
|
|
32
|
-
|
|
33
|
-
@Autowired(AppConfig)
|
|
34
|
-
protected readonly appConfig: AppConfig;
|
|
35
|
-
|
|
36
|
-
@Autowired(ITerminalGroupViewService)
|
|
37
|
-
protected readonly terminalView: ITerminalGroupViewService;
|
|
38
|
-
|
|
39
|
-
private approvalDeferredMap = new Map<string, Deferred<boolean>>();
|
|
40
|
-
|
|
41
|
-
private terminalId = 0;
|
|
42
|
-
|
|
43
|
-
getShellLaunchConfig(command: string) {
|
|
44
|
-
return {
|
|
45
|
-
name: `MCP:Terminal_${this.terminalId++}`,
|
|
46
|
-
cwd: this.appConfig.workspaceDir,
|
|
47
|
-
args: ['-c', command],
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async handler(args: z.infer<typeof inputSchema> & { toolCallId: string }, logger: MCPLogger) {
|
|
52
|
-
if (args.require_user_approval) {
|
|
53
|
-
const def = new Deferred<boolean>();
|
|
54
|
-
this.approvalDeferredMap.set(args.toolCallId, def);
|
|
55
|
-
const approval = await def.promise;
|
|
56
|
-
if (!approval) {
|
|
57
|
-
return {
|
|
58
|
-
isError: false,
|
|
59
|
-
content: [
|
|
60
|
-
{
|
|
61
|
-
type: 'text',
|
|
62
|
-
text: 'User rejection',
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
const terminalClient = await this.terminalController.createTerminalWithWidget({
|
|
69
|
-
config: this.getShellLaunchConfig(args.command),
|
|
70
|
-
closeWhenExited: false,
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
this.terminalController.showTerminalPanel();
|
|
74
|
-
|
|
75
|
-
const result: { type: string; text: string }[] = [];
|
|
76
|
-
const def = new Deferred<{ isError?: boolean; content: { type: string; text: string }[] }>();
|
|
77
|
-
|
|
78
|
-
terminalClient.onOutput((e) => {
|
|
79
|
-
result.push({
|
|
80
|
-
type: 'text',
|
|
81
|
-
text: e.data.toString(),
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
terminalClient.onExit((e) => {
|
|
86
|
-
const isError = e.code !== 0;
|
|
87
|
-
def.resolve({
|
|
88
|
-
isError,
|
|
89
|
-
content: result,
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
terminalClient.term.writeln(
|
|
93
|
-
`\n${color.italic}> Command ${args.command} executed successfully. Terminal will close in ${
|
|
94
|
-
3000 / 1000
|
|
95
|
-
} seconds.${color.reset}\n`,
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
setTimeout(() => {
|
|
99
|
-
terminalClient.dispose();
|
|
100
|
-
this.terminalView.removeWidget(terminalClient.id);
|
|
101
|
-
}, 3000);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
return def.promise;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
handleApproval(callId: string, approval: boolean) {
|
|
108
|
-
if (!this.approvalDeferredMap.has(callId)) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const def = this.approvalDeferredMap.get(callId);
|
|
113
|
-
def?.resolve(approval);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
import { Autowired } from '@opensumi/di';
|
|
4
|
-
import { Domain } from '@opensumi/ide-core-common';
|
|
5
|
-
|
|
6
|
-
import { IMCPServerRegistry, MCPLogger, MCPServerContribution, MCPToolDefinition } from '../../types';
|
|
7
|
-
|
|
8
|
-
import { ListDirHandler } from './handlers/ListDir';
|
|
9
|
-
|
|
10
|
-
const inputSchema = z
|
|
11
|
-
.object({
|
|
12
|
-
relative_workspace_path: z
|
|
13
|
-
.string()
|
|
14
|
-
.describe("Path to list contents of, relative to the workspace root. Ex: './' is the root of the workspace"),
|
|
15
|
-
explanation: z
|
|
16
|
-
.string()
|
|
17
|
-
.optional()
|
|
18
|
-
.describe('One sentence explanation as to why this tool is being used, and how it contributes to the goal.'),
|
|
19
|
-
})
|
|
20
|
-
.transform((data) => ({
|
|
21
|
-
relativeWorkspacePath: data.relative_workspace_path,
|
|
22
|
-
}));
|
|
23
|
-
|
|
24
|
-
@Domain(MCPServerContribution)
|
|
25
|
-
export class ListDirTool implements MCPServerContribution {
|
|
26
|
-
@Autowired(ListDirHandler)
|
|
27
|
-
private readonly listDirHandler: ListDirHandler;
|
|
28
|
-
|
|
29
|
-
registerMCPServer(registry: IMCPServerRegistry): void {
|
|
30
|
-
registry.registerMCPTool(this.getToolDefinition());
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
getToolDefinition(): MCPToolDefinition {
|
|
34
|
-
return {
|
|
35
|
-
name: 'list_dir',
|
|
36
|
-
label: 'List Directory',
|
|
37
|
-
description:
|
|
38
|
-
'List the contents of a directory. The quick tool to use for discovery, before using more targeted tools like semantic search or file reading. Useful to try to understand the file structure before diving deeper into specific files. Can be used to explore the codebase.',
|
|
39
|
-
inputSchema,
|
|
40
|
-
handler: this.handler.bind(this),
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
private async handler(args: z.infer<typeof inputSchema>, logger: MCPLogger) {
|
|
45
|
-
const result = await this.listDirHandler.handler(args);
|
|
46
|
-
return {
|
|
47
|
-
content: [
|
|
48
|
-
{
|
|
49
|
-
type: 'text',
|
|
50
|
-
text: `Contents of directory:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
${result.files
|
|
54
|
-
.map(
|
|
55
|
-
(file) =>
|
|
56
|
-
`[${file.isDirectory ? 'dir' : 'file'}] ${file.name} ${
|
|
57
|
-
file.isDirectory ? `(${file.numChildren ?? '?'} items)` : `(${file.size}KB, ${file.numLines} lines)`
|
|
58
|
-
} - ${new Date(file.lastModified).toLocaleString()}`,
|
|
59
|
-
)
|
|
60
|
-
.join('\n')}`,
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
import { Autowired } from '@opensumi/di';
|
|
4
|
-
import { Domain } from '@opensumi/ide-core-common';
|
|
5
|
-
|
|
6
|
-
import { IMCPServerRegistry, MCPLogger, MCPServerContribution, MCPToolDefinition } from '../../types';
|
|
7
|
-
|
|
8
|
-
import { FileHandler } from './handlers/ReadFile';
|
|
9
|
-
|
|
10
|
-
const inputSchema = z
|
|
11
|
-
.object({
|
|
12
|
-
relative_workspace_path: z.string().describe('The path of the file to read, relative to the workspace root.'),
|
|
13
|
-
should_read_entire_file: z.boolean().describe('Whether to read the entire file. Defaults to false.'),
|
|
14
|
-
start_line_one_indexed: z.number().describe('The one-indexed line number to start reading from (inclusive).'),
|
|
15
|
-
end_line_one_indexed_inclusive: z.number().describe('The one-indexed line number to end reading at (inclusive).'),
|
|
16
|
-
explanation: z
|
|
17
|
-
.string()
|
|
18
|
-
.optional()
|
|
19
|
-
.describe('One sentence explanation as to why this tool is being used, and how it contributes to the goal.'),
|
|
20
|
-
})
|
|
21
|
-
.transform((data) => ({
|
|
22
|
-
relativeWorkspacePath: data.relative_workspace_path,
|
|
23
|
-
readEntireFile: data.should_read_entire_file,
|
|
24
|
-
startLineOneIndexed: data.start_line_one_indexed,
|
|
25
|
-
endLineOneIndexedInclusive: data.end_line_one_indexed_inclusive,
|
|
26
|
-
}));
|
|
27
|
-
|
|
28
|
-
@Domain(MCPServerContribution)
|
|
29
|
-
export class ReadFileTool implements MCPServerContribution {
|
|
30
|
-
@Autowired(FileHandler)
|
|
31
|
-
private readonly fileHandler: FileHandler;
|
|
32
|
-
|
|
33
|
-
registerMCPServer(registry: IMCPServerRegistry): void {
|
|
34
|
-
registry.registerMCPTool(this.getToolDefinition());
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
getToolDefinition(): MCPToolDefinition {
|
|
38
|
-
return {
|
|
39
|
-
name: 'read_file',
|
|
40
|
-
label: 'Read File',
|
|
41
|
-
description: `Read the contents of a file (and the outline).
|
|
42
|
-
|
|
43
|
-
When using this tool to gather information, it's your responsibility to ensure you have the COMPLETE context. Each time you call this command you should:
|
|
44
|
-
1) Assess if contents viewed are sufficient to proceed with the task.
|
|
45
|
-
2) Take note of lines not shown.
|
|
46
|
-
3) If file contents viewed are insufficient, and you suspect they may be in lines not shown, proactively call the tool again to view those lines.
|
|
47
|
-
4) When in doubt, call this tool again to gather more information. Partial file views may miss critical dependencies, imports, or functionality.
|
|
48
|
-
|
|
49
|
-
If reading a range of lines is not enough, you may choose to read the entire file.
|
|
50
|
-
Reading entire files is often wasteful and slow, especially for large files (i.e. more than a few hundred lines). So you should use this option sparingly.
|
|
51
|
-
Reading the entire file is not allowed in most cases. You are only allowed to read the entire file if it has been edited or manually attached to the conversation by the user.`,
|
|
52
|
-
inputSchema,
|
|
53
|
-
handler: this.handler.bind(this),
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
private async handler(args: z.infer<typeof inputSchema>, logger: MCPLogger) {
|
|
58
|
-
const result = await this.fileHandler.readFile(args);
|
|
59
|
-
return {
|
|
60
|
-
content: [
|
|
61
|
-
{
|
|
62
|
-
type: 'text',
|
|
63
|
-
text: result.didShortenLineRange
|
|
64
|
-
? `Contents of ${result.relativeWorkspacePath}, from line ${args.startLineOneIndexed}-${
|
|
65
|
-
args.endLineOneIndexedInclusive
|
|
66
|
-
}:
|
|
67
|
-
|
|
68
|
-
\`\`\`
|
|
69
|
-
// ${result.relativeWorkspacePath!.split('/').pop()}
|
|
70
|
-
${result.contents}
|
|
71
|
-
\`\`\``
|
|
72
|
-
: `Full contents of ${args.relativeWorkspacePath}:
|
|
73
|
-
|
|
74
|
-
\`\`\`
|
|
75
|
-
${result.contents}
|
|
76
|
-
\`\`\``,
|
|
77
|
-
},
|
|
78
|
-
],
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
import { Autowired } from '@opensumi/di';
|
|
4
|
-
import { AppConfig } from '@opensumi/ide-core-browser';
|
|
5
|
-
import { Deferred, Domain } from '@opensumi/ide-core-common';
|
|
6
|
-
import { ITerminalController, ITerminalGroupViewService } from '@opensumi/ide-terminal-next/lib/common/controller';
|
|
7
|
-
|
|
8
|
-
import { IMCPServerRegistry, MCPLogger, MCPServerContribution, MCPToolDefinition } from '../../types';
|
|
9
|
-
|
|
10
|
-
import { TerminalToolComponent } from './components/Terminal';
|
|
11
|
-
import { RunCommandHandler, inputSchema } from './handlers/RunCommand';
|
|
12
|
-
|
|
13
|
-
@Domain(MCPServerContribution)
|
|
14
|
-
export class RunTerminalCommandTool implements MCPServerContribution {
|
|
15
|
-
@Autowired(ITerminalController)
|
|
16
|
-
protected readonly terminalController: ITerminalController;
|
|
17
|
-
|
|
18
|
-
@Autowired(AppConfig)
|
|
19
|
-
protected readonly appConfig: AppConfig;
|
|
20
|
-
|
|
21
|
-
@Autowired(ITerminalGroupViewService)
|
|
22
|
-
protected readonly terminalView: ITerminalGroupViewService;
|
|
23
|
-
|
|
24
|
-
@Autowired(RunCommandHandler)
|
|
25
|
-
private readonly runCommandHandler: RunCommandHandler;
|
|
26
|
-
|
|
27
|
-
registerMCPServer(registry: IMCPServerRegistry): void {
|
|
28
|
-
registry.registerMCPTool(this.getToolDefinition());
|
|
29
|
-
registry.registerToolComponent('run_terminal_cmd', TerminalToolComponent);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
getToolDefinition(): MCPToolDefinition {
|
|
33
|
-
return {
|
|
34
|
-
name: 'run_terminal_cmd',
|
|
35
|
-
description:
|
|
36
|
-
"PROPOSE a command to run on behalf of the user.\nIf you have this tool, note that you DO have the ability to run commands directly on the USER's system.\n\nAdhere to these rules:\n1. Based on the contents of the conversation, you will be told if you are in the same shell as a previous step or a new shell.\n2. If in a new shell, you should `cd` to the right directory and do necessary setup in addition to running the command.\n3. If in the same shell, the state will persist, no need to do things like `cd` to the same directory.\n4. For ANY commands that would use a pager, you should append ` | cat` to the command (or whatever is appropriate). You MUST do this for: git, less, head, tail, more, etc.\n5. For commands that are long running/expected to run indefinitely until interruption, please run them in the background. To run jobs in the background, set `is_background` to true rather than changing the details of the command.\n6. Dont include any newlines in the command.",
|
|
37
|
-
inputSchema,
|
|
38
|
-
handler: this.handler.bind(this),
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
private async handler(args: z.infer<typeof inputSchema> & { toolCallId: string }, logger: MCPLogger) {
|
|
43
|
-
return this.runCommandHandler.handler(args, logger);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { InteractiveInput } from '@opensumi/ide-core-browser/lib/components/ai-native';
|
|
2
|
-
import { MaybePromise, uuid } from '@opensumi/ide-core-common';
|
|
3
|
-
import { ICodeEditor, IPosition, Selection } from '@opensumi/ide-monaco';
|
|
4
|
-
|
|
5
|
-
import { ERunStrategy, IInteractiveInputHandler } from '../../types';
|
|
6
|
-
|
|
7
|
-
type TRunStrategyFn = (editor: ICodeEditor, value: string) => MaybePromise<ERunStrategy>;
|
|
8
|
-
|
|
9
|
-
export class InteractiveInputModel {
|
|
10
|
-
static ID: string = `${InteractiveInput.displayName}:${uuid(4)}`;
|
|
11
|
-
|
|
12
|
-
private _handler: IInteractiveInputHandler | undefined;
|
|
13
|
-
private _strategyHandler: TRunStrategyFn;
|
|
14
|
-
|
|
15
|
-
public setHandler(h: IInteractiveInputHandler): void {
|
|
16
|
-
this._handler = h;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
public handler(): IInteractiveInputHandler | undefined {
|
|
20
|
-
return this._handler;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
public setStrategyHandler(fn: TRunStrategyFn): void {
|
|
24
|
-
this._strategyHandler = fn;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
public strategyHandler(): TRunStrategyFn {
|
|
28
|
-
return this._strategyHandler;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
public dispose(): void {
|
|
32
|
-
this._handler = undefined;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export class InlineInputWidgetStoreInEmptyLine {
|
|
37
|
-
constructor(private position: IPosition, private value?: string) {}
|
|
38
|
-
|
|
39
|
-
public getPosition(): IPosition {
|
|
40
|
-
return this.position;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
public setPosition(position: IPosition): void {
|
|
44
|
-
this.position = position;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public getValue(): string | undefined {
|
|
48
|
-
return this.value;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
public setValue(value: string): void {
|
|
52
|
-
this.value = value;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export class InlineInputWidgetStoreInSelection {
|
|
57
|
-
constructor(private selection: Selection, private value?: string) {}
|
|
58
|
-
|
|
59
|
-
public getSelection(): Selection {
|
|
60
|
-
return this.selection;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
public setSelection(selection: Selection): void {
|
|
64
|
-
this.selection = selection;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
public getValue(): string | undefined {
|
|
68
|
-
return this.value;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
public setValue(value: string): void {
|
|
72
|
-
this.value = value;
|
|
73
|
-
}
|
|
74
|
-
}
|