@opensumi/ide-ai-native 3.8.3-next-1741767755.0 → 3.8.3-next-1741769014.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.
Files changed (74) hide show
  1. package/lib/browser/chat/chat-agent.service.d.ts +1 -1
  2. package/lib/browser/chat/chat-agent.service.d.ts.map +1 -1
  3. package/lib/browser/chat/chat-agent.service.js +7 -7
  4. package/lib/browser/chat/chat-agent.service.js.map +1 -1
  5. package/lib/browser/chat/chat.view.d.ts.map +1 -1
  6. package/lib/browser/chat/chat.view.js +18 -52
  7. package/lib/browser/chat/chat.view.js.map +1 -1
  8. package/lib/browser/components/{chat-context/context-selector.d.ts → ChatContext/ContextSelector.d.ts} +1 -1
  9. package/lib/browser/components/ChatContext/ContextSelector.d.ts.map +1 -0
  10. package/lib/browser/components/{chat-context/context-selector.js → ChatContext/ContextSelector.js} +1 -1
  11. package/lib/browser/components/ChatContext/ContextSelector.js.map +1 -0
  12. package/lib/browser/components/ChatContext/index.d.ts.map +1 -0
  13. package/lib/browser/components/{chat-context → ChatContext}/index.js +2 -2
  14. package/lib/browser/components/ChatContext/index.js.map +1 -0
  15. package/lib/browser/components/ChatEditor.d.ts +2 -11
  16. package/lib/browser/components/ChatEditor.d.ts.map +1 -1
  17. package/lib/browser/components/ChatEditor.js +6 -66
  18. package/lib/browser/components/ChatEditor.js.map +1 -1
  19. package/lib/browser/components/components.module.less +0 -25
  20. package/lib/browser/context/llm-context.service.d.ts +2 -10
  21. package/lib/browser/context/llm-context.service.d.ts.map +1 -1
  22. package/lib/browser/context/llm-context.service.js +2 -71
  23. package/lib/browser/context/llm-context.service.js.map +1 -1
  24. package/lib/common/llm-context.d.ts +1 -15
  25. package/lib/common/llm-context.d.ts.map +1 -1
  26. package/lib/common/llm-context.js.map +1 -1
  27. package/lib/common/prompts/context-prompt-provider.d.ts +2 -12
  28. package/lib/common/prompts/context-prompt-provider.d.ts.map +1 -1
  29. package/lib/common/prompts/context-prompt-provider.js +30 -94
  30. package/lib/common/prompts/context-prompt-provider.js.map +1 -1
  31. package/package.json +23 -23
  32. package/src/browser/chat/chat-agent.service.ts +7 -7
  33. package/src/browser/chat/chat.view.tsx +21 -72
  34. package/src/browser/components/{chat-context → ChatContext}/index.tsx +1 -1
  35. package/src/browser/components/ChatEditor.tsx +9 -126
  36. package/src/browser/components/components.module.less +0 -25
  37. package/src/browser/context/llm-context.service.ts +3 -81
  38. package/src/common/llm-context.ts +1 -16
  39. package/src/common/prompts/context-prompt-provider.ts +36 -126
  40. package/lib/browser/components/ChatMentionInput.d.ts +0 -25
  41. package/lib/browser/components/ChatMentionInput.d.ts.map +0 -1
  42. package/lib/browser/components/ChatMentionInput.js +0 -221
  43. package/lib/browser/components/ChatMentionInput.js.map +0 -1
  44. package/lib/browser/components/chat-context/context-selector.d.ts.map +0 -1
  45. package/lib/browser/components/chat-context/context-selector.js.map +0 -1
  46. package/lib/browser/components/chat-context/index.d.ts.map +0 -1
  47. package/lib/browser/components/chat-context/index.js.map +0 -1
  48. package/lib/browser/components/mention-input/mention-input.d.ts +0 -5
  49. package/lib/browser/components/mention-input/mention-input.d.ts.map +0 -1
  50. package/lib/browser/components/mention-input/mention-input.js +0 -753
  51. package/lib/browser/components/mention-input/mention-input.js.map +0 -1
  52. package/lib/browser/components/mention-input/mention-input.module.less +0 -328
  53. package/lib/browser/components/mention-input/mention-item.d.ts +0 -10
  54. package/lib/browser/components/mention-input/mention-item.d.ts.map +0 -1
  55. package/lib/browser/components/mention-input/mention-item.js +0 -16
  56. package/lib/browser/components/mention-input/mention-item.js.map +0 -1
  57. package/lib/browser/components/mention-input/mention-panel.d.ts +0 -15
  58. package/lib/browser/components/mention-input/mention-panel.d.ts.map +0 -1
  59. package/lib/browser/components/mention-input/mention-panel.js +0 -49
  60. package/lib/browser/components/mention-input/mention-panel.js.map +0 -1
  61. package/lib/browser/components/mention-input/types.d.ts +0 -76
  62. package/lib/browser/components/mention-input/types.d.ts.map +0 -1
  63. package/lib/browser/components/mention-input/types.js +0 -16
  64. package/lib/browser/components/mention-input/types.js.map +0 -1
  65. package/src/browser/components/ChatMentionInput.tsx +0 -268
  66. package/src/browser/components/mention-input/mention-input.module.less +0 -328
  67. package/src/browser/components/mention-input/mention-input.tsx +0 -943
  68. package/src/browser/components/mention-input/mention-item.tsx +0 -24
  69. package/src/browser/components/mention-input/mention-panel.tsx +0 -89
  70. package/src/browser/components/mention-input/types.ts +0 -82
  71. /package/lib/browser/components/{chat-context → ChatContext}/index.d.ts +0 -0
  72. /package/lib/browser/components/{chat-context → ChatContext}/style.module.less +0 -0
  73. /package/src/browser/components/{chat-context/context-selector.tsx → ChatContext/ContextSelector.tsx} +0 -0
  74. /package/src/browser/components/{chat-context → ChatContext}/style.module.less +0 -0
