@opensumi/ide-ai-native 3.8.1-next-1740571693.0 → 3.8.1-next-1740725107.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 +20 -1
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/chat/chat-manager.service.d.ts +6 -0
- package/lib/browser/chat/chat-manager.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-manager.service.js +31 -1
- package/lib/browser/chat/chat-manager.service.js.map +1 -1
- package/lib/browser/chat/chat-model.d.ts +2 -0
- package/lib/browser/chat/chat-model.d.ts.map +1 -1
- package/lib/browser/chat/chat-model.js +8 -2
- 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 +1 -2
- package/lib/browser/chat/chat.view.d.ts.map +1 -1
- package/lib/browser/chat/chat.view.js +6 -38
- 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 +25 -1
- 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 +2 -3
- 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 +20 -0
- package/lib/browser/context/llm-context.service.d.ts +16 -5
- package/lib/browser/context/llm-context.service.d.ts.map +1 -1
- package/lib/browser/context/llm-context.service.js +78 -47
- package/lib/browser/context/llm-context.service.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/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 +23 -3
- package/lib/browser/mcp/tools/createNewFileWithText.d.ts.map +1 -1
- package/lib/browser/mcp/tools/createNewFileWithText.js +1 -0
- 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 +1 -0
- 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 +2 -0
- 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 +1 -0
- 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/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/llm-context.d.ts +12 -9
- 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 +4 -3
- package/lib/common/prompts/context-prompt-provider.d.ts.map +1 -1
- package/lib/common/prompts/context-prompt-provider.js +34 -22
- package/lib/common/prompts/context-prompt-provider.js.map +1 -1
- package/lib/common/types.d.ts +17 -0
- package/lib/common/types.d.ts.map +1 -1
- package/lib/common/types.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/package.json +23 -23
- package/src/browser/ai-core.contribution.ts +25 -1
- package/src/browser/chat/chat-manager.service.ts +29 -1
- package/src/browser/chat/chat-model.ts +18 -3
- package/src/browser/chat/chat.internal.service.ts +4 -0
- package/src/browser/chat/chat.module.less +1 -2
- package/src/browser/chat/chat.view.tsx +7 -70
- package/src/browser/components/ChatContext/index.tsx +2 -2
- package/src/browser/components/ChatHistory.tsx +21 -15
- package/src/browser/components/ChatInput.tsx +67 -4
- package/src/browser/components/ChatToolRender.tsx +1 -2
- package/src/browser/components/{chat-history.css → chat-history.module.less} +1 -1
- package/src/browser/components/components.module.less +20 -0
- package/src/browser/context/llm-context.service.ts +90 -54
- package/src/browser/layout/layout.module.less +4 -4
- package/src/browser/mcp/base-apply.service.ts +266 -213
- package/src/browser/mcp/tools/components/EditFile.tsx +82 -60
- package/src/browser/mcp/tools/components/index.module.less +23 -3
- package/src/browser/mcp/tools/createNewFileWithText.ts +1 -0
- package/src/browser/mcp/tools/editFile.ts +2 -2
- package/src/browser/mcp/tools/getDiagnosticsByPath.ts +1 -0
- package/src/browser/mcp/tools/handlers/EditFile.ts +4 -4
- package/src/browser/mcp/tools/handlers/RunCommand.ts +2 -0
- package/src/browser/mcp/tools/runTerminalCmd.ts +1 -0
- package/src/browser/model/msg-history-manager.ts +12 -2
- 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/llm-context.ts +10 -4
- package/src/common/prompts/context-prompt-provider.ts +39 -29
- package/src/common/types.ts +20 -0
- package/src/node/base-language-model.ts +63 -1
|
@@ -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 { FileContext, LLMContextService, SerializedContext } from '../../common/llm-context';
|
|
15
|
+
import { AttachFileContext, FileContext, LLMContextService, SerializedContext } from '../../common/llm-context';
|
|
16
16
|
|
|
17
17
|
@Injectable()
|
|
18
18
|
export class LLMContextServiceImpl extends WithEventBus implements LLMContextService {
|
|
@@ -27,40 +27,65 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
|
|
|
27
27
|
|
|
28
28
|
private isAutoCollecting = false;
|
|
29
29
|
|
|
30
|
-
private
|
|
30
|
+
private readonly maxAttachFilesLimit = 10;
|
|
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;
|
|
31
36
|
|
|
32
|
-
private
|
|
37
|
+
private addFileToList(file: FileContext, list: FileContext[], maxLimit: number) {
|
|
38
|
+
const existingIndex = list.findIndex((f) => f.uri.toString() === file.uri.toString());
|
|
39
|
+
if (existingIndex > -1) {
|
|
40
|
+
list.splice(existingIndex, 1);
|
|
41
|
+
}
|
|
33
42
|
|
|
34
|
-
|
|
35
|
-
|
|
43
|
+
list.push(file);
|
|
44
|
+
if (list.length > maxLimit) {
|
|
45
|
+
list.shift();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
36
48
|
|
|
37
|
-
addFileToContext(uri: URI, selection?: [number, number], isManual =
|
|
38
|
-
|
|
49
|
+
addFileToContext(uri: URI, selection?: [number, number], isManual = false): void {
|
|
50
|
+
if (!uri) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
39
53
|
|
|
40
|
-
|
|
54
|
+
const file = { uri, selection };
|
|
55
|
+
const targetList = isManual ? this.attachedFiles : this.recentlyViewFiles;
|
|
56
|
+
const maxLimit = isManual ? this.maxAttachFilesLimit : this.maxViewFilesLimit;
|
|
41
57
|
|
|
42
|
-
if (
|
|
43
|
-
this.
|
|
58
|
+
if (isManual) {
|
|
59
|
+
this.docModelManager.createModelReference(uri);
|
|
44
60
|
}
|
|
45
61
|
|
|
62
|
+
this.addFileToList(file, targetList, maxLimit);
|
|
63
|
+
this.notifyContextChange();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private notifyContextChange(): void {
|
|
46
67
|
this.onDidContextFilesChangeEmitter.fire(this.getAllContextFiles());
|
|
47
68
|
}
|
|
48
69
|
|
|
49
70
|
cleanFileContext() {
|
|
50
|
-
this.
|
|
51
|
-
this.
|
|
71
|
+
this.attachedFiles.length = 0;
|
|
72
|
+
this.notifyContextChange();
|
|
52
73
|
}
|
|
53
74
|
|
|
54
75
|
private getAllContextFiles() {
|
|
55
|
-
return
|
|
76
|
+
return {
|
|
77
|
+
viewed: this.recentlyViewFiles,
|
|
78
|
+
attached: this.attachedFiles,
|
|
79
|
+
};
|
|
56
80
|
}
|
|
57
81
|
|
|
58
|
-
removeFileFromContext(uri: URI): void {
|
|
59
|
-
const
|
|
82
|
+
removeFileFromContext(uri: URI, isManual = false): void {
|
|
83
|
+
const targetList = isManual ? this.attachedFiles : this.recentlyViewFiles;
|
|
84
|
+
const index = targetList.findIndex((file) => file.uri.toString() === uri.toString());
|
|
60
85
|
if (index > -1) {
|
|
61
|
-
|
|
62
|
-
this.onDidContextFilesChangeEmitter.fire(this.getAllContextFiles());
|
|
86
|
+
targetList.splice(index, 1);
|
|
63
87
|
}
|
|
88
|
+
this.notifyContextChange();
|
|
64
89
|
}
|
|
65
90
|
|
|
66
91
|
startAutoCollection(): void {
|
|
@@ -78,8 +103,7 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
|
|
|
78
103
|
if (event.payload.uri.scheme !== 'file') {
|
|
79
104
|
return;
|
|
80
105
|
}
|
|
81
|
-
|
|
82
|
-
// this.addFileToContext(event.payload.uri);
|
|
106
|
+
this.addFileToContext(event.payload.uri, undefined, false);
|
|
83
107
|
}),
|
|
84
108
|
);
|
|
85
109
|
|
|
@@ -88,6 +112,8 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
|
|
|
88
112
|
if (event.payload.scheme !== 'file') {
|
|
89
113
|
return;
|
|
90
114
|
}
|
|
115
|
+
|
|
116
|
+
this.removeFileFromContext(event.payload, false);
|
|
91
117
|
}),
|
|
92
118
|
);
|
|
93
119
|
|
|
@@ -109,11 +135,12 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
|
|
|
109
135
|
].sort() as [number, number];
|
|
110
136
|
|
|
111
137
|
if (selection[0] === selection[1]) {
|
|
112
|
-
this.addFileToContext(event.payload.editorUri, undefined);
|
|
138
|
+
this.addFileToContext(event.payload.editorUri, undefined, false);
|
|
113
139
|
} else {
|
|
114
140
|
this.addFileToContext(
|
|
115
141
|
event.payload.editorUri,
|
|
116
142
|
selection.sort((a, b) => a - b),
|
|
143
|
+
false,
|
|
117
144
|
);
|
|
118
145
|
}
|
|
119
146
|
}
|
|
@@ -127,42 +154,51 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
|
|
|
127
154
|
|
|
128
155
|
serialize(): SerializedContext {
|
|
129
156
|
const files = this.getAllContextFiles();
|
|
130
|
-
const
|
|
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
|
-
})
|
|
139
|
-
.filter(Boolean);
|
|
140
|
-
|
|
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
|
-
};
|
|
160
|
-
})
|
|
161
|
-
.filter(Boolean);
|
|
157
|
+
const workspaceRoot = URI.file(this.appConfig.workspaceDir);
|
|
162
158
|
|
|
163
159
|
return {
|
|
164
|
-
recentlyViewFiles,
|
|
165
|
-
attachedFiles,
|
|
160
|
+
recentlyViewFiles: this.serializeRecentlyViewFiles(files.viewed, workspaceRoot),
|
|
161
|
+
attachedFiles: this.serializeAttachedFiles(files.attached, workspaceRoot),
|
|
166
162
|
};
|
|
167
163
|
}
|
|
164
|
+
|
|
165
|
+
private serializeRecentlyViewFiles(files: FileContext[], workspaceRoot: URI): string[] {
|
|
166
|
+
return files
|
|
167
|
+
.map((file) => workspaceRoot.relative(file.uri)?.toString() || file.uri.parent.toString())
|
|
168
|
+
.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
|
+
|
|
177
|
+
private serializeAttachedFile(file: FileContext, workspaceRoot: URI) {
|
|
178
|
+
try {
|
|
179
|
+
const ref = this.docModelManager.getModelReference(file.uri);
|
|
180
|
+
if (!ref) {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return {
|
|
185
|
+
content: ref.instance.getText(),
|
|
186
|
+
lineErrors: this.getFileErrors(file.uri),
|
|
187
|
+
path: workspaceRoot.relative(file.uri)!.toString(),
|
|
188
|
+
language: ref.instance.languageId!,
|
|
189
|
+
};
|
|
190
|
+
} catch (e) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
private getFileErrors(uri: URI): string[] {
|
|
196
|
+
return this.markerService
|
|
197
|
+
.getManager()
|
|
198
|
+
.getMarkers({
|
|
199
|
+
resource: uri.toString(),
|
|
200
|
+
severities: MarkerSeverity.Error,
|
|
201
|
+
})
|
|
202
|
+
.map((marker) => marker.message);
|
|
203
|
+
}
|
|
168
204
|
}
|
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
padding: 8px 12px;
|
|
15
15
|
min-width: initial;
|
|
16
16
|
margin: 0;
|
|
17
|
-
|
|
18
|
-
::after {
|
|
19
|
-
content: '';
|
|
20
|
-
}
|
|
21
17
|
}
|
|
22
18
|
|
|
23
19
|
.rce-mbox-text {
|
|
24
20
|
line-height: 18px;
|
|
25
21
|
width: inherit;
|
|
26
22
|
font-size: 12px;
|
|
23
|
+
|
|
24
|
+
&::after {
|
|
25
|
+
display: none;
|
|
26
|
+
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
.rce-smsg {
|