@opensumi/ide-ai-native 3.8.1-next-1741228774.0 → 3.8.1-next-1741250387.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 +1 -1
- package/lib/browser/ai-core.contextkeys.d.ts.map +1 -1
- package/lib/browser/ai-core.contextkeys.js +1 -1
- package/lib/browser/ai-core.contextkeys.js.map +1 -1
- package/lib/browser/ai-core.contribution.d.ts +0 -5
- package/lib/browser/ai-core.contribution.d.ts.map +1 -1
- package/lib/browser/ai-core.contribution.js +9 -71
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/chat/chat-agent.service.d.ts +3 -11
- package/lib/browser/chat/chat-agent.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-agent.service.js +5 -43
- package/lib/browser/chat/chat-agent.service.js.map +1 -1
- package/lib/browser/chat/chat-manager.service.d.ts +0 -1
- package/lib/browser/chat/chat-manager.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-manager.service.js +8 -6
- package/lib/browser/chat/chat-manager.service.js.map +1 -1
- package/lib/browser/chat/chat-model.d.ts +1 -4
- package/lib/browser/chat/chat-model.d.ts.map +1 -1
- package/lib/browser/chat/chat-model.js +2 -57
- package/lib/browser/chat/chat-model.js.map +1 -1
- package/lib/browser/chat/chat-proxy.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-proxy.service.js +6 -13
- package/lib/browser/chat/chat-proxy.service.js.map +1 -1
- package/lib/browser/chat/chat.api.service.d.ts +2 -1
- package/lib/browser/chat/chat.api.service.d.ts.map +1 -1
- package/lib/browser/chat/chat.api.service.js +4 -0
- package/lib/browser/chat/chat.api.service.js.map +1 -1
- package/lib/browser/chat/chat.internal.service.d.ts +0 -2
- package/lib/browser/chat/chat.internal.service.d.ts.map +1 -1
- package/lib/browser/chat/chat.internal.service.js +0 -3
- package/lib/browser/chat/chat.internal.service.js.map +1 -1
- package/lib/browser/chat/chat.module.less +2 -1
- package/lib/browser/chat/chat.view.d.ts.map +1 -1
- package/lib/browser/chat/chat.view.js +29 -46
- package/lib/browser/chat/chat.view.js.map +1 -1
- package/lib/browser/components/ChatContext/index.js +2 -2
- package/lib/browser/components/ChatContext/index.js.map +1 -1
- package/lib/browser/components/ChatInput.d.ts.map +1 -1
- package/lib/browser/components/ChatInput.js +1 -29
- package/lib/browser/components/ChatInput.js.map +1 -1
- package/lib/browser/components/ChatReply.js +1 -6
- package/lib/browser/components/ChatReply.js.map +1 -1
- package/lib/browser/components/ChatThinking.d.ts +2 -0
- package/lib/browser/components/ChatThinking.d.ts.map +1 -1
- package/lib/browser/components/ChatThinking.js +10 -2
- package/lib/browser/components/ChatThinking.js.map +1 -1
- package/lib/browser/components/ChatToolRender.d.ts.map +1 -1
- package/lib/browser/components/ChatToolRender.js +3 -2
- package/lib/browser/components/ChatToolRender.js.map +1 -1
- package/lib/browser/components/WelcomeMsg.js +1 -1
- package/lib/browser/components/WelcomeMsg.js.map +1 -1
- package/lib/browser/components/chat-history.module.less +1 -2
- package/lib/browser/components/components.module.less +0 -22
- package/lib/browser/context/llm-context.service.d.ts +5 -18
- package/lib/browser/context/llm-context.service.d.ts.map +1 -1
- package/lib/browser/context/llm-context.service.js +47 -81
- package/lib/browser/context/llm-context.service.js.map +1 -1
- package/lib/browser/contrib/inline-completions/inline-completions.controller.js +1 -1
- package/lib/browser/contrib/inline-completions/inline-completions.controller.js.map +1 -1
- package/lib/browser/contrib/inline-completions/prompt/matcher.js +2 -2
- package/lib/browser/contrib/inline-completions/prompt/similarSnippets.d.ts +1 -1
- package/lib/browser/contrib/inline-completions/prompt/similarSnippets.js +2 -2
- package/lib/browser/contrib/intelligent-completions/index.d.ts +1 -2
- package/lib/browser/contrib/intelligent-completions/index.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/index.js +1 -4
- package/lib/browser/contrib/intelligent-completions/index.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.js +2 -2
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.js +5 -6
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/view/code-edits-previewer.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/view/code-edits-previewer.js +2 -4
- package/lib/browser/contrib/intelligent-completions/view/code-edits-previewer.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/view/default.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/view/default.js +11 -23
- package/lib/browser/contrib/intelligent-completions/view/default.js.map +1 -1
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +0 -4
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/layout/layout.module.less +4 -4
- package/lib/browser/mcp/base-apply.service.d.ts +11 -26
- package/lib/browser/mcp/base-apply.service.d.ts.map +1 -1
- package/lib/browser/mcp/base-apply.service.js +103 -255
- package/lib/browser/mcp/base-apply.service.js.map +1 -1
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts +0 -6
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts.map +1 -1
- package/lib/browser/mcp/mcp-server-proxy.service.js +1 -10
- package/lib/browser/mcp/mcp-server-proxy.service.js.map +1 -1
- package/lib/browser/mcp/mcp-server.feature.registry.d.ts +0 -8
- package/lib/browser/mcp/mcp-server.feature.registry.d.ts.map +1 -1
- package/lib/browser/mcp/mcp-server.feature.registry.js +3 -28
- package/lib/browser/mcp/mcp-server.feature.registry.js.map +1 -1
- package/lib/browser/mcp/tools/components/EditFile.d.ts.map +1 -1
- package/lib/browser/mcp/tools/components/EditFile.js +9 -15
- package/lib/browser/mcp/tools/components/EditFile.js.map +1 -1
- package/lib/browser/mcp/tools/components/SearchResult.d.ts +11 -0
- package/lib/browser/mcp/tools/components/SearchResult.d.ts.map +1 -0
- package/lib/browser/mcp/tools/components/{ExpandableFileList.js → SearchResult.js} +19 -29
- package/lib/browser/mcp/tools/components/SearchResult.js.map +1 -0
- package/lib/browser/mcp/tools/components/Terminal.d.ts.map +1 -1
- package/lib/browser/mcp/tools/components/Terminal.js +2 -10
- package/lib/browser/mcp/tools/components/Terminal.js.map +1 -1
- package/lib/browser/mcp/tools/components/index.module.less +0 -4
- package/lib/browser/mcp/tools/createNewFileWithText.d.ts +0 -1
- package/lib/browser/mcp/tools/createNewFileWithText.d.ts.map +1 -1
- package/lib/browser/mcp/tools/createNewFileWithText.js +11 -19
- package/lib/browser/mcp/tools/createNewFileWithText.js.map +1 -1
- package/lib/browser/mcp/tools/fileSearch.d.ts +0 -1
- package/lib/browser/mcp/tools/fileSearch.d.ts.map +1 -1
- package/lib/browser/mcp/tools/fileSearch.js +5 -14
- package/lib/browser/mcp/tools/fileSearch.js.map +1 -1
- package/lib/browser/mcp/tools/getDiagnosticsByPath.d.ts.map +1 -1
- package/lib/browser/mcp/tools/getDiagnosticsByPath.js +0 -1
- package/lib/browser/mcp/tools/getDiagnosticsByPath.js.map +1 -1
- package/lib/browser/mcp/tools/grepSearch.d.ts.map +1 -1
- package/lib/browser/mcp/tools/grepSearch.js +3 -6
- package/lib/browser/mcp/tools/grepSearch.js.map +1 -1
- package/lib/browser/mcp/tools/handlers/EditFile.js +1 -1
- package/lib/browser/mcp/tools/handlers/EditFile.js.map +1 -1
- package/lib/browser/mcp/tools/handlers/ListDir.d.ts +0 -1
- package/lib/browser/mcp/tools/handlers/ListDir.d.ts.map +1 -1
- package/lib/browser/mcp/tools/handlers/ListDir.js +0 -3
- package/lib/browser/mcp/tools/handlers/ListDir.js.map +1 -1
- package/lib/browser/mcp/tools/handlers/RunCommand.d.ts.map +1 -1
- package/lib/browser/mcp/tools/handlers/RunCommand.js +0 -2
- package/lib/browser/mcp/tools/handlers/RunCommand.js.map +1 -1
- package/lib/browser/mcp/tools/listDir.d.ts +0 -1
- package/lib/browser/mcp/tools/listDir.d.ts.map +1 -1
- package/lib/browser/mcp/tools/listDir.js +4 -35
- package/lib/browser/mcp/tools/listDir.js.map +1 -1
- package/lib/browser/mcp/tools/runTerminalCmd.d.ts.map +1 -1
- package/lib/browser/mcp/tools/runTerminalCmd.js +0 -1
- package/lib/browser/mcp/tools/runTerminalCmd.js.map +1 -1
- package/lib/browser/model/msg-history-manager.d.ts +2 -2
- package/lib/browser/model/msg-history-manager.d.ts.map +1 -1
- package/lib/browser/model/msg-history-manager.js +10 -4
- package/lib/browser/model/msg-history-manager.js.map +1 -1
- package/lib/browser/preferences/schema.d.ts.map +1 -1
- package/lib/browser/preferences/schema.js +2 -22
- package/lib/browser/preferences/schema.js.map +1 -1
- package/lib/browser/types.d.ts +0 -4
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat-controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat-controller.js +1 -6
- package/lib/browser/widget/inline-chat/inline-chat-controller.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-manager.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-manager.js +8 -68
- package/lib/browser/widget/inline-diff/inline-diff-manager.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-previewer.d.ts +4 -10
- package/lib/browser/widget/inline-diff/inline-diff-previewer.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-previewer.js +3 -14
- package/lib/browser/widget/inline-diff/inline-diff-previewer.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-widget.module.less +4 -25
- package/lib/browser/widget/inline-diff/inline-diff.controller.d.ts +3 -3
- package/lib/browser/widget/inline-diff/inline-diff.controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff.controller.js +5 -10
- package/lib/browser/widget/inline-diff/inline-diff.controller.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.d.ts +17 -46
- 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 +53 -110
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.d.ts +0 -4
- 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 +1 -26
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.js.map +1 -1
- package/lib/common/index.d.ts +4 -13
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +1 -5
- package/lib/common/index.js.map +1 -1
- package/lib/common/llm-context.d.ts +9 -13
- package/lib/common/llm-context.d.ts.map +1 -1
- package/lib/common/llm-context.js.map +1 -1
- package/lib/common/mcp-server-manager.d.ts +1 -17
- package/lib/common/mcp-server-manager.d.ts.map +1 -1
- package/lib/common/mcp-server-manager.js.map +1 -1
- package/lib/common/prompts/context-prompt-provider.d.ts +3 -4
- package/lib/common/prompts/context-prompt-provider.d.ts.map +1 -1
- package/lib/common/prompts/context-prompt-provider.js +22 -33
- package/lib/common/prompts/context-prompt-provider.js.map +1 -1
- package/lib/common/tool-invocation-registry.d.ts +2 -2
- package/lib/common/tool-invocation-registry.d.ts.map +1 -1
- package/lib/common/tool-invocation-registry.js +1 -1
- package/lib/common/tool-invocation-registry.js.map +1 -1
- package/lib/common/types.d.ts +0 -8
- package/lib/common/types.d.ts.map +1 -1
- package/lib/common/utils.d.ts.map +1 -1
- package/lib/common/utils.js +1 -2
- package/lib/common/utils.js.map +1 -1
- package/lib/node/anthropic/anthropic-language-model.d.ts +1 -3
- package/lib/node/anthropic/anthropic-language-model.d.ts.map +1 -1
- package/lib/node/anthropic/anthropic-language-model.js +2 -6
- package/lib/node/anthropic/anthropic-language-model.js.map +1 -1
- package/lib/node/base-language-model.d.ts +3 -6
- package/lib/node/base-language-model.d.ts.map +1 -1
- package/lib/node/base-language-model.js +31 -14
- package/lib/node/base-language-model.js.map +1 -1
- package/lib/node/deepseek/deepseek-language-model.d.ts +1 -3
- package/lib/node/deepseek/deepseek-language-model.d.ts.map +1 -1
- package/lib/node/deepseek/deepseek-language-model.js +2 -6
- package/lib/node/deepseek/deepseek-language-model.js.map +1 -1
- package/lib/node/mcp/sumi-mcp-server.d.ts +3 -17
- package/lib/node/mcp/sumi-mcp-server.d.ts.map +1 -1
- package/lib/node/mcp/sumi-mcp-server.js +6 -59
- package/lib/node/mcp/sumi-mcp-server.js.map +1 -1
- package/lib/node/mcp-server-manager-impl.d.ts +3 -4
- package/lib/node/mcp-server-manager-impl.d.ts.map +1 -1
- package/lib/node/mcp-server-manager-impl.js +6 -26
- package/lib/node/mcp-server-manager-impl.js.map +1 -1
- package/lib/node/mcp-server.d.ts +16 -5
- package/lib/node/mcp-server.d.ts.map +1 -1
- package/lib/node/mcp-server.js +6 -12
- package/lib/node/mcp-server.js.map +1 -1
- package/lib/node/openai/openai-language-model.d.ts +2 -4
- package/lib/node/openai/openai-language-model.d.ts.map +1 -1
- package/lib/node/openai/openai-language-model.js +4 -6
- package/lib/node/openai/openai-language-model.js.map +1 -1
- package/package.json +26 -27
- package/src/browser/ai-core.contextkeys.ts +3 -3
- package/src/browser/ai-core.contribution.ts +12 -89
- package/src/browser/chat/chat-agent.service.ts +9 -53
- package/src/browser/chat/chat-manager.service.ts +8 -10
- package/src/browser/chat/chat-model.ts +5 -63
- package/src/browser/chat/chat-proxy.service.ts +8 -16
- package/src/browser/chat/chat.api.service.ts +5 -1
- package/src/browser/chat/chat.internal.service.ts +0 -4
- package/src/browser/chat/chat.module.less +2 -1
- package/src/browser/chat/chat.view.tsx +69 -63
- package/src/browser/components/ChatContext/index.tsx +2 -2
- package/src/browser/components/ChatInput.tsx +6 -81
- package/src/browser/components/ChatReply.tsx +6 -6
- package/src/browser/components/ChatThinking.tsx +9 -3
- package/src/browser/components/ChatToolRender.tsx +2 -1
- package/src/browser/components/WelcomeMsg.tsx +1 -1
- package/src/browser/components/chat-history.module.less +1 -2
- package/src/browser/components/components.module.less +0 -22
- package/src/browser/context/llm-context.service.ts +54 -100
- package/src/browser/contrib/inline-completions/inline-completions.controller.ts +1 -1
- package/src/browser/contrib/inline-completions/prompt/matcher.ts +2 -2
- package/src/browser/contrib/inline-completions/prompt/similarSnippets.ts +2 -2
- package/src/browser/contrib/intelligent-completions/index.ts +1 -5
- package/src/browser/contrib/intelligent-completions/intelligent-completions.contribution.ts +3 -3
- package/src/browser/contrib/intelligent-completions/intelligent-completions.controller.ts +6 -7
- package/src/browser/contrib/intelligent-completions/view/code-edits-previewer.ts +2 -4
- package/src/browser/contrib/intelligent-completions/view/default.ts +19 -34
- package/src/browser/index.ts +0 -4
- package/src/browser/layout/layout.module.less +4 -4
- package/src/browser/mcp/base-apply.service.ts +109 -306
- package/src/browser/mcp/mcp-server-proxy.service.ts +2 -14
- package/src/browser/mcp/mcp-server.feature.registry.ts +4 -35
- package/src/browser/mcp/tools/components/EditFile.tsx +9 -16
- package/src/browser/mcp/tools/components/SearchResult.tsx +92 -0
- package/src/browser/mcp/tools/components/Terminal.tsx +2 -13
- package/src/browser/mcp/tools/components/index.module.less +0 -4
- package/src/browser/mcp/tools/createNewFileWithText.ts +12 -21
- package/src/browser/mcp/tools/fileSearch.ts +4 -14
- package/src/browser/mcp/tools/getDiagnosticsByPath.ts +0 -1
- package/src/browser/mcp/tools/grepSearch.ts +3 -6
- package/src/browser/mcp/tools/handlers/EditFile.ts +1 -1
- package/src/browser/mcp/tools/handlers/ListDir.ts +0 -4
- package/src/browser/mcp/tools/handlers/RunCommand.ts +0 -2
- package/src/browser/mcp/tools/listDir.ts +5 -36
- package/src/browser/mcp/tools/runTerminalCmd.ts +0 -1
- package/src/browser/model/msg-history-manager.ts +11 -5
- package/src/browser/preferences/schema.ts +2 -22
- package/src/browser/types.ts +0 -1
- package/src/browser/widget/inline-chat/inline-chat-controller.ts +1 -5
- package/src/browser/widget/inline-diff/inline-diff-manager.tsx +21 -143
- package/src/browser/widget/inline-diff/inline-diff-previewer.ts +7 -25
- package/src/browser/widget/inline-diff/inline-diff-widget.module.less +4 -25
- package/src/browser/widget/inline-diff/inline-diff.controller.ts +8 -16
- package/src/browser/widget/inline-stream-diff/inline-stream-diff.handler.tsx +68 -139
- package/src/browser/widget/inline-stream-diff/live-preview.decoration.tsx +1 -30
- package/src/common/index.ts +4 -15
- package/src/common/llm-context.ts +4 -10
- package/src/common/mcp-server-manager.ts +1 -17
- package/src/common/prompts/context-prompt-provider.ts +29 -38
- package/src/common/tool-invocation-registry.ts +2 -2
- package/src/common/types.ts +0 -8
- package/src/common/utils.ts +1 -3
- package/src/node/anthropic/anthropic-language-model.ts +2 -7
- package/src/node/base-language-model.ts +38 -25
- package/src/node/deepseek/deepseek-language-model.ts +2 -7
- package/src/node/mcp/sumi-mcp-server.ts +9 -67
- package/src/node/mcp-server-manager-impl.ts +9 -30
- package/src/node/mcp-server.ts +14 -11
- package/src/node/openai/openai-language-model.ts +4 -8
- package/lib/browser/mcp/config/components/mcp-config.module.less +0 -178
- package/lib/browser/mcp/config/components/mcp-config.view.d.ts +0 -3
- package/lib/browser/mcp/config/components/mcp-config.view.d.ts.map +0 -1
- package/lib/browser/mcp/config/components/mcp-config.view.js +0 -150
- package/lib/browser/mcp/config/components/mcp-config.view.js.map +0 -1
- package/lib/browser/mcp/config/components/mcp-server-form.d.ts +0 -16
- package/lib/browser/mcp/config/components/mcp-server-form.d.ts.map +0 -1
- package/lib/browser/mcp/config/components/mcp-server-form.js +0 -84
- package/lib/browser/mcp/config/components/mcp-server-form.js.map +0 -1
- package/lib/browser/mcp/config/components/mcp-server-form.module.less +0 -78
- package/lib/browser/mcp/config/mcp-config.commands.d.ts +0 -10
- package/lib/browser/mcp/config/mcp-config.commands.d.ts.map +0 -1
- package/lib/browser/mcp/config/mcp-config.commands.js +0 -35
- package/lib/browser/mcp/config/mcp-config.commands.js.map +0 -1
- package/lib/browser/mcp/config/mcp-config.contribution.d.ts +0 -16
- package/lib/browser/mcp/config/mcp-config.contribution.d.ts.map +0 -1
- package/lib/browser/mcp/config/mcp-config.contribution.js +0 -62
- package/lib/browser/mcp/config/mcp-config.contribution.js.map +0 -1
- package/lib/browser/mcp/tools/components/ExpandableFileList.d.ts +0 -13
- package/lib/browser/mcp/tools/components/ExpandableFileList.d.ts.map +0 -1
- package/lib/browser/mcp/tools/components/ExpandableFileList.js.map +0 -1
- package/lib/common/model.d.ts +0 -12
- package/lib/common/model.d.ts.map +0 -1
- package/lib/common/model.js +0 -83
- package/lib/common/model.js.map +0 -1
- package/lib/node/openai-compatible/openai-compatible-language-model.d.ts +0 -10
- package/lib/node/openai-compatible/openai-compatible-language-model.d.ts.map +0 -1
- package/lib/node/openai-compatible/openai-compatible-language-model.js +0 -32
- package/lib/node/openai-compatible/openai-compatible-language-model.js.map +0 -1
- package/src/browser/mcp/config/components/mcp-config.module.less +0 -178
- package/src/browser/mcp/config/components/mcp-config.view.tsx +0 -215
- package/src/browser/mcp/config/components/mcp-server-form.module.less +0 -78
- package/src/browser/mcp/config/components/mcp-server-form.tsx +0 -144
- package/src/browser/mcp/config/mcp-config.commands.ts +0 -29
- package/src/browser/mcp/config/mcp-config.contribution.ts +0 -65
- package/src/browser/mcp/tools/components/ExpandableFileList.tsx +0 -133
- package/src/common/model.ts +0 -90
- package/src/node/openai-compatible/openai-compatible-language-model.ts +0 -30
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
padding: 8px 12px;
|
|
15
15
|
min-width: initial;
|
|
16
16
|
margin: 0;
|
|
17
|
+
|
|
18
|
+
::after {
|
|
19
|
+
content: '';
|
|
20
|
+
}
|
|
17
21
|
}
|
|
18
22
|
|
|
19
23
|
.rce-mbox-text {
|
|
20
24
|
line-height: 18px;
|
|
21
25
|
width: inherit;
|
|
22
26
|
font-size: 12px;
|
|
23
|
-
|
|
24
|
-
&::after {
|
|
25
|
-
display: none;
|
|
26
|
-
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
.rce-smsg {
|
|
@@ -1,30 +1,17 @@
|
|
|
1
1
|
import { createPatch } from 'diff';
|
|
2
2
|
|
|
3
3
|
import { Autowired } from '@opensumi/di';
|
|
4
|
-
import {
|
|
5
|
-
AIServiceType,
|
|
6
|
-
ActionSourceEnum,
|
|
7
|
-
ActionTypeEnum,
|
|
8
|
-
AppConfig,
|
|
9
|
-
IAIReporter,
|
|
10
|
-
IChatProgress,
|
|
11
|
-
IMarker,
|
|
12
|
-
MarkerSeverity,
|
|
13
|
-
OnEvent,
|
|
14
|
-
WithEventBus,
|
|
15
|
-
} from '@opensumi/ide-core-browser';
|
|
4
|
+
import { AppConfig, IChatProgress, IMarker, MarkerSeverity, OnEvent, WithEventBus } from '@opensumi/ide-core-browser';
|
|
16
5
|
import { WorkbenchEditorService } from '@opensumi/ide-editor';
|
|
17
6
|
import {
|
|
18
7
|
EditorGroupCloseEvent,
|
|
19
8
|
EditorGroupOpenEvent,
|
|
20
|
-
IEditorDocumentModelService,
|
|
21
9
|
RegisterEditorSideComponentEvent,
|
|
22
10
|
} from '@opensumi/ide-editor/lib/browser';
|
|
23
11
|
import { IMarkerService } from '@opensumi/ide-markers';
|
|
24
|
-
import { ICodeEditor,
|
|
25
|
-
import { Deferred,
|
|
12
|
+
import { ICodeEditor, Position, Range, Selection, SelectionDirection } from '@opensumi/ide-monaco';
|
|
13
|
+
import { Deferred, Emitter, URI, path } from '@opensumi/ide-utils';
|
|
26
14
|
import { SumiReadableStream } from '@opensumi/ide-utils/lib/stream';
|
|
27
|
-
import { EditOperation } from '@opensumi/monaco-editor-core/esm/vs/editor/common/core/editOperation';
|
|
28
15
|
|
|
29
16
|
import { IChatInternalService } from '../../common';
|
|
30
17
|
import { CodeBlockData, CodeBlockStatus } from '../../common/types';
|
|
@@ -36,9 +23,15 @@ import {
|
|
|
36
23
|
InlineDiffService,
|
|
37
24
|
LiveInlineDiffPreviewer,
|
|
38
25
|
} from '../widget/inline-diff';
|
|
39
|
-
import {
|
|
26
|
+
import { InlineStreamDiffHandler } from '../widget/inline-stream-diff/inline-stream-diff.handler';
|
|
27
|
+
|
|
28
|
+
import { FileHandler } from './tools/handlers/ReadFile';
|
|
40
29
|
|
|
30
|
+
// 提供代码块的唯一索引,迭代轮次,生成状态管理(包括取消),关联文件位置这些信息的记录,后续并行 apply 的支持
|
|
41
31
|
export abstract class BaseApplyService extends WithEventBus {
|
|
32
|
+
@Autowired(FileHandler)
|
|
33
|
+
protected fileHandler: FileHandler;
|
|
34
|
+
|
|
42
35
|
@Autowired(IChatInternalService)
|
|
43
36
|
protected chatInternalService: ChatInternalService;
|
|
44
37
|
|
|
@@ -54,41 +47,14 @@ export abstract class BaseApplyService extends WithEventBus {
|
|
|
54
47
|
@Autowired(IMarkerService)
|
|
55
48
|
private readonly markerService: IMarkerService;
|
|
56
49
|
|
|
57
|
-
@Autowired(IEditorDocumentModelService)
|
|
58
|
-
private readonly editorDocumentModelService: IEditorDocumentModelService;
|
|
59
|
-
|
|
60
|
-
@Autowired(IAIReporter)
|
|
61
|
-
private readonly aiReporter: IAIReporter;
|
|
62
|
-
|
|
63
50
|
private onCodeBlockUpdateEmitter = new Emitter<CodeBlockData>();
|
|
64
51
|
public onCodeBlockUpdate = this.onCodeBlockUpdateEmitter.event;
|
|
65
52
|
|
|
66
|
-
private currentSessionId?: string;
|
|
67
|
-
|
|
68
53
|
constructor() {
|
|
69
54
|
super();
|
|
70
55
|
this.addDispose(
|
|
71
56
|
this.chatInternalService.onCancelRequest(() => {
|
|
72
|
-
|
|
73
|
-
if (!currentMessageId) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
const codeBlockMap = this.getMessageCodeBlocks(currentMessageId);
|
|
77
|
-
if (!codeBlockMap) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
Object.values(codeBlockMap).forEach((blockData) => {
|
|
81
|
-
this.cancelApply(blockData);
|
|
82
|
-
});
|
|
83
|
-
}),
|
|
84
|
-
);
|
|
85
|
-
this.currentSessionId = this.chatInternalService.sessionModel.sessionId;
|
|
86
|
-
this.addDispose(
|
|
87
|
-
this.chatInternalService.onChangeSession((sessionId) => {
|
|
88
|
-
if (sessionId !== this.currentSessionId) {
|
|
89
|
-
this.cancelAllApply();
|
|
90
|
-
this.currentSessionId = sessionId;
|
|
91
|
-
}
|
|
57
|
+
this.cancelAllApply();
|
|
92
58
|
}),
|
|
93
59
|
);
|
|
94
60
|
this.addDispose(
|
|
@@ -104,11 +70,6 @@ export abstract class BaseApplyService extends WithEventBus {
|
|
|
104
70
|
});
|
|
105
71
|
}),
|
|
106
72
|
);
|
|
107
|
-
this.addDispose(
|
|
108
|
-
this.chatInternalService.onWillClearSession((sessionId) => {
|
|
109
|
-
this.cancelAllApply(sessionId);
|
|
110
|
-
}),
|
|
111
|
-
);
|
|
112
73
|
}
|
|
113
74
|
|
|
114
75
|
private getMessageCodeBlocks(
|
|
@@ -124,80 +85,46 @@ export abstract class BaseApplyService extends WithEventBus {
|
|
|
124
85
|
return message?.codeBlockMap;
|
|
125
86
|
}
|
|
126
87
|
|
|
127
|
-
private
|
|
128
|
-
new DisposableMap<string, BaseInlineDiffPreviewer<BaseInlineStreamDiffHandler>>(),
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
private editorListenerMap = this.registerDispose(new DisposableMap<string, IDisposable>());
|
|
88
|
+
private activePreviewer: BaseInlineDiffPreviewer<InlineStreamDiffHandler> | undefined;
|
|
132
89
|
|
|
133
90
|
@OnEvent(EditorGroupCloseEvent)
|
|
134
91
|
onEditorGroupClose(event: EditorGroupCloseEvent) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
this.activePreviewerMap.disposeKey(relativePath);
|
|
92
|
+
if (this.activePreviewer?.getNode()?.uri.path.toString() === event.payload.resource.uri.path.toString()) {
|
|
93
|
+
this.activePreviewer.dispose();
|
|
94
|
+
this.activePreviewer = undefined;
|
|
139
95
|
}
|
|
140
|
-
this.editorListenerMap.disposeKey(event.payload.resource.uri.toString());
|
|
141
96
|
}
|
|
142
97
|
|
|
143
98
|
@OnEvent(EditorGroupOpenEvent)
|
|
144
99
|
async onEditorGroupOpen(event: EditorGroupOpenEvent) {
|
|
145
|
-
|
|
146
|
-
if (
|
|
147
|
-
this.duringApply ||
|
|
148
|
-
this.activePreviewerMap.has(relativePath) ||
|
|
149
|
-
!this.chatInternalService.sessionModel.history.getMessages().length
|
|
150
|
-
) {
|
|
100
|
+
if (!this.chatInternalService.sessionModel.history.getMessages().length) {
|
|
151
101
|
return;
|
|
152
102
|
}
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
103
|
+
const relativePath = path.relative(this.appConfig.workspaceDir, event.payload.resource.uri.path.toString());
|
|
104
|
+
const filePendingApplies = Object.values(
|
|
105
|
+
this.getMessageCodeBlocks(this.chatInternalService.sessionModel.history.lastMessageId!) || {},
|
|
106
|
+
).filter((block) => block.relativePath === relativePath && block.status === 'pending');
|
|
107
|
+
// TODO: 刷新后重新应用,事件无法恢复 & 恢复继续请求,需要改造成批量apply形式
|
|
108
|
+
// TODO: 暂时只支持 pending 串行的 apply,后续支持批量apply后统一accept
|
|
109
|
+
if (filePendingApplies.length > 0) {
|
|
110
|
+
this.renderApplyResult(filePendingApplies[0], filePendingApplies[0].updatedCode!);
|
|
159
111
|
}
|
|
160
112
|
}
|
|
161
113
|
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
if (!
|
|
114
|
+
getUriPendingCodeBlock(uri: URI): CodeBlockData | undefined {
|
|
115
|
+
const messageId = this.chatInternalService.sessionModel.history.lastMessageId;
|
|
116
|
+
if (!messageId) {
|
|
165
117
|
return undefined;
|
|
166
118
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* 获取指定uri的 code block,按version降序排序
|
|
172
|
-
*/
|
|
173
|
-
getUriCodeBlocks(uri: URI): CodeBlockData[] | undefined {
|
|
174
|
-
const sessionCodeBlocks = this.getSessionCodeBlocks();
|
|
175
|
-
const relativePath = path.relative(this.appConfig.workspaceDir, uri.path.toString());
|
|
176
|
-
return sessionCodeBlocks
|
|
177
|
-
.filter((block) => block.relativePath === relativePath)
|
|
178
|
-
.sort((a, b) => b.version - a.version);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
getPendingPaths(sessionId?: string): string[] {
|
|
182
|
-
const sessionCodeBlocks = this.getSessionCodeBlocks(sessionId);
|
|
183
|
-
return sessionCodeBlocks.filter((block) => block.status === 'pending').map((block) => block.relativePath);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
protected getSessionCodeBlocks(sessionId?: string) {
|
|
187
|
-
sessionId = sessionId || this.chatInternalService.sessionModel.sessionId;
|
|
188
|
-
const sessionModel = this.chatInternalService.getSession(sessionId);
|
|
189
|
-
if (!sessionModel) {
|
|
190
|
-
throw new Error(`Session ${sessionId} not found`);
|
|
119
|
+
const codeBlockMap = this.getMessageCodeBlocks(messageId);
|
|
120
|
+
if (!codeBlockMap) {
|
|
121
|
+
return undefined;
|
|
191
122
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
acc.push(block);
|
|
198
|
-
});
|
|
199
|
-
return acc;
|
|
200
|
-
}, [] as CodeBlockData[]);
|
|
123
|
+
return Object.values(codeBlockMap).find(
|
|
124
|
+
(block) =>
|
|
125
|
+
block.relativePath === path.relative(this.appConfig.workspaceDir, uri.path.toString()) &&
|
|
126
|
+
block.status === 'pending',
|
|
127
|
+
);
|
|
201
128
|
}
|
|
202
129
|
|
|
203
130
|
getCodeBlock(toolCallId: string, messageId?: string): CodeBlockData | undefined {
|
|
@@ -212,8 +139,11 @@ export abstract class BaseApplyService extends WithEventBus {
|
|
|
212
139
|
return codeBlockMap[toolCallId];
|
|
213
140
|
}
|
|
214
141
|
|
|
215
|
-
protected updateCodeBlock(codeBlock: CodeBlockData) {
|
|
216
|
-
|
|
142
|
+
protected updateCodeBlock(codeBlock: CodeBlockData, messageId?: string) {
|
|
143
|
+
messageId = messageId || this.chatInternalService.sessionModel.history.lastMessageId;
|
|
144
|
+
if (!messageId) {
|
|
145
|
+
throw new Error('Message ID is required');
|
|
146
|
+
}
|
|
217
147
|
const codeBlockMap = this.getMessageCodeBlocks(messageId);
|
|
218
148
|
if (!codeBlockMap) {
|
|
219
149
|
throw new Error('Code block not found');
|
|
@@ -225,12 +155,9 @@ export abstract class BaseApplyService extends WithEventBus {
|
|
|
225
155
|
this.onCodeBlockUpdateEmitter.fire(codeBlock);
|
|
226
156
|
}
|
|
227
157
|
|
|
228
|
-
|
|
158
|
+
registerCodeBlock(relativePath: string, content: string, toolCallId: string): CodeBlockData {
|
|
229
159
|
const lastMessageId = this.chatInternalService.sessionModel.history.lastMessageId!;
|
|
230
|
-
const
|
|
231
|
-
const originalModelRef = await this.editorDocumentModelService.createModelReference(
|
|
232
|
-
URI.file(path.join(this.appConfig.workspaceDir, relativePath)),
|
|
233
|
-
);
|
|
160
|
+
const savedCodeBlockMap = this.getMessageCodeBlocks(lastMessageId) || {};
|
|
234
161
|
const newBlock: CodeBlockData = {
|
|
235
162
|
codeEdit: content,
|
|
236
163
|
relativePath,
|
|
@@ -239,13 +166,11 @@ export abstract class BaseApplyService extends WithEventBus {
|
|
|
239
166
|
version: 1,
|
|
240
167
|
createdAt: Date.now(),
|
|
241
168
|
toolCallId,
|
|
242
|
-
messageId: lastMessageId,
|
|
243
|
-
// TODO: 支持range
|
|
244
|
-
originalCode: originalModelRef.instance.getText(),
|
|
245
169
|
};
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
170
|
+
const samePathCodeBlocks = Object.values(savedCodeBlockMap).filter((block) => block.relativePath === relativePath);
|
|
171
|
+
if (samePathCodeBlocks.length > 0) {
|
|
172
|
+
newBlock.version = samePathCodeBlocks.length;
|
|
173
|
+
for (const block of samePathCodeBlocks.sort((a, b) => b.version - a.version)) {
|
|
249
174
|
// 如果连续的上一个同文件apply结果存在LintError,则iterationCount++
|
|
250
175
|
if (block.relativePath === relativePath && block.applyResult?.diagnosticInfos?.length) {
|
|
251
176
|
newBlock.iterationCount++;
|
|
@@ -254,7 +179,6 @@ export abstract class BaseApplyService extends WithEventBus {
|
|
|
254
179
|
}
|
|
255
180
|
}
|
|
256
181
|
}
|
|
257
|
-
const savedCodeBlockMap = this.getMessageCodeBlocks(lastMessageId) || {};
|
|
258
182
|
savedCodeBlockMap[toolCallId] = newBlock;
|
|
259
183
|
this.chatInternalService.sessionModel.history.setMessageAdditional(lastMessageId, {
|
|
260
184
|
codeBlockMap: savedCodeBlockMap,
|
|
@@ -263,45 +187,21 @@ export abstract class BaseApplyService extends WithEventBus {
|
|
|
263
187
|
return newBlock;
|
|
264
188
|
}
|
|
265
189
|
|
|
266
|
-
private duringApply?: boolean;
|
|
267
|
-
|
|
268
190
|
/**
|
|
269
191
|
* Apply changes of a code block
|
|
270
192
|
*/
|
|
271
193
|
async apply(codeBlock: CodeBlockData): Promise<CodeBlockData> {
|
|
272
194
|
try {
|
|
273
|
-
this.duringApply = true;
|
|
274
195
|
if (codeBlock.iterationCount > 3) {
|
|
275
196
|
throw new Error('Lint error max iteration count exceeded');
|
|
276
197
|
}
|
|
277
|
-
|
|
278
|
-
const fastApplyFileResult = !codeBlock.originalCode
|
|
279
|
-
? {
|
|
280
|
-
result: codeBlock.codeEdit,
|
|
281
|
-
}
|
|
282
|
-
: await this.doApply(codeBlock);
|
|
198
|
+
const fastApplyFileResult = await this.doApply(codeBlock);
|
|
283
199
|
if (!fastApplyFileResult.stream && !fastApplyFileResult.result) {
|
|
284
200
|
throw new Error('No apply content provided');
|
|
285
201
|
}
|
|
286
202
|
|
|
287
|
-
if (this.activePreviewerMap.has(codeBlock.relativePath)) {
|
|
288
|
-
// 有正在进行的 apply,则取消(但不更新block状态,只清理副作用)
|
|
289
|
-
this.cancelApply(codeBlock, true);
|
|
290
|
-
}
|
|
291
203
|
// trigger diffPreivewer & return expected diff result directly
|
|
292
|
-
const result = await this.editorService.open(
|
|
293
|
-
URI.file(path.join(this.appConfig.workspaceDir, codeBlock.relativePath)),
|
|
294
|
-
);
|
|
295
|
-
if (!result) {
|
|
296
|
-
throw new Error('Failed to open file');
|
|
297
|
-
}
|
|
298
|
-
if (typeof fastApplyFileResult.result === 'string') {
|
|
299
|
-
codeBlock.updatedCode = fastApplyFileResult.result;
|
|
300
|
-
codeBlock.status = 'pending';
|
|
301
|
-
this.updateCodeBlock(codeBlock);
|
|
302
|
-
}
|
|
303
204
|
const applyResult = await this.renderApplyResult(
|
|
304
|
-
result.group.codeEditor.monacoEditor,
|
|
305
205
|
codeBlock,
|
|
306
206
|
(fastApplyFileResult.result || fastApplyFileResult.stream)!,
|
|
307
207
|
fastApplyFileResult.range,
|
|
@@ -317,37 +217,31 @@ export abstract class BaseApplyService extends WithEventBus {
|
|
|
317
217
|
codeBlock.status = 'failed';
|
|
318
218
|
this.updateCodeBlock(codeBlock);
|
|
319
219
|
throw err;
|
|
320
|
-
} finally {
|
|
321
|
-
this.duringApply = false;
|
|
322
220
|
}
|
|
323
221
|
}
|
|
324
222
|
|
|
325
223
|
async renderApplyResult(
|
|
326
|
-
editor: ICodeEditor,
|
|
327
224
|
codeBlock: CodeBlockData,
|
|
328
225
|
updatedContentOrStream: string | SumiReadableStream<IChatProgress>,
|
|
329
226
|
range?: Range,
|
|
330
227
|
): Promise<{ diff: string; diagnosticInfos: IMarker[] } | undefined> {
|
|
331
|
-
const
|
|
228
|
+
const { relativePath } = codeBlock;
|
|
229
|
+
const openResult = await this.editorService.open(URI.file(path.join(this.appConfig.workspaceDir, relativePath)));
|
|
230
|
+
if (!openResult) {
|
|
231
|
+
throw new Error('Failed to open editor');
|
|
232
|
+
}
|
|
233
|
+
const editor = openResult.group.codeEditor.monacoEditor;
|
|
332
234
|
const inlineDiffController = InlineDiffController.get(editor)!;
|
|
333
|
-
|
|
235
|
+
codeBlock.status = 'pending';
|
|
236
|
+
// 强刷展示 manager 视图
|
|
237
|
+
this.eventBus.fire(new RegisterEditorSideComponentEvent());
|
|
238
|
+
this.updateCodeBlock(codeBlock);
|
|
239
|
+
|
|
240
|
+
const fullOriginalContent = editor.getModel()!.getValue();
|
|
241
|
+
range = range || editor.getModel()?.getFullModelRange()!;
|
|
242
|
+
// const savedRangeContent = editor.getModel()!.getValueInRange(range);
|
|
334
243
|
|
|
335
244
|
if (typeof updatedContentOrStream === 'string') {
|
|
336
|
-
const editorCurrentContent = editor.getModel()!.getValue();
|
|
337
|
-
const uri = URI.file(path.join(this.appConfig.workspaceDir, codeBlock.relativePath));
|
|
338
|
-
const document = this.editorDocumentModelService.getModelReference(uri);
|
|
339
|
-
if (editorCurrentContent !== updatedContentOrStream || document?.instance.dirty) {
|
|
340
|
-
editor.getModel()?.pushEditOperations([], [EditOperation.replace(range, updatedContentOrStream)], () => null);
|
|
341
|
-
await this.editorService.save(uri);
|
|
342
|
-
}
|
|
343
|
-
const uriPendingCodeBlocks = this.getUriCodeBlocks(uri)?.filter((block) => block.status === 'pending');
|
|
344
|
-
const earlistPendingCodeBlock = uriPendingCodeBlocks?.[uriPendingCodeBlocks.length - 1];
|
|
345
|
-
if ((earlistPendingCodeBlock?.originalCode || codeBlock.originalCode) === updatedContentOrStream) {
|
|
346
|
-
codeBlock.status = 'cancelled';
|
|
347
|
-
this.updateCodeBlock(codeBlock);
|
|
348
|
-
deferred.resolve();
|
|
349
|
-
return;
|
|
350
|
-
}
|
|
351
245
|
// Create diff previewer
|
|
352
246
|
const previewer = inlineDiffController.createDiffPreviewer(
|
|
353
247
|
editor,
|
|
@@ -355,38 +249,18 @@ export abstract class BaseApplyService extends WithEventBus {
|
|
|
355
249
|
{
|
|
356
250
|
disposeWhenEditorClosed: true,
|
|
357
251
|
renderRemovedWidgetImmediately: true,
|
|
358
|
-
reverse: true,
|
|
359
252
|
},
|
|
360
253
|
) as LiveInlineDiffPreviewer;
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
this.eventBus.fire(new RegisterEditorSideComponentEvent());
|
|
366
|
-
|
|
367
|
-
this.listenPartialEdit(editor.getModel()!, codeBlock).then((result) => {
|
|
368
|
-
if (result) {
|
|
369
|
-
codeBlock.applyResult = result;
|
|
370
|
-
}
|
|
371
|
-
this.updateCodeBlock(codeBlock);
|
|
372
|
-
this.editorService.save(URI.file(path.join(this.appConfig.workspaceDir, codeBlock.relativePath)));
|
|
373
|
-
});
|
|
374
|
-
|
|
375
|
-
const { diff, rangesFromDiffHunk } = this.getDiffResult(
|
|
376
|
-
codeBlock.originalCode,
|
|
377
|
-
codeBlock.updatedCode || updatedContentOrStream,
|
|
378
|
-
codeBlock.relativePath,
|
|
379
|
-
);
|
|
380
|
-
const diagnosticInfos = this.getDiagnosticInfos(editor.getModel()!.uri.toString(), rangesFromDiffHunk);
|
|
381
|
-
deferred.resolve({
|
|
382
|
-
diff,
|
|
383
|
-
diagnosticInfos,
|
|
384
|
-
});
|
|
254
|
+
// TODO: 支持多个diffPreviewer
|
|
255
|
+
this.activePreviewer = previewer;
|
|
256
|
+
codeBlock.updatedCode = updatedContentOrStream;
|
|
257
|
+
previewer.setValue(updatedContentOrStream);
|
|
385
258
|
} else {
|
|
386
259
|
const controller = new InlineChatController();
|
|
387
260
|
controller.mountReadable(updatedContentOrStream);
|
|
261
|
+
const inlineDiffHandler = InlineDiffController.get(editor)!;
|
|
388
262
|
|
|
389
|
-
|
|
263
|
+
this.activePreviewer = inlineDiffHandler.showPreviewerByStream(editor, {
|
|
390
264
|
crossSelection: Selection.fromRange(range, SelectionDirection.LTR),
|
|
391
265
|
chatResponse: controller,
|
|
392
266
|
previewerOptions: {
|
|
@@ -394,68 +268,39 @@ export abstract class BaseApplyService extends WithEventBus {
|
|
|
394
268
|
renderRemovedWidgetImmediately: false,
|
|
395
269
|
},
|
|
396
270
|
}) as LiveInlineDiffPreviewer;
|
|
397
|
-
|
|
398
271
|
this.addDispose(
|
|
399
|
-
|
|
400
|
-
deferred.reject(err);
|
|
401
|
-
}),
|
|
402
|
-
);
|
|
403
|
-
this.addDispose(
|
|
404
|
-
controller.onAbort(() => {
|
|
405
|
-
deferred.reject(new Error('Apply aborted'));
|
|
406
|
-
}),
|
|
407
|
-
);
|
|
408
|
-
this.addDispose(
|
|
409
|
-
// 流式输出结束后,转为直接输出逻辑
|
|
410
|
-
previewer.getNode()!.onDiffFinished(async (diffModel) => {
|
|
272
|
+
this.activePreviewer.getNode()!.onDiffFinished((diffModel) => {
|
|
411
273
|
codeBlock.updatedCode = diffModel.newFullRangeTextLines.join('\n');
|
|
412
|
-
// TODO: 添加 reapply
|
|
413
|
-
// 实际应用结果为空,则取消
|
|
414
|
-
if (codeBlock.updatedCode === codeBlock.originalCode) {
|
|
415
|
-
codeBlock.status = 'failed';
|
|
416
|
-
this.updateCodeBlock(codeBlock);
|
|
417
|
-
previewer.dispose();
|
|
418
|
-
deferred.reject(new Error('no changes applied'));
|
|
419
|
-
return;
|
|
420
|
-
}
|
|
421
|
-
codeBlock.status = 'pending';
|
|
422
274
|
this.updateCodeBlock(codeBlock);
|
|
423
|
-
previewer.dispose();
|
|
424
|
-
const result = await this.renderApplyResult(editor, codeBlock, codeBlock.updatedCode);
|
|
425
|
-
deferred.resolve(result);
|
|
426
275
|
}),
|
|
427
276
|
);
|
|
428
|
-
this.activePreviewerMap.set(codeBlock.relativePath, previewer);
|
|
429
277
|
}
|
|
430
|
-
|
|
278
|
+
|
|
279
|
+
return this.listenPartialEdit(editor, codeBlock, fullOriginalContent);
|
|
431
280
|
}
|
|
432
281
|
|
|
433
282
|
/**
|
|
434
283
|
* Cancel an ongoing apply operation
|
|
435
284
|
*/
|
|
436
|
-
cancelApply(blockData: CodeBlockData
|
|
285
|
+
cancelApply(blockData: CodeBlockData): void {
|
|
437
286
|
if (blockData.status === 'generating' || blockData.status === 'pending') {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
);
|
|
442
|
-
if (this.activePreviewerMap.has(blockData.relativePath)) {
|
|
443
|
-
this.activePreviewerMap
|
|
444
|
-
.get(blockData.relativePath)
|
|
445
|
-
?.getNode()
|
|
446
|
-
?.livePreviewDiffDecorationModel.discardUnProcessed();
|
|
447
|
-
this.activePreviewerMap.disposeKey(blockData.relativePath);
|
|
448
|
-
}
|
|
449
|
-
if (!keepStatus) {
|
|
450
|
-
blockData.status = 'cancelled';
|
|
451
|
-
this.updateCodeBlock(blockData);
|
|
287
|
+
if (this.activePreviewer) {
|
|
288
|
+
this.activePreviewer.getNode()?.livePreviewDiffDecorationModel.discardUnProcessed();
|
|
289
|
+
this.activePreviewer.dispose();
|
|
452
290
|
}
|
|
291
|
+
blockData.status = 'cancelled';
|
|
292
|
+
this.updateCodeBlock(blockData);
|
|
453
293
|
}
|
|
454
294
|
}
|
|
455
295
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
296
|
+
// TODO: 目前的设计下,有一个工具 apply 没返回,是不会触发下一个的(cursor 是会全部自动 apply 的),所以这个方法目前还没有必要
|
|
297
|
+
cancelAllApply(): void {
|
|
298
|
+
const messageId = this.chatInternalService.sessionModel.history.lastMessageId!;
|
|
299
|
+
const codeBlockMap = this.getMessageCodeBlocks(messageId);
|
|
300
|
+
if (!codeBlockMap) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
Object.values(codeBlockMap).forEach((blockData) => {
|
|
459
304
|
this.cancelApply(blockData);
|
|
460
305
|
});
|
|
461
306
|
}
|
|
@@ -478,13 +323,11 @@ export abstract class BaseApplyService extends WithEventBus {
|
|
|
478
323
|
}
|
|
479
324
|
|
|
480
325
|
processAll(uri: URI, type: 'accept' | 'reject'): void {
|
|
481
|
-
const
|
|
482
|
-
if (!
|
|
326
|
+
const codeBlock = this.getUriPendingCodeBlock(uri);
|
|
327
|
+
if (!codeBlock) {
|
|
483
328
|
throw new Error('No pending code block found');
|
|
484
329
|
}
|
|
485
|
-
const decorationModel = this.
|
|
486
|
-
.get(codeBlocks[0].relativePath)
|
|
487
|
-
?.getNode()?.livePreviewDiffDecorationModel;
|
|
330
|
+
const decorationModel = this.activePreviewer?.getNode()?.livePreviewDiffDecorationModel;
|
|
488
331
|
if (!decorationModel) {
|
|
489
332
|
throw new Error('No active previewer found');
|
|
490
333
|
}
|
|
@@ -494,89 +337,49 @@ export abstract class BaseApplyService extends WithEventBus {
|
|
|
494
337
|
decorationModel.discardUnProcessed();
|
|
495
338
|
}
|
|
496
339
|
this.editorService.save(uri);
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
// TODO: 批量更新
|
|
500
|
-
this.updateCodeBlock(codeBlock);
|
|
501
|
-
});
|
|
340
|
+
codeBlock.status = type === 'accept' ? 'success' : 'cancelled';
|
|
341
|
+
this.updateCodeBlock(codeBlock);
|
|
502
342
|
}
|
|
503
343
|
|
|
504
|
-
protected listenPartialEdit(
|
|
344
|
+
protected listenPartialEdit(editor: ICodeEditor, codeBlock: CodeBlockData, fullOriginalContent: string) {
|
|
505
345
|
const deferred = new Deferred<{ diff: string; diagnosticInfos: IMarker[] }>();
|
|
506
|
-
const uriString = model.uri.toString();
|
|
507
346
|
const toDispose = this.inlineDiffService.onPartialEdit((event) => {
|
|
508
347
|
// TODO 支持自动保存
|
|
509
|
-
if (
|
|
510
|
-
event.totalPartialEditCount === event.resolvedPartialEditCount &&
|
|
511
|
-
event.uri.path === model.uri.path.toString()
|
|
512
|
-
) {
|
|
348
|
+
if (event.totalPartialEditCount === event.resolvedPartialEditCount) {
|
|
513
349
|
if (event.acceptPartialEditCount > 0) {
|
|
514
350
|
codeBlock.status = 'success';
|
|
515
|
-
const appliedResult =
|
|
516
|
-
const
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
351
|
+
const appliedResult = editor.getModel()!.getValue();
|
|
352
|
+
const diffResult = createPatch(codeBlock.relativePath, fullOriginalContent, appliedResult)
|
|
353
|
+
.split('\n')
|
|
354
|
+
.slice(4)
|
|
355
|
+
.join('\n');
|
|
356
|
+
const rangesFromDiffHunk = diffResult
|
|
357
|
+
.split('\n')
|
|
358
|
+
.map((line) => {
|
|
359
|
+
if (line.startsWith('@@')) {
|
|
360
|
+
const [, , , start, end] = line.match(/@@ -(\d+),(\d+) \+(\d+),(\d+) @@/)!;
|
|
361
|
+
return new Range(parseInt(start, 10), 0, parseInt(end, 10), 0);
|
|
362
|
+
}
|
|
363
|
+
return null;
|
|
364
|
+
})
|
|
365
|
+
.filter((range) => range !== null);
|
|
366
|
+
const diagnosticInfos = this.getDiagnosticInfos(editor.getModel()!.uri.toString(), rangesFromDiffHunk);
|
|
522
367
|
// 移除开头的几个固定信息,避免浪费 tokens
|
|
523
|
-
this.aiReporter.send({
|
|
524
|
-
msgType: AIServiceType.Chat,
|
|
525
|
-
actionType: ActionTypeEnum.Accept,
|
|
526
|
-
actionSource: ActionSourceEnum.Chat,
|
|
527
|
-
sessionId: this.chatInternalService.sessionModel.sessionId,
|
|
528
|
-
isReceive: true,
|
|
529
|
-
isDrop: false,
|
|
530
|
-
code: codeBlock.codeEdit,
|
|
531
|
-
message: JSON.stringify({
|
|
532
|
-
diff,
|
|
533
|
-
diagnosticInfos,
|
|
534
|
-
}),
|
|
535
|
-
});
|
|
536
368
|
deferred.resolve({
|
|
537
|
-
diff,
|
|
369
|
+
diff: diffResult,
|
|
538
370
|
diagnosticInfos,
|
|
539
371
|
});
|
|
540
372
|
} else {
|
|
541
373
|
// 用户全部取消
|
|
542
374
|
codeBlock.status = 'cancelled';
|
|
543
375
|
deferred.resolve();
|
|
544
|
-
this.aiReporter.send({
|
|
545
|
-
msgType: AIServiceType.Chat,
|
|
546
|
-
actionType: ActionTypeEnum.Discard,
|
|
547
|
-
actionSource: ActionSourceEnum.Chat,
|
|
548
|
-
sessionId: this.chatInternalService.sessionModel.sessionId,
|
|
549
|
-
isReceive: false,
|
|
550
|
-
isDrop: true,
|
|
551
|
-
code: codeBlock.codeEdit,
|
|
552
|
-
originCode: codeBlock.originalCode,
|
|
553
|
-
});
|
|
554
376
|
}
|
|
555
|
-
|
|
377
|
+
toDispose.dispose();
|
|
556
378
|
}
|
|
557
379
|
});
|
|
558
|
-
this.editorListenerMap.set(uriString, toDispose);
|
|
559
380
|
return deferred.promise;
|
|
560
381
|
}
|
|
561
382
|
|
|
562
|
-
protected getDiffResult(originalContent: string, appliedResult: string, relativePath: string) {
|
|
563
|
-
const diffResult = createPatch(relativePath, originalContent, appliedResult).split('\n').slice(4).join('\n');
|
|
564
|
-
const rangesFromDiffHunk = diffResult
|
|
565
|
-
.split('\n')
|
|
566
|
-
.map((line) => {
|
|
567
|
-
if (line.startsWith('@@')) {
|
|
568
|
-
const [, , , start, end] = line.match(/@@ -(\d+),(\d+) \+(\d+),(\d+) @@/)!;
|
|
569
|
-
return new Range(parseInt(start, 10), 0, parseInt(end, 10), 0);
|
|
570
|
-
}
|
|
571
|
-
return null;
|
|
572
|
-
})
|
|
573
|
-
.filter((range) => range !== null);
|
|
574
|
-
return {
|
|
575
|
-
diff: diffResult,
|
|
576
|
-
rangesFromDiffHunk,
|
|
577
|
-
};
|
|
578
|
-
}
|
|
579
|
-
|
|
580
383
|
/**
|
|
581
384
|
* Apply changes of a code block, return stream to render inline diff in stream mode, result to render inline diff directly
|
|
582
385
|
* range is optional, if not provided, the result will be applied to the the full file
|
|
@@ -4,7 +4,7 @@ import { Autowired, Injectable } from '@opensumi/di';
|
|
|
4
4
|
import { ILogger } from '@opensumi/ide-core-browser';
|
|
5
5
|
import { Emitter, Event } from '@opensumi/ide-core-common';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { ISumiMCPServerBackend, SumiMCPServerProxyServicePath } from '../../common';
|
|
8
8
|
import { IMCPServerProxyService } from '../../common/types';
|
|
9
9
|
import { IMCPServerRegistry, TokenMCPServerRegistry } from '../types';
|
|
10
10
|
|
|
@@ -35,7 +35,7 @@ export class MCPServerProxyService implements IMCPServerProxyService {
|
|
|
35
35
|
name: tool.name,
|
|
36
36
|
description: tool.description,
|
|
37
37
|
inputSchema: zodToJsonSchema(tool.inputSchema),
|
|
38
|
-
providerName:
|
|
38
|
+
providerName: 'sumi-builtin',
|
|
39
39
|
}),
|
|
40
40
|
);
|
|
41
41
|
|
|
@@ -52,16 +52,4 @@ export class MCPServerProxyService implements IMCPServerProxyService {
|
|
|
52
52
|
async getAllMCPTools() {
|
|
53
53
|
return this.sumiMCPServerProxyService.getAllMCPTools();
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
async $getServers() {
|
|
57
|
-
return this.sumiMCPServerProxyService.getServers();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async $startServer(serverName: string) {
|
|
61
|
-
await this.sumiMCPServerProxyService.startServer(serverName);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
async $stopServer(serverName: string) {
|
|
65
|
-
await this.sumiMCPServerProxyService.stopServer(serverName);
|
|
66
|
-
}
|
|
67
55
|
}
|