@@ -1,268 +0,0 @@
1
- import React, { useCallback, useEffect, useMemo, useState } from 'react';
2
-
3
- import { LabelService, RecentFilesManager, useInjectable } from '@opensumi/ide-core-browser';
4
- import { getIcon } from '@opensumi/ide-core-browser/lib/components';
5
- import { URI, localize } from '@opensumi/ide-core-common';
6
- import { CommandService } from '@opensumi/ide-core-common/lib/command';
7
- import { WorkbenchEditorService } from '@opensumi/ide-editor';
8
- import { FileSearchServicePath, IFileSearchService } from '@opensumi/ide-file-search';
9
- import { IWorkspaceService } from '@opensumi/ide-workspace';
10
-
11
- import { IChatInternalService } from '../../common';
12
- import { ChatInternalService } from '../chat/chat.internal.service';
13
- import { OPEN_MCP_CONFIG_COMMAND } from '../mcp/config/mcp-config.commands';
14
-
15
- import styles from './components.module.less';
16
- import { MentionInput } from './mention-input/mention-input';
17
- import { FooterButtonPosition, FooterConfig, MentionItem, MentionType } from './mention-input/types';
18
-
19
- export interface IChatMentionInputProps {
20
- onSend: (value: string, agentId?: string, command?: string, option?: { model: string; [key: string]: any }) => void;
21
- onValueChange?: (value: string) => void;
22
- onExpand?: (value: boolean) => void;
23
- placeholder?: string;
24
- enableOptions?: boolean;
25
- disabled?: boolean;
26
- sendBtnClassName?: string;
27
- defaultHeight?: number;
28
- value?: string;
29
- autoFocus?: boolean;
30
- theme?: string | null;
31
- setTheme: (theme: string | null) => void;
32
- agentId: string;
33
- setAgentId: (id: string) => void;
34
- defaultAgentId?: string;
35
- command: string;
36
- setCommand: (command: string) => void;
37
- }
38
-
39
- // 指令命令激活组件
40
- export const ChatMentionInput = React.forwardRef((props: IChatMentionInputProps) => {
41
- const { onSend, disabled = false } = props;
42
-
43
- const [value, setValue] = useState(props.value || '');
44
- const aiChatService = useInjectable<ChatInternalService>(IChatInternalService);
45
- const commandService = useInjectable<CommandService>(CommandService);
46
- const searchService = useInjectable<IFileSearchService>(FileSearchServicePath);
47
- const recentFilesManager = useInjectable<RecentFilesManager>(RecentFilesManager);
48
- const workspaceService = useInjectable<IWorkspaceService>(IWorkspaceService);
49
- const editorService = useInjectable<WorkbenchEditorService>(WorkbenchEditorService);
50
- const labelService = useInjectable<LabelService>(LabelService);
51
-
52
- const handleShowMCPConfig = React.useCallback(() => {
53
- commandService.executeCommand(OPEN_MCP_CONFIG_COMMAND.id);
54
- }, [commandService]);
55
-
56
- useEffect(() => {
57
- if (props.value !== value) {
58
- setValue(props.value || '');
59
- }
60
- }, [props.value]);
61
-
62
- // 默认菜单项
63
- const defaultMenuItems: MentionItem[] = [
64
- // {
65
- // id: 'code',
66
- // type: 'code',
67
- // text: 'Code',
68
- // icon: getIcon('codebraces'),
69
- // getHighestLevelItems: () => [],
70
- // getItems: async (searchText: string) => {
71
- // const currentEditor = editorService.currentEditor;
72
- // if (!currentEditor) {
73
- // return [];
74
- // }
75
- // const currentDocumentModel = currentEditor.currentDocumentModel;
76
- // if (!currentDocumentModel) {
77
- // return [];
78
- // }
79
- // const symbols = await commandService.executeCommand('_executeFormatDocumentProvider', currentDocumentModel.uri.codeUri);
80
- // return [];
81
- // },
82
- // },
83
- {
84
- id: MentionType.FILE,
85
- type: MentionType.FILE,
86
- text: 'File',
87
- icon: getIcon('file'),
88
- getHighestLevelItems: () => {
89
- const currentEditor = editorService.currentEditor;
90
- const currentUri = currentEditor?.currentUri;
91
- if (!currentUri) {
92
- return [];
93
- }
94
- return [
95
- {
96
- id: currentUri.codeUri.fsPath,
97
- type: MentionType.FILE,
98
- text: currentUri.displayName,
99
- value: currentUri.codeUri.fsPath,
100
- description: `(${localize('aiNative.chat.defaultContextFile')})`,
101
- contextId: currentUri.codeUri.fsPath,
102
- icon: labelService.getIcon(currentUri),
103
- },
104
- ];
105
- },
106
- getItems: async (searchText: string) => {
107
- if (!searchText) {
108
- const recentFile = await recentFilesManager.getMostRecentlyOpenedFiles();
109
- return Promise.all(
110
- recentFile.map(async (file) => {
111
- const uri = new URI(file);
112
- return {
113
- id: uri.codeUri.fsPath,
114
- type: MentionType.FILE,
115
- text: uri.displayName,
116
- value: uri.codeUri.fsPath,
117
- description: (await workspaceService.asRelativePath(uri.parent))?.path || '',
118
- contextId: uri.codeUri.fsPath,
119
- icon: labelService.getIcon(uri),
120
- };
121
- }),
122
- );
123
- } else {
124
- const rootUris = (await workspaceService.roots).map((root) => new URI(root.uri).codeUri.fsPath.toString());
125
- const results = await searchService.find(searchText, {
126
- rootUris,
127
- useGitIgnore: true,
128
- noIgnoreParent: true,
129
- fuzzyMatch: true,
130
- limit: 10,
131
- });
132
- return Promise.all(
133
- results.map(async (file) => {
134
- const uri = new URI(file);
135
- return {
136
- id: uri.codeUri.fsPath,
137
- type: MentionType.FILE,
138
- text: uri.displayName,
139
- value: uri.codeUri.fsPath,
140
- description: (await workspaceService.asRelativePath(uri.parent))?.path || '',
141
- contextId: uri.codeUri.fsPath,
142
- icon: labelService.getIcon(uri),
143
- };
144
- }),
145
- );
146
- }
147
- },
148
- },
149
- {
150
- id: MentionType.FOLDER,
151
- type: MentionType.FOLDER,
152
- text: 'Folder',
153
- icon: getIcon('folder'),
154
- getHighestLevelItems: () => {
155
- const currentEditor = editorService.currentEditor;
156
- const currentFolderUri = currentEditor?.currentUri?.parent;
157
- if (!currentFolderUri) {
158
- return [];
159
- }
160
- return [
161
- {
162
- id: currentFolderUri.codeUri.fsPath,
163
- type: MentionType.FOLDER,
164
- text: currentFolderUri.displayName,
165
- value: currentFolderUri.codeUri.fsPath,
166
- description: `(${localize('aiNative.chat.defaultContextFolder')})`,
167
- contextId: currentFolderUri.codeUri.fsPath,
168
- icon: getIcon('folder'),
169
- },
170
- ];
171
- },
172
- getItems: async (searchText: string) => {
173
- if (!searchText) {
174
- const recentFile = await recentFilesManager.getMostRecentlyOpenedFiles();
175
- const recentFolder = Array.from(new Set(recentFile.map((file) => new URI(file).parent.codeUri.fsPath)));
176
- return Promise.all(
177
- recentFolder.map(async (folder) => {
178
- const uri = new URI(folder);
179
- const relativePath = await workspaceService.asRelativePath(uri);
180
- return {
181
- id: uri.codeUri.fsPath,
182
- type: MentionType.FOLDER,
183
- text: uri.displayName,
184
- value: uri.codeUri.fsPath,
185
- description: relativePath?.root ? relativePath.path : '',
186
- contextId: uri.codeUri.fsPath,
187
- icon: getIcon('folder'),
188
- };
189
- }),
190
- );
191
- } else {
192
- const rootUris = (await workspaceService.roots).map((root) => new URI(root.uri).codeUri.fsPath.toString());
193
- const results = await searchService.find(searchText, {
194
- rootUris,
195
- useGitIgnore: true,
196
- noIgnoreParent: true,
197
- fuzzyMatch: true,
198
- limit: 10,
199
- onlyFolders: true,
200
- });
201
- return Promise.all(
202
- results.map(async (folder) => {
203
- const uri = new URI(folder);
204
- return {
205
- id: uri.codeUri.fsPath,
206
- type: MentionType.FOLDER,
207
- text: uri.displayName,
208
- value: uri.codeUri.fsPath,
209
- description: (await workspaceService.asRelativePath(uri.parent))?.path || '',
210
- contextId: uri.codeUri.fsPath,
211
- icon: getIcon('folder'),
212
- };
213
- }),
214
- );
215
- }
216
- },
217
- },
218
- ];
219
-
220
- const defaultMentionInputFooterOptions: FooterConfig = useMemo(
221
- () => ({
222
- modelOptions: [
223
- { label: 'QWQ 32B', value: 'qwq-32b' },
224
- { label: 'DeepSeek R1', value: 'deepseek-r1' },
225
- ],
226
- defaultModel: 'deepseek-r1',
227
- buttons: [
228
- {
229
- id: 'mcp-server',
230
- icon: 'mcp',
231
- title: 'MCP Server',
232
- onClick: handleShowMCPConfig,
233
- position: FooterButtonPosition.LEFT,
234
- },
235
- ],
236
- showModelSelector: true,
237
- }),
238
- [handleShowMCPConfig],
239
- );
240
-
241
- const handleStop = useCallback(() => {
242
- aiChatService.cancelRequest();
243
- }, []);
244
-
245
- const handleSend = useCallback(
246
- async (content: string, option?: { model: string; [key: string]: any }) => {
247
- if (disabled) {
248
- return;
249
- }
250
- onSend(content, undefined, undefined, option);
251
- },
252
- [onSend, editorService, disabled],
253
- );
254
-
255
- return (
256
- <div className={styles.chat_input_container}>
257
- <MentionInput
258
- mentionItems={defaultMenuItems}
259
- onSend={handleSend}
260
- onStop={handleStop}
261
- loading={disabled}
262
- labelService={labelService}
263
- placeholder={localize('aiNative.chat.input.placeholder.default')}
264
- footerConfig={defaultMentionInputFooterOptions}
265
- />
266
- </div>
267
- );
268
- });
@@ -1,328 +0,0 @@
1
- .input_container {
2
- position: relative;
3
- width: 100%;
4
- margin: 0 auto;
5
- border-radius: 4px;
6
-
7
- .model_selector {
8
- margin-right: 5px;
9
- }
10
-
11
- .editor_area {
12
- position: relative;
13
- padding: 0 15px;
14
- min-height: 42px;
15
- max-height: 105px;
16
- }
17
-
18
- .editor {
19
- width: 100%;
20
- background-color: transparent;
21
- border: none;
22
- font-size: 14px;
23
- line-height: 1.5;
24
- outline: none;
25
- resize: none;
26
- min-height: 24px;
27
- max-height: 120px;
28
- overflow-y: auto;
29
- border-radius: 4px;
30
- word-break: break-word;
31
-
32
- .mention_tag {
33
- margin: 0 2px;
34
- vertical-align: middle;
35
- }
36
- }
37
-
38
- .editor:empty:before,
39
- .editor[data-content=''] + .editor:before {
40
- content: attr(data-placeholder);
41
- color: var(--descriptionForeground);
42
- pointer-events: none;
43
- display: block;
44
- }
45
-
46
- .ai_enhance_icon {
47
- border-radius: 6px;
48
- padding: 2px 3px;
49
- display: flex;
50
- align-items: center;
51
- cursor: pointer;
52
- text-wrap: nowrap;
53
- white-space: nowrap;
54
- box-sizing: border-box;
55
-
56
- span {
57
- color: var(--design-text-foreground);
58
- }
59
-
60
- &:hover {
61
- background-color: var(--badge-background);
62
-
63
- span {
64
- color: var(--badge-foreground);
65
- }
66
- }
67
-
68
- > span {
69
- &::before {
70
- font-size: 14px;
71
- }
72
- }
73
- }
74
-
75
- .footer {
76
- padding: 12px 15px;
77
- display: flex;
78
- justify-content: flex-start;
79
- align-items: center;
80
- flex-direction: row;
81
-
82
- .left_control {
83
- display: flex;
84
- align-items: center;
85
- justify-content: flex-start;
86
- flex-direction: row;
87
- flex: 1;
88
- }
89
-
90
- .right_control {
91
- display: flex;
92
- align-items: center;
93
- justify-content: flex-end;
94
- flex-direction: row;
95
-
96
- .send_logo,
97
- .stop_logo {
98
- background-color: var(--badge-background);
99
- color: var(--badge-foreground);
100
-
101
- &:hover {
102
- background-color: var(--kt-primaryButton-background);
103
-
104
- .send_logo_icon,
105
- .stop_logo_icon {
106
- color: var(--kt-primaryButton-foreground);
107
- }
108
- }
109
- }
110
- }
111
- }
112
-
113
- .send_button {
114
- color: var(--icon-foreground);
115
- border: none;
116
- border-radius: 4px;
117
- padding: 6px 12px;
118
- cursor: pointer;
119
- display: flex;
120
- align-items: center;
121
- justify-content: center;
122
- transition: background-color 0.2s;
123
- }
124
-
125
- .send_button:hover {
126
- background-color: var(--notification-success-background);
127
- }
128
- }
129
-
130
- .mention_panel_container {
131
- position: absolute;
132
- top: -20px;
133
- left: 0;
134
- right: 0;
135
- width: 100%;
136
- z-index: 1000;
137
- transform: translateY(-100%);
138
- display: flex;
139
- justify-content: center;
140
- }
141
-
142
- .mention_panel {
143
- background-color: var(--editor-background);
144
- color: var(--editor-foreground);
145
- border-radius: 6px;
146
- max-height: 300px;
147
- overflow-y: auto;
148
- z-index: 1000;
149
- padding: 8px 4px;
150
- width: 100%;
151
- }
152
-
153
- .mention_item {
154
- padding: 0 8px;
155
- border-radius: 8px;
156
- cursor: pointer;
157
- line-height: 22px;
158
- height: 22px;
159
- display: flex;
160
- align-items: center;
161
- transition: all 0.2s ease;
162
- justify-content: space-between;
163
- color: var(--foreground);
164
- border-radius: 4px;
165
- margin-bottom: 5px;
166
-
167
- &:last-child {
168
- margin-bottom: 0;
169
- }
170
- }
171
-
172
- .mention_list {
173
- margin: 0;
174
- padding: 0;
175
- list-style: none;
176
- }
177
-
178
- .mention_item.active {
179
- color: var(--kt-tree-inactiveSelectionForeground);
180
- background: var(--kt-tree-inactiveSelectionBackground);
181
- }
182
-
183
- .mention_item:hover:not(.active) {
184
- color: var(--kt-tree-inactiveSelectionForeground);
185
- background: var(--kt-tree-inactiveSelectionBackground);
186
- }
187
-
188
- .mention_item_left {
189
- display: flex;
190
- align-items: center;
191
- flex: 1;
192
- }
193
-
194
- .mention_item_icon {
195
- margin-right: 8px;
196
- width: 18px;
197
- height: 18px;
198
- display: flex;
199
- align-items: center;
200
- justify-content: center;
201
- }
202
-
203
- .mention_item_text {
204
- font-size: 13px;
205
- margin-right: 6px;
206
- display: inline;
207
- white-space: pre;
208
- }
209
-
210
- .mention_item_description {
211
- color: var(--descriptionForeground);
212
- font-size: 13px;
213
- display: inline;
214
- flex: 1;
215
- text-overflow: ellipsis;
216
- overflow: hidden;
217
- white-space: nowrap;
218
- margin-left: 5px;
219
- text-align: right;
220
- }
221
-
222
- .mention_item_right {
223
- color: #8b949e;
224
- font-size: 12px;
225
- }
226
-
227
- .mention_panel_title {
228
- padding: 8px 12px;
229
- font-size: 12px;
230
- display: flex;
231
- justify-content: space-between;
232
- align-items: center;
233
- }
234
-
235
- .back_button {
236
- background: none;
237
- border: none;
238
- cursor: pointer;
239
- font-size: 12px;
240
- display: flex;
241
- align-items: center;
242
- }
243
-
244
- .back_button:hover {
245
- text-decoration: underline;
246
- }
247
-
248
- .mention_tag {
249
- background-color: var(--chat-slashCommandBackground);
250
- color: var(--chat-slashCommandForeground);
251
- border-radius: 4px;
252
- padding: 0 4px;
253
- margin: 0 3px;
254
- user-select: all;
255
- cursor: default;
256
- display: inline-flex;
257
- align-items: center;
258
- justify-content: center;
259
- }
260
-
261
- .mention_icon {
262
- display: inline-flex;
263
- align-items: center;
264
- justify-content: center;
265
- margin-right: 3px;
266
- }
267
-
268
- .empty_state {
269
- padding: 5px 10px;
270
- text-align: center;
271
- color: var(--descriptionForeground);
272
- font-size: 14px;
273
- }
274
-
275
- .model_selector {
276
- margin-right: 5px;
277
- }
278
-
279
- .mcp_logo {
280
- margin-right: 5px;
281
- }
282
-
283
- .send_logo {
284
- color: var(--icon-foreground);
285
- cursor: pointer;
286
- margin-left: auto;
287
-
288
- &:hover {
289
- color: var(--notification-success-foreground);
290
- }
291
- }
292
-
293
- .popover_icon {
294
- // 移除 margin-left: auto
295
- }
296
-
297
- .loading_container {
298
- display: none;
299
- }
300
-
301
- .loading_bar {
302
- position: absolute;
303
- top: 0;
304
- left: 0;
305
- height: 2px;
306
- width: 100%;
307
- background: linear-gradient(90deg, transparent, var(--kt-primaryButton-background), transparent);
308
- background-size: 200% 100%;
309
- animation: loading-bar 1.5s infinite;
310
- z-index: 10;
311
- }
312
-
313
- @keyframes loading-bar {
314
- 0% {
315
- background-position: 100% 0;
316
- }
317
-
318
- 100% {
319
- background-position: -100% 0;
320
- }
321
- }
322
-
323
- .no_results {
324
- padding: 12px;
325
- text-align: center;
326
- color: #666;
327
- font-style: italic;
328
- }