@opensumi/ide-ai-native 3.8.3-next-1741771971.0 → 3.8.3-next-1741772268.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/chat/chat-agent.service.d.ts +1 -1
- package/lib/browser/chat/chat-agent.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-agent.service.js +7 -7
- package/lib/browser/chat/chat-agent.service.js.map +1 -1
- package/lib/browser/chat/chat.view.d.ts.map +1 -1
- package/lib/browser/chat/chat.view.js +18 -55
- package/lib/browser/chat/chat.view.js.map +1 -1
- package/lib/browser/components/{chat-context/context-selector.d.ts → ChatContext/ContextSelector.d.ts} +1 -1
- package/lib/browser/components/ChatContext/ContextSelector.d.ts.map +1 -0
- package/lib/browser/components/{chat-context/context-selector.js → ChatContext/ContextSelector.js} +1 -1
- package/lib/browser/components/ChatContext/ContextSelector.js.map +1 -0
- package/lib/browser/components/ChatContext/index.d.ts.map +1 -0
- package/lib/browser/components/{chat-context → ChatContext}/index.js +2 -2
- package/lib/browser/components/ChatContext/index.js.map +1 -0
- package/lib/browser/components/ChatEditor.d.ts +2 -11
- package/lib/browser/components/ChatEditor.d.ts.map +1 -1
- package/lib/browser/components/ChatEditor.js +6 -66
- package/lib/browser/components/ChatEditor.js.map +1 -1
- package/lib/browser/components/ChatThinking.d.ts +1 -1
- package/lib/browser/components/ChatThinking.d.ts.map +1 -1
- package/lib/browser/components/ChatThinking.js +2 -8
- package/lib/browser/components/ChatThinking.js.map +1 -1
- package/lib/browser/components/change-list.module.less +0 -2
- package/lib/browser/components/components.module.less +2 -34
- package/lib/browser/context/llm-context.service.d.ts +2 -10
- package/lib/browser/context/llm-context.service.d.ts.map +1 -1
- package/lib/browser/context/llm-context.service.js +2 -71
- package/lib/browser/context/llm-context.service.js.map +1 -1
- package/lib/common/llm-context.d.ts +1 -15
- package/lib/common/llm-context.d.ts.map +1 -1
- package/lib/common/llm-context.js.map +1 -1
- package/lib/common/prompts/context-prompt-provider.d.ts +2 -12
- package/lib/common/prompts/context-prompt-provider.d.ts.map +1 -1
- package/lib/common/prompts/context-prompt-provider.js +30 -94
- package/lib/common/prompts/context-prompt-provider.js.map +1 -1
- package/lib/node/mcp-server.sse.d.ts.map +1 -1
- package/lib/node/mcp-server.sse.js +2 -2
- package/lib/node/mcp-server.sse.js.map +1 -1
- package/package.json +23 -23
- package/src/browser/chat/chat-agent.service.ts +7 -7
- package/src/browser/chat/chat.view.tsx +21 -74
- package/src/browser/components/{chat-context → ChatContext}/index.tsx +1 -1
- package/src/browser/components/ChatEditor.tsx +9 -126
- package/src/browser/components/ChatThinking.tsx +4 -10
- package/src/browser/components/change-list.module.less +0 -2
- package/src/browser/components/components.module.less +2 -34
- package/src/browser/context/llm-context.service.ts +3 -81
- package/src/common/llm-context.ts +1 -16
- package/src/common/prompts/context-prompt-provider.ts +36 -126
- package/src/node/mcp-server.sse.ts +2 -1
- package/lib/browser/components/ChatMentionInput.d.ts +0 -25
- package/lib/browser/components/ChatMentionInput.d.ts.map +0 -1
- package/lib/browser/components/ChatMentionInput.js +0 -221
- package/lib/browser/components/ChatMentionInput.js.map +0 -1
- package/lib/browser/components/chat-context/context-selector.d.ts.map +0 -1
- package/lib/browser/components/chat-context/context-selector.js.map +0 -1
- package/lib/browser/components/chat-context/index.d.ts.map +0 -1
- package/lib/browser/components/chat-context/index.js.map +0 -1
- package/lib/browser/components/mention-input/mention-input.d.ts +0 -5
- package/lib/browser/components/mention-input/mention-input.d.ts.map +0 -1
- package/lib/browser/components/mention-input/mention-input.js +0 -763
- package/lib/browser/components/mention-input/mention-input.js.map +0 -1
- package/lib/browser/components/mention-input/mention-input.module.less +0 -329
- package/lib/browser/components/mention-input/mention-item.d.ts +0 -10
- package/lib/browser/components/mention-input/mention-item.d.ts.map +0 -1
- package/lib/browser/components/mention-input/mention-item.js +0 -16
- package/lib/browser/components/mention-input/mention-item.js.map +0 -1
- package/lib/browser/components/mention-input/mention-panel.d.ts +0 -15
- package/lib/browser/components/mention-input/mention-panel.d.ts.map +0 -1
- package/lib/browser/components/mention-input/mention-panel.js +0 -49
- package/lib/browser/components/mention-input/mention-panel.js.map +0 -1
- package/lib/browser/components/mention-input/types.d.ts +0 -78
- package/lib/browser/components/mention-input/types.d.ts.map +0 -1
- package/lib/browser/components/mention-input/types.js +0 -16
- package/lib/browser/components/mention-input/types.js.map +0 -1
- package/src/browser/components/ChatMentionInput.tsx +0 -269
- package/src/browser/components/mention-input/mention-input.module.less +0 -329
- package/src/browser/components/mention-input/mention-input.tsx +0 -952
- package/src/browser/components/mention-input/mention-item.tsx +0 -24
- package/src/browser/components/mention-input/mention-panel.tsx +0 -89
- package/src/browser/components/mention-input/types.ts +0 -84
- /package/lib/browser/components/{chat-context → ChatContext}/index.d.ts +0 -0
- /package/lib/browser/components/{chat-context → ChatContext}/style.module.less +0 -0
- /package/src/browser/components/{chat-context/context-selector.tsx → ChatContext/ContextSelector.tsx} +0 -0
- /package/src/browser/components/{chat-context → ChatContext}/style.module.less +0 -0
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
height: 100%;
|
|
5
5
|
.stop {
|
|
6
6
|
position: absolute;
|
|
7
|
-
bottom: -
|
|
7
|
+
bottom: -38px;
|
|
8
8
|
padding-top: 12px;
|
|
9
|
-
left: -
|
|
9
|
+
left: -8px;
|
|
10
10
|
width: 105%;
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -519,7 +519,6 @@
|
|
|
519
519
|
display: flex;
|
|
520
520
|
font-size: 11px;
|
|
521
521
|
align-items: center;
|
|
522
|
-
min-width: 150px;
|
|
523
522
|
}
|
|
524
523
|
|
|
525
524
|
.mcp_desc {
|
|
@@ -566,34 +565,3 @@
|
|
|
566
565
|
color: var(--descriptionForeground);
|
|
567
566
|
}
|
|
568
567
|
}
|
|
569
|
-
|
|
570
|
-
.attachment {
|
|
571
|
-
display: inline-flex;
|
|
572
|
-
align-items: center;
|
|
573
|
-
padding: 0 4px;
|
|
574
|
-
margin: 0 2px;
|
|
575
|
-
background: var(--badge-background);
|
|
576
|
-
color: var(--badge-foreground);
|
|
577
|
-
border-radius: 3px;
|
|
578
|
-
vertical-align: middle;
|
|
579
|
-
font-size: 12px;
|
|
580
|
-
cursor: pointer;
|
|
581
|
-
opacity: 0.8;
|
|
582
|
-
:global {
|
|
583
|
-
.kt-icon {
|
|
584
|
-
font-size: 12px;
|
|
585
|
-
margin-right: 3px;
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
&:hover {
|
|
589
|
-
opacity: 1;
|
|
590
|
-
background-color: var(--chat-slashCommandBackground);
|
|
591
|
-
color: var(--chat-slashCommandForeground);
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
.attachment_text {
|
|
596
|
-
line-height: 20px;
|
|
597
|
-
vertical-align: middle;
|
|
598
|
-
font-size: 12px;
|
|
599
|
-
}
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
IEditorDocumentModelService,
|
|
11
11
|
} from '@opensumi/ide-editor/lib/browser/doc-model/types';
|
|
12
12
|
import { EditorSelectionChangeEvent } from '@opensumi/ide-editor/lib/browser/types';
|
|
13
|
-
import { FileType, IFileServiceClient } from '@opensumi/ide-file-service';
|
|
14
13
|
import { IMarkerService } from '@opensumi/ide-markers/lib/common/types';
|
|
15
14
|
import { Range } from '@opensumi/ide-monaco';
|
|
16
15
|
|
|
@@ -27,18 +26,13 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
|
|
|
27
26
|
@Autowired(IMarkerService)
|
|
28
27
|
protected readonly markerService: IMarkerService;
|
|
29
28
|
|
|
30
|
-
@Autowired(IFileServiceClient)
|
|
31
|
-
protected readonly fileService: IFileServiceClient;
|
|
32
|
-
|
|
33
29
|
private isAutoCollecting = false;
|
|
34
30
|
|
|
35
31
|
private contextVersion = 0;
|
|
36
32
|
|
|
37
33
|
private readonly maxAttachFilesLimit = 10;
|
|
38
|
-
private readonly maxAttachFoldersLimit = 10;
|
|
39
34
|
private readonly maxViewFilesLimit = 20;
|
|
40
|
-
private attachedFiles: FileContext[] = [];
|
|
41
|
-
private attachedFolders: FileContext[] = [];
|
|
35
|
+
private readonly attachedFiles: FileContext[] = [];
|
|
42
36
|
private readonly recentlyViewFiles: FileContext[] = [];
|
|
43
37
|
private readonly onDidContextFilesChangeEmitter = new Emitter<{
|
|
44
38
|
viewed: FileContext[];
|
|
@@ -59,18 +53,6 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
|
|
|
59
53
|
}
|
|
60
54
|
}
|
|
61
55
|
|
|
62
|
-
private addFolderToList(folder: FileContext, list: FileContext[], maxLimit: number) {
|
|
63
|
-
const existingIndex = list.findIndex((f) => f.uri.toString() === folder.uri.toString());
|
|
64
|
-
if (existingIndex > -1) {
|
|
65
|
-
list.splice(existingIndex, 1);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
list.push(folder);
|
|
69
|
-
if (list.length > maxLimit) {
|
|
70
|
-
list.shift();
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
56
|
addFileToContext(uri: URI, selection?: [number, number], isManual = false): void {
|
|
75
57
|
if (!uri) {
|
|
76
58
|
return;
|
|
@@ -88,24 +70,12 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
|
|
|
88
70
|
this.notifyContextChange();
|
|
89
71
|
}
|
|
90
72
|
|
|
91
|
-
addFolderToContext(uri: URI): void {
|
|
92
|
-
if (!uri) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const file = { uri };
|
|
97
|
-
|
|
98
|
-
this.addFolderToList(file, this.attachedFolders, this.maxAttachFoldersLimit);
|
|
99
|
-
this.notifyContextChange();
|
|
100
|
-
}
|
|
101
|
-
|
|
102
73
|
private notifyContextChange(): void {
|
|
103
74
|
this.onDidContextFilesChangeEmitter.fire(this.getAllContextFiles());
|
|
104
75
|
}
|
|
105
76
|
|
|
106
77
|
cleanFileContext() {
|
|
107
|
-
this.attachedFiles =
|
|
108
|
-
this.attachedFolders = [];
|
|
78
|
+
this.attachedFiles.length = 0;
|
|
109
79
|
this.notifyContextChange();
|
|
110
80
|
}
|
|
111
81
|
|
|
@@ -113,7 +83,6 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
|
|
|
113
83
|
return {
|
|
114
84
|
viewed: this.recentlyViewFiles,
|
|
115
85
|
attached: this.attachedFiles,
|
|
116
|
-
attachedFolders: this.attachedFolders,
|
|
117
86
|
version: this.contextVersion++,
|
|
118
87
|
};
|
|
119
88
|
}
|
|
@@ -191,63 +160,16 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
|
|
|
191
160
|
this.dispose();
|
|
192
161
|
}
|
|
193
162
|
|
|
194
|
-
|
|
163
|
+
serialize(): SerializedContext {
|
|
195
164
|
const files = this.getAllContextFiles();
|
|
196
165
|
const workspaceRoot = URI.file(this.appConfig.workspaceDir);
|
|
197
166
|
|
|
198
167
|
return {
|
|
199
168
|
recentlyViewFiles: this.serializeRecentlyViewFiles(files.viewed, workspaceRoot),
|
|
200
169
|
attachedFiles: this.serializeAttachedFiles(files.attached, workspaceRoot),
|
|
201
|
-
attachedFolders: await this.serializeAttachedFolders(files.attachedFolders, workspaceRoot),
|
|
202
170
|
};
|
|
203
171
|
}
|
|
204
172
|
|
|
205
|
-
private async serializeAttachedFolders(folders: FileContext[], workspaceRoot: URI): Promise<string[]> {
|
|
206
|
-
// 去重
|
|
207
|
-
const folderPath = Array.from(new Set(folders.map((folder) => folder.uri.toString())));
|
|
208
|
-
return Promise.all(
|
|
209
|
-
folderPath.map(async (folder) => {
|
|
210
|
-
const folderUri = new URI(folder);
|
|
211
|
-
const root = workspaceRoot.relative(folderUri)?.toString() || '/';
|
|
212
|
-
return `\`\`\`\n${root}\n${(await this.getPartiaFolderStructure(folderUri.codeUri.fsPath))
|
|
213
|
-
.map((line) => `- ${line}`)
|
|
214
|
-
.join('\n')}\n\`\`\`\n`;
|
|
215
|
-
}),
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
private async getPartiaFolderStructure(folder: string, level = 2): Promise<string[]> {
|
|
220
|
-
const result: string[] = [];
|
|
221
|
-
const stat = await this.fileService.getFileStat(folder);
|
|
222
|
-
|
|
223
|
-
for (const child of stat?.children || []) {
|
|
224
|
-
const relativePath = new URI(folder).relative(new URI(child.uri))!.toString();
|
|
225
|
-
|
|
226
|
-
if (child.isSymbolicLink) {
|
|
227
|
-
// 处理软链接
|
|
228
|
-
const target = await this.fileService.getFileStat(child.realUri || child.uri);
|
|
229
|
-
if (target) {
|
|
230
|
-
result.push(`${relativePath} -> ${target} (symbolic link)`);
|
|
231
|
-
} else {
|
|
232
|
-
result.push(`${relativePath} (broken symbolic link)`);
|
|
233
|
-
}
|
|
234
|
-
continue;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
if (child.type === FileType.Directory) {
|
|
238
|
-
result.push(`${relativePath}/`);
|
|
239
|
-
if (level > 1) {
|
|
240
|
-
const subDirStructure = await this.getPartiaFolderStructure(child.uri, level - 1);
|
|
241
|
-
result.push(...subDirStructure.map((subEntry) => `${relativePath}/${subEntry}`));
|
|
242
|
-
}
|
|
243
|
-
} else if (child.type === FileType.File) {
|
|
244
|
-
result.push(relativePath);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
return result;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
173
|
private serializeRecentlyViewFiles(files: FileContext[], workspaceRoot: URI): string[] {
|
|
252
174
|
return files
|
|
253
175
|
.map((file) => workspaceRoot.relative(file.uri)?.toString() || file.uri.parent.toString())
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import { Event, URI } from '@opensumi/ide-core-common/lib/utils';
|
|
2
2
|
|
|
3
3
|
export interface LLMContextService {
|
|
4
|
-
/**
|
|
5
|
-
* 开始自动收集
|
|
6
|
-
*/
|
|
7
4
|
startAutoCollection(): void;
|
|
8
5
|
|
|
9
|
-
/**
|
|
10
|
-
* 停止自动收集
|
|
11
|
-
*/
|
|
12
6
|
stopAutoCollection(): void;
|
|
13
7
|
|
|
14
8
|
/**
|
|
@@ -16,19 +10,11 @@ export interface LLMContextService {
|
|
|
16
10
|
*/
|
|
17
11
|
addFileToContext(uri: URI, selection?: [number, number], isManual?: boolean): void;
|
|
18
12
|
|
|
19
|
-
/**
|
|
20
|
-
* 添加文件夹到 context 中
|
|
21
|
-
*/
|
|
22
|
-
addFolderToContext(uri: URI, isManual?: boolean): void;
|
|
23
|
-
|
|
24
13
|
/**
|
|
25
14
|
* 清除上下文
|
|
26
15
|
*/
|
|
27
16
|
cleanFileContext(): void;
|
|
28
17
|
|
|
29
|
-
/**
|
|
30
|
-
* 上下文文件变化事件
|
|
31
|
-
*/
|
|
32
18
|
onDidContextFilesChangeEvent: Event<{ viewed: FileContext[]; attached: FileContext[]; version: number }>;
|
|
33
19
|
|
|
34
20
|
/**
|
|
@@ -38,7 +24,7 @@ export interface LLMContextService {
|
|
|
38
24
|
removeFileFromContext(uri: URI, isManual?: boolean): void;
|
|
39
25
|
|
|
40
26
|
/** 导出为可序列化格式 */
|
|
41
|
-
serialize():
|
|
27
|
+
serialize(): SerializedContext;
|
|
42
28
|
}
|
|
43
29
|
|
|
44
30
|
export interface FileContext {
|
|
@@ -58,5 +44,4 @@ export interface AttachFileContext {
|
|
|
58
44
|
export interface SerializedContext {
|
|
59
45
|
recentlyViewFiles: string[];
|
|
60
46
|
attachedFiles: Array<AttachFileContext>;
|
|
61
|
-
attachedFolders: string[];
|
|
62
47
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Autowired, Injectable } from '@opensumi/di';
|
|
2
2
|
import { WorkbenchEditorService } from '@opensumi/ide-editor/lib/common/editor';
|
|
3
|
-
import { IWorkspaceService } from '@opensumi/ide-workspace';
|
|
4
3
|
|
|
5
4
|
import { SerializedContext } from '../llm-context';
|
|
6
5
|
|
|
@@ -11,7 +10,7 @@ export interface ChatAgentPromptProvider {
|
|
|
11
10
|
* 提供上下文提示
|
|
12
11
|
* @param context 上下文
|
|
13
12
|
*/
|
|
14
|
-
provideContextPrompt(context: SerializedContext, userMessage: string):
|
|
13
|
+
provideContextPrompt(context: SerializedContext, userMessage: string): string;
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
@Injectable()
|
|
@@ -19,131 +18,42 @@ export class DefaultChatAgentPromptProvider implements ChatAgentPromptProvider {
|
|
|
19
18
|
@Autowired(WorkbenchEditorService)
|
|
20
19
|
protected readonly workbenchEditorService: WorkbenchEditorService;
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
protected readonly workspaceService: IWorkspaceService;
|
|
24
|
-
|
|
25
|
-
async provideContextPrompt(context: SerializedContext, userMessage: string) {
|
|
26
|
-
const currentFileInfo = await this.getCurrentFileInfo();
|
|
27
|
-
|
|
28
|
-
return this.buildPromptTemplate({
|
|
29
|
-
recentFiles: this.buildRecentFilesSection(context.recentlyViewFiles),
|
|
30
|
-
attachedFiles: this.buildAttachedFilesSection(context.attachedFiles),
|
|
31
|
-
attachedFolders: this.buildAttachedFoldersSection(context.attachedFolders),
|
|
32
|
-
currentFile: currentFileInfo,
|
|
33
|
-
userMessage,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
private async getCurrentFileInfo() {
|
|
21
|
+
provideContextPrompt(context: SerializedContext, userMessage: string): string {
|
|
38
22
|
const editor = this.workbenchEditorService.currentEditor;
|
|
39
23
|
const currentModel = editor?.currentDocumentModel;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
this.buildCurrentFileSection(currentFile),
|
|
75
|
-
'</additional_data>',
|
|
76
|
-
'<user_query>',
|
|
77
|
-
userMessage,
|
|
78
|
-
'</user_query>',
|
|
79
|
-
].filter(Boolean);
|
|
80
|
-
|
|
81
|
-
return sections.join('\n');
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
private buildRecentFilesSection(files: string[]): string {
|
|
85
|
-
if (!files.length) {
|
|
86
|
-
return '';
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return `<recently_viewed_files>
|
|
90
|
-
${files.map((file, idx) => ` ${idx + 1}: ${file}`).join('\n')}
|
|
91
|
-
</recently_viewed_files>`;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
private buildAttachedFilesSection(files: { path: string; content: string; lineErrors: string[] }[]): string {
|
|
95
|
-
if (!files.length) {
|
|
96
|
-
return '';
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const fileContents = files
|
|
100
|
-
.map((file) => {
|
|
101
|
-
const sections = [
|
|
102
|
-
this.buildFileContentSection(file),
|
|
103
|
-
file.lineErrors.length ? this.buildLineErrorsSection(file.lineErrors) : '',
|
|
104
|
-
].filter(Boolean);
|
|
105
|
-
|
|
106
|
-
return sections.join('\n');
|
|
107
|
-
})
|
|
108
|
-
.filter(Boolean)
|
|
109
|
-
.join('\n');
|
|
110
|
-
|
|
111
|
-
return `<attached_files>\n${fileContents}\n</attached_files>`;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
private buildFileContentSection(file: { path: string; content: string }): string {
|
|
115
|
-
return `<file_contents>
|
|
116
|
-
\`\`\`${file.path}
|
|
117
|
-
${file.content}
|
|
118
|
-
\`\`\`
|
|
119
|
-
</file_contents>`;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
private buildLineErrorsSection(errors: string[]): string {
|
|
123
|
-
if (!errors.length) {
|
|
124
|
-
return '';
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return `<linter_errors>\n${errors.join('\n')}\n</linter_errors>`;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
private buildAttachedFoldersSection(folders: string[]): string {
|
|
131
|
-
if (!folders.length) {
|
|
132
|
-
return '';
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return `<attached_folders>\n${folders.join('\n')}</attached_folders>`;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
private buildCurrentFileSection(fileInfo: { path: string; languageId: string; content: string } | null): string {
|
|
139
|
-
if (!fileInfo) {
|
|
140
|
-
return '';
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return `<current_opened_file>
|
|
144
|
-
\`\`\`${fileInfo.languageId} ${fileInfo.path}
|
|
145
|
-
${fileInfo.content}
|
|
146
|
-
\`\`\`
|
|
147
|
-
</current_opened_file>`;
|
|
24
|
+
return `
|
|
25
|
+
<additional_data>
|
|
26
|
+
Below are some potentially helpful/relevant pieces of information for figuring out to respond
|
|
27
|
+
<recently_viewed_files>
|
|
28
|
+
${context.recentlyViewFiles.map((file, idx) => ` ${idx + 1}: ${file}`).join('\n')}
|
|
29
|
+
</recently_viewed_files>
|
|
30
|
+
<attached_files>
|
|
31
|
+
${context.attachedFiles.map(
|
|
32
|
+
(file) =>
|
|
33
|
+
`
|
|
34
|
+
<file_contents>
|
|
35
|
+
\`\`\`${file.path}
|
|
36
|
+
${file.content}
|
|
37
|
+
\`\`\`
|
|
38
|
+
</file_contents>
|
|
39
|
+
<linter_errors>
|
|
40
|
+
${file.lineErrors.join('\n')}
|
|
41
|
+
</linter_errors>
|
|
42
|
+
`,
|
|
43
|
+
)}
|
|
44
|
+
</attached_files>
|
|
45
|
+
${
|
|
46
|
+
currentModel
|
|
47
|
+
? `<current_opened_file>
|
|
48
|
+
\`\`\`${currentModel.languageId} ${currentModel.uri.toString()}
|
|
49
|
+
${currentModel.getText()}
|
|
50
|
+
\`\`\`
|
|
51
|
+
</current_opened_file>`
|
|
52
|
+
: ''
|
|
53
|
+
}
|
|
54
|
+
</additional_data>
|
|
55
|
+
<user_query>
|
|
56
|
+
${userMessage}
|
|
57
|
+
</user_query>`;
|
|
148
58
|
}
|
|
149
59
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// have to import with extension since the exports map is ./* -> ./dist/cjs/*
|
|
2
2
|
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
3
|
-
import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';
|
|
4
3
|
import { EventSource } from 'eventsource';
|
|
5
4
|
|
|
6
5
|
import { ILogger } from '@opensumi/ide-core-common';
|
|
@@ -34,6 +33,8 @@ export class SSEMCPServer implements IMCPServer {
|
|
|
34
33
|
}
|
|
35
34
|
this.logger?.log(`Starting server "${this.name}" with serverHost: ${this.serverHost}`);
|
|
36
35
|
|
|
36
|
+
const SSEClientTransport = (await import('@modelcontextprotocol/sdk/client/sse.js')).SSEClientTransport;
|
|
37
|
+
|
|
37
38
|
const transport = new SSEClientTransport(new URL(this.serverHost));
|
|
38
39
|
transport.onerror = (error) => {
|
|
39
40
|
this.logger?.error('Transport Error:', error);
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export interface IChatMentionInputProps {
|
|
3
|
-
onSend: (value: string, agentId?: string, command?: string, option?: {
|
|
4
|
-
model: string;
|
|
5
|
-
[key: string]: any;
|
|
6
|
-
}) => void;
|
|
7
|
-
onValueChange?: (value: string) => void;
|
|
8
|
-
onExpand?: (value: boolean) => void;
|
|
9
|
-
placeholder?: string;
|
|
10
|
-
enableOptions?: boolean;
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
sendBtnClassName?: string;
|
|
13
|
-
defaultHeight?: number;
|
|
14
|
-
value?: string;
|
|
15
|
-
autoFocus?: boolean;
|
|
16
|
-
theme?: string | null;
|
|
17
|
-
setTheme: (theme: string | null) => void;
|
|
18
|
-
agentId: string;
|
|
19
|
-
setAgentId: (id: string) => void;
|
|
20
|
-
defaultAgentId?: string;
|
|
21
|
-
command: string;
|
|
22
|
-
setCommand: (command: string) => void;
|
|
23
|
-
}
|
|
24
|
-
export declare const ChatMentionInput: React.ForwardRefExoticComponent<IChatMentionInputProps & React.RefAttributes<unknown>>;
|
|
25
|
-
//# sourceMappingURL=ChatMentionInput.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ChatMentionInput.d.ts","sourceRoot":"","sources":["../../../src/browser/components/ChatMentionInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAkBzE,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,KAAK,IAAI,CAAC;IACpH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC;AAGD,eAAO,MAAM,gBAAgB,wFAqO3B,CAAC"}
|