@opensumi/ide-ai-native 3.8.1-next-1740475512.0 → 3.8.1-next-1740556231.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.contribution.d.ts +4 -1
- package/lib/browser/ai-core.contribution.d.ts.map +1 -1
- package/lib/browser/ai-core.contribution.js +23 -11
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/chat/chat-manager.service.d.ts +1 -5
- package/lib/browser/chat/chat-manager.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-manager.service.js +13 -17
- package/lib/browser/chat/chat-manager.service.js.map +1 -1
- package/lib/browser/chat/chat-model.d.ts +0 -2
- package/lib/browser/chat/chat-model.d.ts.map +1 -1
- package/lib/browser/chat/chat-model.js +2 -8
- package/lib/browser/chat/chat-model.js.map +1 -1
- package/lib/browser/chat/chat.internal.service.d.ts +1 -0
- package/lib/browser/chat/chat.internal.service.d.ts.map +1 -1
- package/lib/browser/chat/chat.internal.service.js +3 -0
- 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 +9 -6
- 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/ChatHistory.d.ts +0 -1
- package/lib/browser/components/ChatHistory.d.ts.map +1 -1
- package/lib/browser/components/ChatHistory.js +14 -14
- package/lib/browser/components/ChatHistory.js.map +1 -1
- package/lib/browser/components/ChatInput.d.ts.map +1 -1
- package/lib/browser/components/ChatInput.js +1 -25
- package/lib/browser/components/ChatInput.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/{chat-history.css → chat-history.module.less} +1 -1
- package/lib/browser/components/components.module.less +0 -20
- package/lib/browser/context/llm-context.service.d.ts +5 -16
- package/lib/browser/context/llm-context.service.d.ts.map +1 -1
- package/lib/browser/context/llm-context.service.js +47 -78
- package/lib/browser/context/llm-context.service.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 +31 -40
- package/lib/browser/mcp/base-apply.service.d.ts.map +1 -1
- package/lib/browser/mcp/base-apply.service.js +233 -167
- 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.map +1 -1
- package/lib/browser/mcp/mcp-server.feature.registry.js +2 -3
- 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 +55 -41
- package/lib/browser/mcp/tools/components/EditFile.js.map +1 -1
- package/lib/browser/mcp/tools/components/index.module.less +22 -4
- package/lib/browser/mcp/tools/createNewFileWithText.d.ts.map +1 -1
- package/lib/browser/mcp/tools/createNewFileWithText.js +0 -1
- package/lib/browser/mcp/tools/createNewFileWithText.js.map +1 -1
- package/lib/browser/mcp/tools/editFile.js +1 -1
- package/lib/browser/mcp/tools/editFile.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/handlers/EditFile.d.ts +5 -1
- package/lib/browser/mcp/tools/handlers/EditFile.d.ts.map +1 -1
- package/lib/browser/mcp/tools/handlers/EditFile.js +4 -4
- package/lib/browser/mcp/tools/handlers/EditFile.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/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 +1 -0
- package/lib/browser/model/msg-history-manager.d.ts.map +1 -1
- package/lib/browser/model/msg-history-manager.js +12 -2
- 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 +0 -16
- package/lib/browser/preferences/schema.js.map +1 -1
- package/lib/browser/types.d.ts +1 -1
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-manager.d.ts +6 -0
- package/lib/browser/widget/inline-diff/inline-diff-manager.d.ts.map +1 -0
- package/lib/browser/widget/inline-diff/inline-diff-manager.js +27 -0
- package/lib/browser/widget/inline-diff/inline-diff-manager.js.map +1 -0
- package/lib/browser/widget/inline-diff/inline-diff-widget.module.less +12 -0
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.d.ts +2 -0
- 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 +11 -4
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.js.map +1 -1
- package/lib/common/index.d.ts +1 -8
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +1 -3
- package/lib/common/index.js.map +1 -1
- package/lib/common/llm-context.d.ts +9 -12
- 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 -2
- package/lib/common/prompts/context-prompt-provider.d.ts.map +1 -1
- package/lib/common/prompts/context-prompt-provider.js +22 -21
- 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 +17 -6
- package/lib/common/types.d.ts.map +1 -1
- package/lib/common/types.js.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/base-language-model.d.ts +1 -1
- package/lib/node/base-language-model.d.ts.map +1 -1
- package/lib/node/base-language-model.js +54 -3
- package/lib/node/base-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 +3 -4
- package/lib/node/openai/openai-language-model.d.ts.map +1 -1
- package/lib/node/openai/openai-language-model.js +2 -3
- package/lib/node/openai/openai-language-model.js.map +1 -1
- package/package.json +27 -27
- package/src/browser/ai-core.contribution.ts +29 -14
- package/src/browser/chat/chat-manager.service.ts +13 -17
- package/src/browser/chat/chat-model.ts +3 -18
- package/src/browser/chat/chat.internal.service.ts +4 -0
- package/src/browser/chat/chat.module.less +2 -1
- package/src/browser/chat/chat.view.tsx +26 -10
- package/src/browser/components/ChatContext/index.tsx +2 -2
- package/src/browser/components/ChatHistory.tsx +21 -15
- package/src/browser/components/ChatInput.tsx +4 -67
- package/src/browser/components/ChatToolRender.tsx +2 -1
- package/src/browser/components/{chat-history.css → chat-history.module.less} +1 -1
- package/src/browser/components/components.module.less +0 -20
- package/src/browser/context/llm-context.service.ts +54 -90
- package/src/browser/index.ts +0 -4
- package/src/browser/layout/layout.module.less +4 -4
- package/src/browser/mcp/base-apply.service.ts +266 -213
- package/src/browser/mcp/mcp-server-proxy.service.ts +2 -14
- package/src/browser/mcp/mcp-server.feature.registry.ts +2 -3
- package/src/browser/mcp/tools/components/EditFile.tsx +82 -60
- package/src/browser/mcp/tools/components/index.module.less +22 -4
- package/src/browser/mcp/tools/createNewFileWithText.ts +0 -1
- package/src/browser/mcp/tools/editFile.ts +2 -2
- package/src/browser/mcp/tools/getDiagnosticsByPath.ts +0 -1
- package/src/browser/mcp/tools/handlers/EditFile.ts +4 -4
- package/src/browser/mcp/tools/handlers/RunCommand.ts +0 -2
- package/src/browser/mcp/tools/runTerminalCmd.ts +0 -1
- package/src/browser/model/msg-history-manager.ts +12 -2
- package/src/browser/preferences/schema.ts +0 -16
- package/src/browser/types.ts +1 -1
- package/src/browser/widget/inline-diff/inline-diff-manager.tsx +38 -0
- package/src/browser/widget/inline-diff/inline-diff-widget.module.less +12 -0
- package/src/browser/widget/inline-stream-diff/inline-stream-diff.handler.tsx +13 -4
- package/src/common/index.ts +1 -7
- 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 +28 -26
- package/src/common/tool-invocation-registry.ts +2 -2
- package/src/common/types.ts +20 -6
- package/src/common/utils.ts +1 -3
- package/src/node/base-language-model.ts +63 -1
- 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 -7
- 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/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
|
@@ -1,31 +1,21 @@
|
|
|
1
1
|
import cls from 'classnames';
|
|
2
2
|
import React, { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { useInjectable, useLatest } from '@opensumi/ide-core-browser';
|
|
5
5
|
import { Icon, Popover, PopoverPosition, getIcon } from '@opensumi/ide-core-browser/lib/components';
|
|
6
6
|
import { EnhanceIcon } from '@opensumi/ide-core-browser/lib/components/ai-native';
|
|
7
7
|
import { InteractiveInput } from '@opensumi/ide-core-browser/lib/components/ai-native/interactive-input/index';
|
|
8
|
-
import {
|
|
9
|
-
ChatAgentViewServiceToken,
|
|
10
|
-
ChatFeatureRegistryToken,
|
|
11
|
-
MessageType,
|
|
12
|
-
localize,
|
|
13
|
-
runWhenIdle,
|
|
14
|
-
} from '@opensumi/ide-core-common';
|
|
15
|
-
import { CommandService } from '@opensumi/ide-core-common/lib/command';
|
|
8
|
+
import { ChatAgentViewServiceToken, ChatFeatureRegistryToken, localize, runWhenIdle } from '@opensumi/ide-core-common';
|
|
16
9
|
import { MonacoCommandRegistry } from '@opensumi/ide-editor/lib/browser/monaco-contrib/command/command.service';
|
|
17
|
-
import { IDialogService } from '@opensumi/ide-overlay';
|
|
18
10
|
|
|
19
|
-
import { AT_SIGN_SYMBOL, IChatAgentService, SLASH_SYMBOL
|
|
11
|
+
import { AT_SIGN_SYMBOL, IChatAgentService, SLASH_SYMBOL } from '../../common';
|
|
20
12
|
import { ChatAgentViewService } from '../chat/chat-agent.view.service';
|
|
21
13
|
import { ChatSlashCommandItemModel } from '../chat/chat-model';
|
|
22
14
|
import { ChatProxyService } from '../chat/chat-proxy.service';
|
|
23
15
|
import { ChatFeatureRegistry } from '../chat/chat.feature.registry';
|
|
24
|
-
import { OPEN_MCP_CONFIG_COMMAND } from '../mcp/config/mcp-config.commands';
|
|
25
|
-
import { MCPServerProxyService } from '../mcp/mcp-server-proxy.service';
|
|
26
|
-
import { MCPToolsDialog } from '../mcp/mcp-tools-dialog.view';
|
|
27
16
|
import { IChatSlashCommandItem } from '../types';
|
|
28
17
|
|
|
18
|
+
import { ChatContext } from './ChatContext';
|
|
29
19
|
import styles from './components.module.less';
|
|
30
20
|
|
|
31
21
|
const INSTRUCTION_BOTTOM = 8;
|
|
@@ -205,29 +195,12 @@ export const ChatInput = React.forwardRef((props: IChatInputProps, ref) => {
|
|
|
205
195
|
const [isExpand, setIsExpand] = useState(false);
|
|
206
196
|
const [placeholder, setPlaceHolder] = useState(localize('aiNative.chat.input.placeholder.default'));
|
|
207
197
|
|
|
208
|
-
const dialogService = useInjectable<IDialogService>(IDialogService);
|
|
209
|
-
const aiNativeConfigService = useInjectable<AINativeConfigService>(AINativeConfigService);
|
|
210
|
-
const mcpServerProxyService = useInjectable<MCPServerProxyService>(TokenMCPServerProxyService);
|
|
211
198
|
const monacoCommandRegistry = useInjectable<MonacoCommandRegistry>(MonacoCommandRegistry);
|
|
212
199
|
const chatAgentService = useInjectable<IChatAgentService>(IChatAgentService);
|
|
213
200
|
const chatFeatureRegistry = useInjectable<ChatFeatureRegistry>(ChatFeatureRegistryToken);
|
|
214
|
-
const commandService = useInjectable<CommandService>(CommandService);
|
|
215
201
|
|
|
216
202
|
const currentAgentIdRef = useLatest(agentId);
|
|
217
203
|
|
|
218
|
-
const handleShowMCPConfig = React.useCallback(() => {
|
|
219
|
-
commandService.executeCommand(OPEN_MCP_CONFIG_COMMAND.id);
|
|
220
|
-
}, [commandService]);
|
|
221
|
-
|
|
222
|
-
const handleShowMCPTools = React.useCallback(async () => {
|
|
223
|
-
const tools = await mcpServerProxyService.getAllMCPTools();
|
|
224
|
-
dialogService.open({
|
|
225
|
-
message: <MCPToolsDialog tools={tools} />,
|
|
226
|
-
type: MessageType.Empty,
|
|
227
|
-
buttons: ['关闭'],
|
|
228
|
-
});
|
|
229
|
-
}, [mcpServerProxyService, dialogService]);
|
|
230
|
-
|
|
231
204
|
useImperativeHandle(ref, () => ({
|
|
232
205
|
setInputValue: (v: string) => {
|
|
233
206
|
setValue(v);
|
|
@@ -489,42 +462,6 @@ export const ChatInput = React.forwardRef((props: IChatInputProps, ref) => {
|
|
|
489
462
|
height={inputHeight}
|
|
490
463
|
popoverPosition={PopoverPosition.left}
|
|
491
464
|
/>
|
|
492
|
-
<div className={styles.chat_input_footer}>
|
|
493
|
-
{aiNativeConfigService.capabilities.supportsMCP && (
|
|
494
|
-
<div className={styles.mcp_desc}>
|
|
495
|
-
<Popover
|
|
496
|
-
overlayClassName={styles.popover_icon}
|
|
497
|
-
id={'ai-chat-header-mcp-server'}
|
|
498
|
-
position={PopoverPosition.left}
|
|
499
|
-
title={'MCP Server'}
|
|
500
|
-
>
|
|
501
|
-
<EnhanceIcon
|
|
502
|
-
wrapperClassName={styles.action_btn}
|
|
503
|
-
className={'codicon codicon-server'}
|
|
504
|
-
onClick={handleShowMCPConfig}
|
|
505
|
-
tabIndex={0}
|
|
506
|
-
role='button'
|
|
507
|
-
ariaLabel={'MCP Server'}
|
|
508
|
-
/>
|
|
509
|
-
</Popover>
|
|
510
|
-
<Popover
|
|
511
|
-
overlayClassName={styles.popover_icon}
|
|
512
|
-
id={'ai-chat-header-tools'}
|
|
513
|
-
position={PopoverPosition.left}
|
|
514
|
-
title={localize('aiNative.operate.tools.title')}
|
|
515
|
-
>
|
|
516
|
-
<EnhanceIcon
|
|
517
|
-
wrapperClassName={styles.action_btn}
|
|
518
|
-
className={getIcon('menubar-tool')}
|
|
519
|
-
onClick={handleShowMCPTools}
|
|
520
|
-
tabIndex={0}
|
|
521
|
-
role='button'
|
|
522
|
-
ariaLabel={localize('aiNative.operate.tools.title')}
|
|
523
|
-
/>
|
|
524
|
-
</Popover>
|
|
525
|
-
</div>
|
|
526
|
-
)}
|
|
527
|
-
</div>
|
|
528
465
|
</div>
|
|
529
466
|
);
|
|
530
467
|
});
|
|
@@ -67,12 +67,13 @@ export const ChatToolRender = (props: { value: IChatToolContent['content']; mess
|
|
|
67
67
|
<div className={styles['chat-tool-render']}>
|
|
68
68
|
<div className={styles['tool-header']} onClick={toggleExpand}>
|
|
69
69
|
<div className={styles['tool-name']}>
|
|
70
|
-
<
|
|
70
|
+
<span className={cls(styles['expand-icon'], { [styles.expanded]: isExpanded })}>▶</span>
|
|
71
71
|
{label}
|
|
72
72
|
</div>
|
|
73
73
|
{value.state && (
|
|
74
74
|
<div className={styles['tool-state']}>
|
|
75
75
|
<span className={styles['state-icon']}>{stateInfo.icon}</span>
|
|
76
|
+
<span className={styles['state-label']}>{stateInfo.label}</span>
|
|
76
77
|
</div>
|
|
77
78
|
)}
|
|
78
79
|
</div>
|
|
@@ -96,7 +96,6 @@
|
|
|
96
96
|
.chat_input_container {
|
|
97
97
|
position: relative;
|
|
98
98
|
border-radius: 9px;
|
|
99
|
-
padding: 10px 0px 0px 0px;
|
|
100
99
|
border: 1px solid var(--kt-input-border);
|
|
101
100
|
background-color: var(--design-chatInput-background);
|
|
102
101
|
&.active {
|
|
@@ -506,22 +505,3 @@
|
|
|
506
505
|
}
|
|
507
506
|
}
|
|
508
507
|
}
|
|
509
|
-
|
|
510
|
-
.chat_input_footer {
|
|
511
|
-
padding: 0px 10px;
|
|
512
|
-
display: flex;
|
|
513
|
-
align-items: center;
|
|
514
|
-
font-size: 12px;
|
|
515
|
-
|
|
516
|
-
.model_selector {
|
|
517
|
-
display: flex;
|
|
518
|
-
font-size: 11px;
|
|
519
|
-
align-items: center;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
.mcp_desc {
|
|
523
|
-
padding: 5px 0px;
|
|
524
|
-
display: flex;
|
|
525
|
-
align-items: center;
|
|
526
|
-
}
|
|
527
|
-
}
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
import { EditorSelectionChangeEvent } from '@opensumi/ide-editor/lib/browser/types';
|
|
13
13
|
import { IMarkerService } from '@opensumi/ide-markers/lib/common/types';
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import { FileContext, LLMContextService, SerializedContext } from '../../common/llm-context';
|
|
16
16
|
|
|
17
17
|
@Injectable()
|
|
18
18
|
export class LLMContextServiceImpl extends WithEventBus implements LLMContextService {
|
|
@@ -27,65 +27,40 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
|
|
|
27
27
|
|
|
28
28
|
private isAutoCollecting = false;
|
|
29
29
|
|
|
30
|
-
private
|
|
31
|
-
private readonly maxViewFilesLimit = 20;
|
|
32
|
-
private readonly attachedFiles: FileContext[] = [];
|
|
33
|
-
private readonly recentlyViewFiles: FileContext[] = [];
|
|
34
|
-
private readonly onDidContextFilesChangeEmitter = new Emitter<{ viewed: FileContext[]; attached: FileContext[] }>();
|
|
35
|
-
onDidContextFilesChangeEvent = this.onDidContextFilesChangeEmitter.event;
|
|
30
|
+
private contextFiles: FileContext[] = [];
|
|
36
31
|
|
|
37
|
-
private
|
|
38
|
-
const existingIndex = list.findIndex((f) => f.uri.toString() === file.uri.toString());
|
|
39
|
-
if (existingIndex > -1) {
|
|
40
|
-
list.splice(existingIndex, 1);
|
|
41
|
-
}
|
|
32
|
+
private maxFiles: number = 10; // 上下文的最大长度限制
|
|
42
33
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
list.shift();
|
|
46
|
-
}
|
|
47
|
-
}
|
|
34
|
+
private onDidContextFilesChangeEmitter = new Emitter<FileContext[]>();
|
|
35
|
+
onDidContextFilesChangeEvent = this.onDidContextFilesChangeEmitter.event;
|
|
48
36
|
|
|
49
|
-
addFileToContext(uri: URI, selection?: [number, number], isManual =
|
|
50
|
-
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
37
|
+
addFileToContext(uri: URI, selection?: [number, number], isManual = true): void {
|
|
38
|
+
this.removeFileFromContext(uri);
|
|
53
39
|
|
|
54
|
-
|
|
55
|
-
const targetList = isManual ? this.attachedFiles : this.recentlyViewFiles;
|
|
56
|
-
const maxLimit = isManual ? this.maxAttachFilesLimit : this.maxViewFilesLimit;
|
|
40
|
+
this.contextFiles.push({ uri, selection, isManual });
|
|
57
41
|
|
|
58
|
-
if (
|
|
59
|
-
this.
|
|
42
|
+
if (this.contextFiles.length > this.maxFiles) {
|
|
43
|
+
this.contextFiles.shift();
|
|
60
44
|
}
|
|
61
45
|
|
|
62
|
-
this.addFileToList(file, targetList, maxLimit);
|
|
63
|
-
this.notifyContextChange();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
private notifyContextChange(): void {
|
|
67
46
|
this.onDidContextFilesChangeEmitter.fire(this.getAllContextFiles());
|
|
68
47
|
}
|
|
69
48
|
|
|
70
49
|
cleanFileContext() {
|
|
71
|
-
this.
|
|
72
|
-
this.
|
|
50
|
+
this.contextFiles = [];
|
|
51
|
+
this.onDidContextFilesChangeEmitter.fire(this.getAllContextFiles());
|
|
73
52
|
}
|
|
74
53
|
|
|
75
54
|
private getAllContextFiles() {
|
|
76
|
-
return
|
|
77
|
-
viewed: this.recentlyViewFiles,
|
|
78
|
-
attached: this.attachedFiles,
|
|
79
|
-
};
|
|
55
|
+
return [...this.contextFiles];
|
|
80
56
|
}
|
|
81
57
|
|
|
82
|
-
removeFileFromContext(uri: URI
|
|
83
|
-
const
|
|
84
|
-
const index = targetList.findIndex((file) => file.uri.toString() === uri.toString());
|
|
58
|
+
removeFileFromContext(uri: URI): void {
|
|
59
|
+
const index = this.contextFiles.findIndex((file) => file.uri.toString() === uri.toString());
|
|
85
60
|
if (index > -1) {
|
|
86
|
-
|
|
61
|
+
this.contextFiles.splice(index, 1);
|
|
62
|
+
this.onDidContextFilesChangeEmitter.fire(this.getAllContextFiles());
|
|
87
63
|
}
|
|
88
|
-
this.notifyContextChange();
|
|
89
64
|
}
|
|
90
65
|
|
|
91
66
|
startAutoCollection(): void {
|
|
@@ -103,7 +78,8 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
|
|
|
103
78
|
if (event.payload.uri.scheme !== 'file') {
|
|
104
79
|
return;
|
|
105
80
|
}
|
|
106
|
-
|
|
81
|
+
// FIXME: 暂时不自动添加
|
|
82
|
+
// this.addFileToContext(event.payload.uri);
|
|
107
83
|
}),
|
|
108
84
|
);
|
|
109
85
|
|
|
@@ -112,8 +88,6 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
|
|
|
112
88
|
if (event.payload.scheme !== 'file') {
|
|
113
89
|
return;
|
|
114
90
|
}
|
|
115
|
-
|
|
116
|
-
this.removeFileFromContext(event.payload, false);
|
|
117
91
|
}),
|
|
118
92
|
);
|
|
119
93
|
|
|
@@ -135,12 +109,11 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
|
|
|
135
109
|
].sort() as [number, number];
|
|
136
110
|
|
|
137
111
|
if (selection[0] === selection[1]) {
|
|
138
|
-
this.addFileToContext(event.payload.editorUri, undefined
|
|
112
|
+
this.addFileToContext(event.payload.editorUri, undefined);
|
|
139
113
|
} else {
|
|
140
114
|
this.addFileToContext(
|
|
141
115
|
event.payload.editorUri,
|
|
142
116
|
selection.sort((a, b) => a - b),
|
|
143
|
-
false,
|
|
144
117
|
);
|
|
145
118
|
}
|
|
146
119
|
}
|
|
@@ -154,51 +127,42 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
|
|
|
154
127
|
|
|
155
128
|
serialize(): SerializedContext {
|
|
156
129
|
const files = this.getAllContextFiles();
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
return files
|
|
167
|
-
.map((file) => workspaceRoot.relative(file.uri)?.toString() || file.uri.parent.toString())
|
|
130
|
+
const recentlyViewFiles = files
|
|
131
|
+
.filter((v) => !v.selection)
|
|
132
|
+
.map((file) => {
|
|
133
|
+
const relativePath = URI.file(this.appConfig.workspaceDir).relative(file.uri);
|
|
134
|
+
if (relativePath) {
|
|
135
|
+
return relativePath.toString();
|
|
136
|
+
}
|
|
137
|
+
return file.uri.parent.toString();
|
|
138
|
+
})
|
|
168
139
|
.filter(Boolean);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
private serializeAttachedFiles(files: FileContext[], workspaceRoot: URI): AttachFileContext[] {
|
|
172
|
-
return files
|
|
173
|
-
.map((file) => this.serializeAttachedFile(file, workspaceRoot))
|
|
174
|
-
.filter(Boolean) as unknown as AttachFileContext[];
|
|
175
|
-
}
|
|
176
140
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
return this.markerService
|
|
197
|
-
.getManager()
|
|
198
|
-
.getMarkers({
|
|
199
|
-
resource: uri.toString(),
|
|
200
|
-
severities: MarkerSeverity.Error,
|
|
141
|
+
const attachedFiles = files
|
|
142
|
+
.filter((v) => v.selection)
|
|
143
|
+
.map((file) => {
|
|
144
|
+
const ref = this.docModelManager.getModelReference(file.uri);
|
|
145
|
+
const content = ref!.instance.getText();
|
|
146
|
+
const lineErrors = this.markerService
|
|
147
|
+
.getManager()
|
|
148
|
+
.getMarkers({
|
|
149
|
+
resource: file.uri.toString(),
|
|
150
|
+
severities: MarkerSeverity.Error,
|
|
151
|
+
})
|
|
152
|
+
.map((marker) => marker.message);
|
|
153
|
+
|
|
154
|
+
return {
|
|
155
|
+
content,
|
|
156
|
+
lineErrors,
|
|
157
|
+
path: URI.file(this.appConfig.workspaceDir).relative(file.uri)!.toString(),
|
|
158
|
+
language: ref?.instance.languageId!,
|
|
159
|
+
};
|
|
201
160
|
})
|
|
202
|
-
.
|
|
161
|
+
.filter(Boolean);
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
recentlyViewFiles,
|
|
165
|
+
attachedFiles,
|
|
166
|
+
};
|
|
203
167
|
}
|
|
204
168
|
}
|
package/src/browser/index.ts
CHANGED
|
@@ -55,8 +55,6 @@ import { RenameCandidatesProviderRegistry } from './contrib/rename/rename.featur
|
|
|
55
55
|
import { TerminalAIContribution } from './contrib/terminal/terminal-ai.contributon';
|
|
56
56
|
import { TerminalFeatureRegistry } from './contrib/terminal/terminal.feature.registry';
|
|
57
57
|
import { LanguageParserService } from './languages/service';
|
|
58
|
-
import { MCPConfigCommandContribution } from './mcp/config/mcp-config.commands';
|
|
59
|
-
import { MCPConfigContribution } from './mcp/config/mcp-config.contribution';
|
|
60
58
|
import { MCPServerProxyService } from './mcp/mcp-server-proxy.service';
|
|
61
59
|
import { MCPServerRegistry } from './mcp/mcp-server.feature.registry';
|
|
62
60
|
import { CreateNewFileWithTextTool } from './mcp/tools/createNewFileWithText';
|
|
@@ -93,8 +91,6 @@ export class AINativeModule extends BrowserModule {
|
|
|
93
91
|
AICodeActionContribution,
|
|
94
92
|
AINativePreferencesContribution,
|
|
95
93
|
IntelligentCompletionsContribution,
|
|
96
|
-
MCPConfigContribution,
|
|
97
|
-
MCPConfigCommandContribution,
|
|
98
94
|
|
|
99
95
|
// MCP Server Contributions START
|
|
100
96
|
ListDirTool,
|
|
@@ -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 {
|