@opensumi/ide-ai-native 3.8.3-next-1741763229.0 → 3.8.3-next-1741763277.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 -49
- 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 -5
- package/lib/browser/components/ChatEditor.d.ts.map +1 -1
- package/lib/browser/components/ChatEditor.js +6 -45
- package/lib/browser/components/ChatEditor.js.map +1 -1
- package/lib/browser/components/components.module.less +0 -19
- 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/package.json +23 -23
- package/src/browser/chat/chat-agent.service.ts +7 -7
- package/src/browser/chat/chat.view.tsx +20 -63
- package/src/browser/components/{chat-context → ChatContext}/index.tsx +1 -1
- package/src/browser/components/ChatEditor.tsx +9 -72
- package/src/browser/components/components.module.less +0 -19
- 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/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 -753
- package/lib/browser/components/mention-input/mention-input.js.map +0 -1
- package/lib/browser/components/mention-input/mention-input.module.less +0 -327
- 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 -76
- 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 -268
- package/src/browser/components/mention-input/mention-input.module.less +0 -327
- package/src/browser/components/mention-input/mention-input.tsx +0 -943
- 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 -82
- /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
|
@@ -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,21 +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
|
-
}
|
|
581
|
-
|
|
582
|
-
.attachment_text {
|
|
583
|
-
line-height: 20px;
|
|
584
|
-
vertical-align: middle;
|
|
585
|
-
font-size: 12px;
|
|
586
|
-
}
|
|
@@ -2,21 +2,17 @@ import { AppConfig } from '@opensumi/ide-core-browser/lib/react-providers/config
|
|
|
2
2
|
import { WithEventBus } from '@opensumi/ide-core-common/lib/event-bus/event-decorator';
|
|
3
3
|
import { URI } from '@opensumi/ide-core-common/lib/utils';
|
|
4
4
|
import { IEditorDocumentModelService } from '@opensumi/ide-editor/lib/browser/doc-model/types';
|
|
5
|
-
import { IFileServiceClient } from '@opensumi/ide-file-service';
|
|
6
5
|
import { IMarkerService } from '@opensumi/ide-markers/lib/common/types';
|
|
7
6
|
import { FileContext, LLMContextService, SerializedContext } from '../../common/llm-context';
|
|
8
7
|
export declare class LLMContextServiceImpl extends WithEventBus implements LLMContextService {
|
|
9
8
|
protected readonly appConfig: AppConfig;
|
|
10
9
|
protected readonly docModelManager: IEditorDocumentModelService;
|
|
11
10
|
protected readonly markerService: IMarkerService;
|
|
12
|
-
protected readonly fileService: IFileServiceClient;
|
|
13
11
|
private isAutoCollecting;
|
|
14
12
|
private contextVersion;
|
|
15
13
|
private readonly maxAttachFilesLimit;
|
|
16
|
-
private readonly maxAttachFoldersLimit;
|
|
17
14
|
private readonly maxViewFilesLimit;
|
|
18
|
-
private attachedFiles;
|
|
19
|
-
private attachedFolders;
|
|
15
|
+
private readonly attachedFiles;
|
|
20
16
|
private readonly recentlyViewFiles;
|
|
21
17
|
private readonly onDidContextFilesChangeEmitter;
|
|
22
18
|
onDidContextFilesChangeEvent: import("@opensumi/ide-utils/lib/event").Event<{
|
|
@@ -25,9 +21,7 @@ export declare class LLMContextServiceImpl extends WithEventBus implements LLMCo
|
|
|
25
21
|
version: number;
|
|
26
22
|
}>;
|
|
27
23
|
private addFileToList;
|
|
28
|
-
private addFolderToList;
|
|
29
24
|
addFileToContext(uri: URI, selection?: [number, number], isManual?: boolean): void;
|
|
30
|
-
addFolderToContext(uri: URI): void;
|
|
31
25
|
private notifyContextChange;
|
|
32
26
|
cleanFileContext(): void;
|
|
33
27
|
private getAllContextFiles;
|
|
@@ -35,9 +29,7 @@ export declare class LLMContextServiceImpl extends WithEventBus implements LLMCo
|
|
|
35
29
|
startAutoCollection(): void;
|
|
36
30
|
private startAutoCollectionInternal;
|
|
37
31
|
stopAutoCollection(): void;
|
|
38
|
-
serialize():
|
|
39
|
-
private serializeAttachedFolders;
|
|
40
|
-
private getPartiaFolderStructure;
|
|
32
|
+
serialize(): SerializedContext;
|
|
41
33
|
private serializeRecentlyViewFiles;
|
|
42
34
|
private serializeAttachedFiles;
|
|
43
35
|
private serializeAttachedFile;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm-context.service.d.ts","sourceRoot":"","sources":["../../../src/browser/context/llm-context.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,gEAAgE,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,yDAAyD,CAAC;AAEvF,OAAO,EAAW,GAAG,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAIL,2BAA2B,EAC5B,MAAM,kDAAkD,CAAC;AAE1D,OAAO,
|
|
1
|
+
{"version":3,"file":"llm-context.service.d.ts","sourceRoot":"","sources":["../../../src/browser/context/llm-context.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,gEAAgE,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,yDAAyD,CAAC;AAEvF,OAAO,EAAW,GAAG,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAIL,2BAA2B,EAC5B,MAAM,kDAAkD,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAGxE,OAAO,EAAqB,WAAW,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAEhH,qBACa,qBAAsB,SAAQ,YAAa,YAAW,iBAAiB;IAElF,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAGxC,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,2BAA2B,CAAC;IAGhE,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,cAAc,CAAC;IAEjD,OAAO,CAAC,gBAAgB,CAAS;IAEjC,OAAO,CAAC,cAAc,CAAK;IAE3B,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAM;IAC1C,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAM;IACxC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAqB;IACnD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAqB;IACvD,OAAO,CAAC,QAAQ,CAAC,8BAA8B,CAI1C;IACL,4BAA4B;gBAJlB,WAAW,EAAE;kBACX,WAAW,EAAE;iBACd,MAAM;OAEwD;IAEzE,OAAO,CAAC,aAAa;IAYrB,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,UAAQ,GAAG,IAAI;IAiBhF,OAAO,CAAC,mBAAmB;IAI3B,gBAAgB;IAKhB,OAAO,CAAC,kBAAkB;IAQ1B,qBAAqB,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,UAAQ,GAAG,IAAI;IASvD,mBAAmB,IAAI,IAAI;IAS3B,OAAO,CAAC,2BAA2B;IAmDnC,kBAAkB,IAAI,IAAI;IAI1B,SAAS,IAAI,iBAAiB;IAU9B,OAAO,CAAC,0BAA0B;IAMlC,OAAO,CAAC,sBAAsB;IAM9B,OAAO,CAAC,qBAAqB;IAoB7B,OAAO,CAAC,aAAa;CAStB"}
|
|
@@ -9,7 +9,6 @@ const markers_1 = require("@opensumi/ide-core-common/lib/types/markers/markers")
|
|
|
9
9
|
const utils_1 = require("@opensumi/ide-core-common/lib/utils");
|
|
10
10
|
const types_1 = require("@opensumi/ide-editor/lib/browser/doc-model/types");
|
|
11
11
|
const types_2 = require("@opensumi/ide-editor/lib/browser/types");
|
|
12
|
-
const ide_file_service_1 = require("@opensumi/ide-file-service");
|
|
13
12
|
const types_3 = require("@opensumi/ide-markers/lib/common/types");
|
|
14
13
|
const ide_monaco_1 = require("@opensumi/ide-monaco");
|
|
15
14
|
let LLMContextServiceImpl = class LLMContextServiceImpl extends event_decorator_1.WithEventBus {
|
|
@@ -18,10 +17,8 @@ let LLMContextServiceImpl = class LLMContextServiceImpl extends event_decorator_
|
|
|
18
17
|
this.isAutoCollecting = false;
|
|
19
18
|
this.contextVersion = 0;
|
|
20
19
|
this.maxAttachFilesLimit = 10;
|
|
21
|
-
this.maxAttachFoldersLimit = 10;
|
|
22
20
|
this.maxViewFilesLimit = 20;
|
|
23
21
|
this.attachedFiles = [];
|
|
24
|
-
this.attachedFolders = [];
|
|
25
22
|
this.recentlyViewFiles = [];
|
|
26
23
|
this.onDidContextFilesChangeEmitter = new utils_1.Emitter();
|
|
27
24
|
this.onDidContextFilesChangeEvent = this.onDidContextFilesChangeEmitter.event;
|
|
@@ -36,16 +33,6 @@ let LLMContextServiceImpl = class LLMContextServiceImpl extends event_decorator_
|
|
|
36
33
|
list.shift();
|
|
37
34
|
}
|
|
38
35
|
}
|
|
39
|
-
addFolderToList(folder, list, maxLimit) {
|
|
40
|
-
const existingIndex = list.findIndex((f) => f.uri.toString() === folder.uri.toString());
|
|
41
|
-
if (existingIndex > -1) {
|
|
42
|
-
list.splice(existingIndex, 1);
|
|
43
|
-
}
|
|
44
|
-
list.push(folder);
|
|
45
|
-
if (list.length > maxLimit) {
|
|
46
|
-
list.shift();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
36
|
addFileToContext(uri, selection, isManual = false) {
|
|
50
37
|
if (!uri) {
|
|
51
38
|
return;
|
|
@@ -59,27 +46,17 @@ let LLMContextServiceImpl = class LLMContextServiceImpl extends event_decorator_
|
|
|
59
46
|
this.addFileToList(file, targetList, maxLimit);
|
|
60
47
|
this.notifyContextChange();
|
|
61
48
|
}
|
|
62
|
-
addFolderToContext(uri) {
|
|
63
|
-
if (!uri) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
const file = { uri };
|
|
67
|
-
this.addFolderToList(file, this.attachedFolders, this.maxAttachFoldersLimit);
|
|
68
|
-
this.notifyContextChange();
|
|
69
|
-
}
|
|
70
49
|
notifyContextChange() {
|
|
71
50
|
this.onDidContextFilesChangeEmitter.fire(this.getAllContextFiles());
|
|
72
51
|
}
|
|
73
52
|
cleanFileContext() {
|
|
74
|
-
this.attachedFiles =
|
|
75
|
-
this.attachedFolders = [];
|
|
53
|
+
this.attachedFiles.length = 0;
|
|
76
54
|
this.notifyContextChange();
|
|
77
55
|
}
|
|
78
56
|
getAllContextFiles() {
|
|
79
57
|
return {
|
|
80
58
|
viewed: this.recentlyViewFiles,
|
|
81
59
|
attached: this.attachedFiles,
|
|
82
|
-
attachedFolders: this.attachedFolders,
|
|
83
60
|
version: this.contextVersion++,
|
|
84
61
|
};
|
|
85
62
|
}
|
|
@@ -135,56 +112,14 @@ let LLMContextServiceImpl = class LLMContextServiceImpl extends event_decorator_
|
|
|
135
112
|
stopAutoCollection() {
|
|
136
113
|
this.dispose();
|
|
137
114
|
}
|
|
138
|
-
|
|
115
|
+
serialize() {
|
|
139
116
|
const files = this.getAllContextFiles();
|
|
140
117
|
const workspaceRoot = utils_1.URI.file(this.appConfig.workspaceDir);
|
|
141
118
|
return {
|
|
142
119
|
recentlyViewFiles: this.serializeRecentlyViewFiles(files.viewed, workspaceRoot),
|
|
143
120
|
attachedFiles: this.serializeAttachedFiles(files.attached, workspaceRoot),
|
|
144
|
-
attachedFolders: await this.serializeAttachedFolders(files.attachedFolders, workspaceRoot),
|
|
145
121
|
};
|
|
146
122
|
}
|
|
147
|
-
async serializeAttachedFolders(folders, workspaceRoot) {
|
|
148
|
-
// 去重
|
|
149
|
-
const folderPath = Array.from(new Set(folders.map((folder) => folder.uri.toString())));
|
|
150
|
-
return Promise.all(folderPath.map(async (folder) => {
|
|
151
|
-
var _a;
|
|
152
|
-
const folderUri = new utils_1.URI(folder);
|
|
153
|
-
const root = ((_a = workspaceRoot.relative(folderUri)) === null || _a === void 0 ? void 0 : _a.toString()) || '/';
|
|
154
|
-
return `\`\`\`\n${root}\n${(await this.getPartiaFolderStructure(folderUri.codeUri.fsPath))
|
|
155
|
-
.map((line) => `- ${line}`)
|
|
156
|
-
.join('\n')}\n\`\`\`\n`;
|
|
157
|
-
}));
|
|
158
|
-
}
|
|
159
|
-
async getPartiaFolderStructure(folder, level = 2) {
|
|
160
|
-
const result = [];
|
|
161
|
-
const stat = await this.fileService.getFileStat(folder);
|
|
162
|
-
for (const child of (stat === null || stat === void 0 ? void 0 : stat.children) || []) {
|
|
163
|
-
const relativePath = new utils_1.URI(folder).relative(new utils_1.URI(child.uri)).toString();
|
|
164
|
-
if (child.isSymbolicLink) {
|
|
165
|
-
// 处理软链接
|
|
166
|
-
const target = await this.fileService.getFileStat(child.realUri || child.uri);
|
|
167
|
-
if (target) {
|
|
168
|
-
result.push(`${relativePath} -> ${target} (symbolic link)`);
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
result.push(`${relativePath} (broken symbolic link)`);
|
|
172
|
-
}
|
|
173
|
-
continue;
|
|
174
|
-
}
|
|
175
|
-
if (child.type === ide_file_service_1.FileType.Directory) {
|
|
176
|
-
result.push(`${relativePath}/`);
|
|
177
|
-
if (level > 1) {
|
|
178
|
-
const subDirStructure = await this.getPartiaFolderStructure(child.uri, level - 1);
|
|
179
|
-
result.push(...subDirStructure.map((subEntry) => `${relativePath}/${subEntry}`));
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
else if (child.type === ide_file_service_1.FileType.File) {
|
|
183
|
-
result.push(relativePath);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return result;
|
|
187
|
-
}
|
|
188
123
|
serializeRecentlyViewFiles(files, workspaceRoot) {
|
|
189
124
|
return files
|
|
190
125
|
.map((file) => { var _a; return ((_a = workspaceRoot.relative(file.uri)) === null || _a === void 0 ? void 0 : _a.toString()) || file.uri.parent.toString(); })
|
|
@@ -235,10 +170,6 @@ tslib_1.__decorate([
|
|
|
235
170
|
(0, di_1.Autowired)(types_3.IMarkerService),
|
|
236
171
|
tslib_1.__metadata("design:type", Object)
|
|
237
172
|
], LLMContextServiceImpl.prototype, "markerService", void 0);
|
|
238
|
-
tslib_1.__decorate([
|
|
239
|
-
(0, di_1.Autowired)(ide_file_service_1.IFileServiceClient),
|
|
240
|
-
tslib_1.__metadata("design:type", Object)
|
|
241
|
-
], LLMContextServiceImpl.prototype, "fileService", void 0);
|
|
242
173
|
exports.LLMContextServiceImpl = LLMContextServiceImpl = tslib_1.__decorate([
|
|
243
174
|
(0, di_1.Injectable)()
|
|
244
175
|
], LLMContextServiceImpl);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm-context.service.js","sourceRoot":"","sources":["../../../src/browser/context/llm-context.service.ts"],"names":[],"mappings":";;;;AAAA,qCAAqD;AACrD,oGAA2F;AAC3F,6FAAuF;AACvF,iFAAqF;AACrF,+DAAmE;AACnE,4EAK0D;AAC1D,kEAAoF;AACpF,
|
|
1
|
+
{"version":3,"file":"llm-context.service.js","sourceRoot":"","sources":["../../../src/browser/context/llm-context.service.ts"],"names":[],"mappings":";;;;AAAA,qCAAqD;AACrD,oGAA2F;AAC3F,6FAAuF;AACvF,iFAAqF;AACrF,+DAAmE;AACnE,4EAK0D;AAC1D,kEAAoF;AACpF,kEAAwE;AACxE,qDAA6C;AAKtC,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,8BAAY;IAAhD;;QAUG,qBAAgB,GAAG,KAAK,CAAC;QAEzB,mBAAc,GAAG,CAAC,CAAC;QAEV,wBAAmB,GAAG,EAAE,CAAC;QACzB,sBAAiB,GAAG,EAAE,CAAC;QACvB,kBAAa,GAAkB,EAAE,CAAC;QAClC,sBAAiB,GAAkB,EAAE,CAAC;QACtC,mCAA8B,GAAG,IAAI,eAAO,EAIzD,CAAC;QACL,iCAA4B,GAAG,IAAI,CAAC,8BAA8B,CAAC,KAAK,CAAC;IA4K3E,CAAC;IA1KS,aAAa,CAAC,IAAiB,EAAE,IAAmB,EAAE,QAAgB;QAC5E,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;QACtF,IAAI,aAAa,GAAG,CAAC,CAAC,EAAE,CAAC;YACvB,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AAQ,CAAC,OAAO,CAC3B,IAAI,CAAC,SAAS,IAAI,IAAI,kBAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CACtF;gBACD,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC;gBACxC,IAAI,EAAE,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAE,CAAC,QAAQ,EAAE;gBAClD,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC,UAAW;aACnC,CAAC;QACJ,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAEO,aAAa,CAAC,GAAQ;QAC5B,OAAO,IAAI,CAAC,aAAa;aACtB,UAAU,EAAE;aACZ,UAAU,CAAC;YACV,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE;YACxB,UAAU,EAAE,wBAAc,CAAC,KAAK;SACjC,CAAC;aACD,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;CACF,CAAA;AAnMY,sDAAqB;AAEb;IADlB,IAAA,cAAS,EAAC,2BAAS,CAAC;;wDACmB;AAGrB;IADlB,IAAA,cAAS,EAAC,mCAA2B,CAAC;;8DACyB;AAG7C;IADlB,IAAA,cAAS,EAAC,sBAAc,CAAC;;4DACuB;gCARtC,qBAAqB;IADjC,IAAA,eAAU,GAAE;GACA,qBAAqB,CAmMjC"}
|
|
@@ -1,28 +1,15 @@
|
|
|
1
1
|
import { Event, URI } from '@opensumi/ide-core-common/lib/utils';
|
|
2
2
|
export interface LLMContextService {
|
|
3
|
-
/**
|
|
4
|
-
* 开始自动收集
|
|
5
|
-
*/
|
|
6
3
|
startAutoCollection(): void;
|
|
7
|
-
/**
|
|
8
|
-
* 停止自动收集
|
|
9
|
-
*/
|
|
10
4
|
stopAutoCollection(): void;
|
|
11
5
|
/**
|
|
12
6
|
* 添加文件到 context 中
|
|
13
7
|
*/
|
|
14
8
|
addFileToContext(uri: URI, selection?: [number, number], isManual?: boolean): void;
|
|
15
|
-
/**
|
|
16
|
-
* 添加文件夹到 context 中
|
|
17
|
-
*/
|
|
18
|
-
addFolderToContext(uri: URI, isManual?: boolean): void;
|
|
19
9
|
/**
|
|
20
10
|
* 清除上下文
|
|
21
11
|
*/
|
|
22
12
|
cleanFileContext(): void;
|
|
23
|
-
/**
|
|
24
|
-
* 上下文文件变化事件
|
|
25
|
-
*/
|
|
26
13
|
onDidContextFilesChangeEvent: Event<{
|
|
27
14
|
viewed: FileContext[];
|
|
28
15
|
attached: FileContext[];
|
|
@@ -34,7 +21,7 @@ export interface LLMContextService {
|
|
|
34
21
|
*/
|
|
35
22
|
removeFileFromContext(uri: URI, isManual?: boolean): void;
|
|
36
23
|
/** 导出为可序列化格式 */
|
|
37
|
-
serialize():
|
|
24
|
+
serialize(): SerializedContext;
|
|
38
25
|
}
|
|
39
26
|
export interface FileContext {
|
|
40
27
|
uri: URI;
|
|
@@ -50,6 +37,5 @@ export interface AttachFileContext {
|
|
|
50
37
|
export interface SerializedContext {
|
|
51
38
|
recentlyViewFiles: string[];
|
|
52
39
|
attachedFiles: Array<AttachFileContext>;
|
|
53
|
-
attachedFolders: string[];
|
|
54
40
|
}
|
|
55
41
|
//# sourceMappingURL=llm-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm-context.d.ts","sourceRoot":"","sources":["../../src/common/llm-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,qCAAqC,CAAC;AAEjE,MAAM,WAAW,iBAAiB;IAChC
|
|
1
|
+
{"version":3,"file":"llm-context.d.ts","sourceRoot":"","sources":["../../src/common/llm-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,qCAAqC,CAAC;AAEjE,MAAM,WAAW,iBAAiB;IAChC,mBAAmB,IAAI,IAAI,CAAC;IAE5B,kBAAkB,IAAI,IAAI,CAAC;IAE3B;;OAEG;IACH,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAEnF;;OAEG;IACH,gBAAgB,IAAI,IAAI,CAAC;IAEzB,4BAA4B,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,WAAW,EAAE,CAAC;QAAC,QAAQ,EAAE,WAAW,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAEzG;;;OAGG;IACH,qBAAqB,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAE1D,gBAAgB;IAChB,SAAS,IAAI,iBAAiB,CAAC;CAChC;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,GAAG,CAAC;IACT,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,eAAO,MAAM,sBAAsB,eAA8B,CAAC;AAElE,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,aAAa,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;CACzC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm-context.js","sourceRoot":"","sources":["../../src/common/llm-context.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"llm-context.js","sourceRoot":"","sources":["../../src/common/llm-context.ts"],"names":[],"mappings":";;;AAkCa,QAAA,sBAAsB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { WorkbenchEditorService } from '@opensumi/ide-editor/lib/common/editor';
|
|
2
|
-
import { IWorkspaceService } from '@opensumi/ide-workspace';
|
|
3
2
|
import { SerializedContext } from '../llm-context';
|
|
4
3
|
export declare const ChatAgentPromptProvider: unique symbol;
|
|
5
4
|
export interface ChatAgentPromptProvider {
|
|
@@ -7,19 +6,10 @@ export interface ChatAgentPromptProvider {
|
|
|
7
6
|
* 提供上下文提示
|
|
8
7
|
* @param context 上下文
|
|
9
8
|
*/
|
|
10
|
-
provideContextPrompt(context: SerializedContext, userMessage: string):
|
|
9
|
+
provideContextPrompt(context: SerializedContext, userMessage: string): string;
|
|
11
10
|
}
|
|
12
11
|
export declare class DefaultChatAgentPromptProvider implements ChatAgentPromptProvider {
|
|
13
12
|
protected readonly workbenchEditorService: WorkbenchEditorService;
|
|
14
|
-
|
|
15
|
-
provideContextPrompt(context: SerializedContext, userMessage: string): Promise<string>;
|
|
16
|
-
private getCurrentFileInfo;
|
|
17
|
-
private buildPromptTemplate;
|
|
18
|
-
private buildRecentFilesSection;
|
|
19
|
-
private buildAttachedFilesSection;
|
|
20
|
-
private buildFileContentSection;
|
|
21
|
-
private buildLineErrorsSection;
|
|
22
|
-
private buildAttachedFoldersSection;
|
|
23
|
-
private buildCurrentFileSection;
|
|
13
|
+
provideContextPrompt(context: SerializedContext, userMessage: string): string;
|
|
24
14
|
}
|
|
25
15
|
//# sourceMappingURL=context-prompt-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-prompt-provider.d.ts","sourceRoot":"","sources":["../../../src/common/prompts/context-prompt-provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"context-prompt-provider.d.ts","sourceRoot":"","sources":["../../../src/common/prompts/context-prompt-provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAEhF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,eAAO,MAAM,uBAAuB,eAAoC,CAAC;AAEzE,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;CAC/E;AAED,qBACa,8BAA+B,YAAW,uBAAuB;IAE5E,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE,sBAAsB,CAAC;IAElE,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM;CAsC9E"}
|
|
@@ -4,100 +4,40 @@ exports.DefaultChatAgentPromptProvider = exports.ChatAgentPromptProvider = void
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const di_1 = require("@opensumi/di");
|
|
6
6
|
const editor_1 = require("@opensumi/ide-editor/lib/common/editor");
|
|
7
|
-
const ide_workspace_1 = require("@opensumi/ide-workspace");
|
|
8
7
|
exports.ChatAgentPromptProvider = Symbol('ChatAgentPromptProvider');
|
|
9
8
|
let DefaultChatAgentPromptProvider = class DefaultChatAgentPromptProvider {
|
|
10
|
-
|
|
11
|
-
const currentFileInfo = await this.getCurrentFileInfo();
|
|
12
|
-
return this.buildPromptTemplate({
|
|
13
|
-
recentFiles: this.buildRecentFilesSection(context.recentlyViewFiles),
|
|
14
|
-
attachedFiles: this.buildAttachedFilesSection(context.attachedFiles),
|
|
15
|
-
attachedFolders: this.buildAttachedFoldersSection(context.attachedFolders),
|
|
16
|
-
currentFile: currentFileInfo,
|
|
17
|
-
userMessage,
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
async getCurrentFileInfo() {
|
|
21
|
-
var _a;
|
|
9
|
+
provideContextPrompt(context, userMessage) {
|
|
22
10
|
const editor = this.workbenchEditorService.currentEditor;
|
|
23
11
|
const currentModel = editor === null || editor === void 0 ? void 0 : editor.currentDocumentModel;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return `<recently_viewed_files>
|
|
54
|
-
${files.map((file, idx) => ` ${idx + 1}: ${file}`).join('\n')}
|
|
55
|
-
</recently_viewed_files>`;
|
|
56
|
-
}
|
|
57
|
-
buildAttachedFilesSection(files) {
|
|
58
|
-
if (!files.length) {
|
|
59
|
-
return '';
|
|
60
|
-
}
|
|
61
|
-
const fileContents = files
|
|
62
|
-
.map((file) => {
|
|
63
|
-
const sections = [
|
|
64
|
-
this.buildFileContentSection(file),
|
|
65
|
-
file.lineErrors.length ? this.buildLineErrorsSection(file.lineErrors) : '',
|
|
66
|
-
].filter(Boolean);
|
|
67
|
-
return sections.join('\n');
|
|
68
|
-
})
|
|
69
|
-
.filter(Boolean)
|
|
70
|
-
.join('\n');
|
|
71
|
-
return `<attached_files>\n${fileContents}\n</attached_files>`;
|
|
72
|
-
}
|
|
73
|
-
buildFileContentSection(file) {
|
|
74
|
-
return `<file_contents>
|
|
75
|
-
\`\`\`${file.path}
|
|
76
|
-
${file.content}
|
|
77
|
-
\`\`\`
|
|
78
|
-
</file_contents>`;
|
|
79
|
-
}
|
|
80
|
-
buildLineErrorsSection(errors) {
|
|
81
|
-
if (!errors.length) {
|
|
82
|
-
return '';
|
|
83
|
-
}
|
|
84
|
-
return `<linter_errors>\n${errors.join('\n')}\n</linter_errors>`;
|
|
85
|
-
}
|
|
86
|
-
buildAttachedFoldersSection(folders) {
|
|
87
|
-
if (!folders.length) {
|
|
88
|
-
return '';
|
|
89
|
-
}
|
|
90
|
-
return `<attached_folders>\n${folders.join('\n')}</attached_folders>`;
|
|
91
|
-
}
|
|
92
|
-
buildCurrentFileSection(fileInfo) {
|
|
93
|
-
if (!fileInfo) {
|
|
94
|
-
return '';
|
|
95
|
-
}
|
|
96
|
-
return `<current_opened_file>
|
|
97
|
-
\`\`\`${fileInfo.languageId} ${fileInfo.path}
|
|
98
|
-
${fileInfo.content}
|
|
99
|
-
\`\`\`
|
|
100
|
-
</current_opened_file>`;
|
|
12
|
+
return `
|
|
13
|
+
<additional_data>
|
|
14
|
+
Below are some potentially helpful/relevant pieces of information for figuring out to respond
|
|
15
|
+
<recently_viewed_files>
|
|
16
|
+
${context.recentlyViewFiles.map((file, idx) => ` ${idx + 1}: ${file}`).join('\n')}
|
|
17
|
+
</recently_viewed_files>
|
|
18
|
+
<attached_files>
|
|
19
|
+
${context.attachedFiles.map((file) => `
|
|
20
|
+
<file_contents>
|
|
21
|
+
\`\`\`${file.path}
|
|
22
|
+
${file.content}
|
|
23
|
+
\`\`\`
|
|
24
|
+
</file_contents>
|
|
25
|
+
<linter_errors>
|
|
26
|
+
${file.lineErrors.join('\n')}
|
|
27
|
+
</linter_errors>
|
|
28
|
+
`)}
|
|
29
|
+
</attached_files>
|
|
30
|
+
${currentModel
|
|
31
|
+
? `<current_opened_file>
|
|
32
|
+
\`\`\`${currentModel.languageId} ${currentModel.uri.toString()}
|
|
33
|
+
${currentModel.getText()}
|
|
34
|
+
\`\`\`
|
|
35
|
+
</current_opened_file>`
|
|
36
|
+
: ''}
|
|
37
|
+
</additional_data>
|
|
38
|
+
<user_query>
|
|
39
|
+
${userMessage}
|
|
40
|
+
</user_query>`;
|
|
101
41
|
}
|
|
102
42
|
};
|
|
103
43
|
exports.DefaultChatAgentPromptProvider = DefaultChatAgentPromptProvider;
|
|
@@ -105,10 +45,6 @@ tslib_1.__decorate([
|
|
|
105
45
|
(0, di_1.Autowired)(editor_1.WorkbenchEditorService),
|
|
106
46
|
tslib_1.__metadata("design:type", editor_1.WorkbenchEditorService)
|
|
107
47
|
], DefaultChatAgentPromptProvider.prototype, "workbenchEditorService", void 0);
|
|
108
|
-
tslib_1.__decorate([
|
|
109
|
-
(0, di_1.Autowired)(ide_workspace_1.IWorkspaceService),
|
|
110
|
-
tslib_1.__metadata("design:type", Object)
|
|
111
|
-
], DefaultChatAgentPromptProvider.prototype, "workspaceService", void 0);
|
|
112
48
|
exports.DefaultChatAgentPromptProvider = DefaultChatAgentPromptProvider = tslib_1.__decorate([
|
|
113
49
|
(0, di_1.Injectable)()
|
|
114
50
|
], DefaultChatAgentPromptProvider);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-prompt-provider.js","sourceRoot":"","sources":["../../../src/common/prompts/context-prompt-provider.ts"],"names":[],"mappings":";;;;AAAA,qCAAqD;AACrD,mEAAgF;
|
|
1
|
+
{"version":3,"file":"context-prompt-provider.js","sourceRoot":"","sources":["../../../src/common/prompts/context-prompt-provider.ts"],"names":[],"mappings":";;;;AAAA,qCAAqD;AACrD,mEAAgF;AAInE,QAAA,uBAAuB,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAC;AAWlE,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAIzC,oBAAoB,CAAC,OAA0B,EAAE,WAAmB;QAClE,MAAM,MAAM,GAAG,IAAI,CAAC,sBAAsB,CAAC,aAAa,CAAC;QACzD,MAAM,YAAY,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,oBAAoB,CAAC;QAClD,OAAO;;;;EAIT,OAAO,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,OAAO,GAAG,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;;MAG9E,OAAO,CAAC,aAAa,CAAC,GAAG,CACzB,CAAC,IAAI,EAAE,EAAE,CACP;;YAEI,IAAI,CAAC,IAAI;MACf,IAAI,CAAC,OAAO;;;;MAIZ,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;;eAEjB,CACV;;EAGH,YAAY;YACV,CAAC,CAAC;UACI,YAAY,CAAC,UAAU,IAAI,YAAY,CAAC,GAAG,CAAC,QAAQ,EAAE;EAC9D,YAAY,CAAC,OAAO,EAAE;;yBAEC;YACrB,CAAC,CAAC,EACN;;;EAGE,WAAW;cACC,CAAC;IACb,CAAC;CACF,CAAA;AA1CY,wEAA8B;AAEtB;IADlB,IAAA,cAAS,EAAC,+BAAsB,CAAC;sCACS,+BAAsB;8EAAC;yCAFvD,8BAA8B;IAD1C,IAAA,eAAU,GAAE;GACA,8BAA8B,CA0C1C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensumi/ide-ai-native",
|
|
3
|
-
"version": "3.8.3-next-
|
|
3
|
+
"version": "3.8.3-next-1741763277.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib",
|
|
6
6
|
"src"
|
|
@@ -24,26 +24,26 @@
|
|
|
24
24
|
"@ai-sdk/openai": "^1.1.9",
|
|
25
25
|
"@ai-sdk/openai-compatible": "^0.1.11",
|
|
26
26
|
"@modelcontextprotocol/sdk": "^1.3.1",
|
|
27
|
-
"@opensumi/ide-addons": "3.8.3-next-
|
|
28
|
-
"@opensumi/ide-components": "3.8.3-next-
|
|
29
|
-
"@opensumi/ide-connection": "3.8.3-next-
|
|
30
|
-
"@opensumi/ide-core-common": "3.8.3-next-
|
|
31
|
-
"@opensumi/ide-core-node": "3.8.3-next-
|
|
32
|
-
"@opensumi/ide-debug": "3.8.3-next-
|
|
33
|
-
"@opensumi/ide-design": "3.8.3-next-
|
|
34
|
-
"@opensumi/ide-editor": "3.8.3-next-
|
|
35
|
-
"@opensumi/ide-file-search": "3.8.3-next-
|
|
36
|
-
"@opensumi/ide-file-service": "3.8.3-next-
|
|
37
|
-
"@opensumi/ide-main-layout": "3.8.3-next-
|
|
38
|
-
"@opensumi/ide-markers": "3.8.3-next-
|
|
39
|
-
"@opensumi/ide-monaco": "3.8.3-next-
|
|
40
|
-
"@opensumi/ide-overlay": "3.8.3-next-
|
|
41
|
-
"@opensumi/ide-preferences": "3.8.3-next-
|
|
42
|
-
"@opensumi/ide-search": "3.8.3-next-
|
|
43
|
-
"@opensumi/ide-terminal-next": "3.8.3-next-
|
|
44
|
-
"@opensumi/ide-theme": "3.8.3-next-
|
|
45
|
-
"@opensumi/ide-utils": "3.8.3-next-
|
|
46
|
-
"@opensumi/ide-workspace": "3.8.3-next-
|
|
27
|
+
"@opensumi/ide-addons": "3.8.3-next-1741763277.0",
|
|
28
|
+
"@opensumi/ide-components": "3.8.3-next-1741763277.0",
|
|
29
|
+
"@opensumi/ide-connection": "3.8.3-next-1741763277.0",
|
|
30
|
+
"@opensumi/ide-core-common": "3.8.3-next-1741763277.0",
|
|
31
|
+
"@opensumi/ide-core-node": "3.8.3-next-1741763277.0",
|
|
32
|
+
"@opensumi/ide-debug": "3.8.3-next-1741763277.0",
|
|
33
|
+
"@opensumi/ide-design": "3.8.3-next-1741763277.0",
|
|
34
|
+
"@opensumi/ide-editor": "3.8.3-next-1741763277.0",
|
|
35
|
+
"@opensumi/ide-file-search": "3.8.3-next-1741763277.0",
|
|
36
|
+
"@opensumi/ide-file-service": "3.8.3-next-1741763277.0",
|
|
37
|
+
"@opensumi/ide-main-layout": "3.8.3-next-1741763277.0",
|
|
38
|
+
"@opensumi/ide-markers": "3.8.3-next-1741763277.0",
|
|
39
|
+
"@opensumi/ide-monaco": "3.8.3-next-1741763277.0",
|
|
40
|
+
"@opensumi/ide-overlay": "3.8.3-next-1741763277.0",
|
|
41
|
+
"@opensumi/ide-preferences": "3.8.3-next-1741763277.0",
|
|
42
|
+
"@opensumi/ide-search": "3.8.3-next-1741763277.0",
|
|
43
|
+
"@opensumi/ide-terminal-next": "3.8.3-next-1741763277.0",
|
|
44
|
+
"@opensumi/ide-theme": "3.8.3-next-1741763277.0",
|
|
45
|
+
"@opensumi/ide-utils": "3.8.3-next-1741763277.0",
|
|
46
|
+
"@opensumi/ide-workspace": "3.8.3-next-1741763277.0",
|
|
47
47
|
"@xterm/xterm": "5.5.0",
|
|
48
48
|
"ai": "^4.1.45",
|
|
49
49
|
"ansi-regex": "^2.0.0",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"zod-to-json-schema": "^3.24.1"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@opensumi/ide-core-browser": "3.8.3-next-
|
|
63
|
+
"@opensumi/ide-core-browser": "3.8.3-next-1741763277.0"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "6afdbd5e463833caf6ff7b389f5bd4e59996ae9f"
|
|
66
66
|
}
|
|
@@ -59,7 +59,7 @@ export class ChatAgentService extends Disposable implements IChatAgentService {
|
|
|
59
59
|
private readonly aiReporter: IAIReporter;
|
|
60
60
|
|
|
61
61
|
@Autowired(LLMContextServiceToken)
|
|
62
|
-
protected readonly
|
|
62
|
+
protected readonly contextService: LLMContextService;
|
|
63
63
|
|
|
64
64
|
@Autowired(ChatAgentPromptProvider)
|
|
65
65
|
protected readonly promptProvider: ChatAgentPromptProvider;
|
|
@@ -74,7 +74,7 @@ export class ChatAgentService extends Disposable implements IChatAgentService {
|
|
|
74
74
|
super();
|
|
75
75
|
this.addDispose(this._onDidChangeAgents);
|
|
76
76
|
this.addDispose(
|
|
77
|
-
this.
|
|
77
|
+
this.contextService.onDidContextFilesChangeEvent((event) => {
|
|
78
78
|
if (event.version !== this.contextVersion) {
|
|
79
79
|
this.contextVersion = event.version;
|
|
80
80
|
this.shouldUpdateContext = true;
|
|
@@ -152,9 +152,9 @@ export class ChatAgentService extends Disposable implements IChatAgentService {
|
|
|
152
152
|
if (!this.initialUserMessageMap.has(request.sessionId)) {
|
|
153
153
|
this.initialUserMessageMap.set(request.sessionId, request.message);
|
|
154
154
|
const rawMessage = request.message;
|
|
155
|
-
request.message =
|
|
155
|
+
request.message = this.provideContextMessage(rawMessage, request.sessionId);
|
|
156
156
|
} else if (this.shouldUpdateContext || request.regenerate || history.length === 0) {
|
|
157
|
-
request.message =
|
|
157
|
+
request.message = this.provideContextMessage(request.message, request.sessionId);
|
|
158
158
|
this.shouldUpdateContext = false;
|
|
159
159
|
}
|
|
160
160
|
|
|
@@ -162,9 +162,9 @@ export class ChatAgentService extends Disposable implements IChatAgentService {
|
|
|
162
162
|
return result;
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
private
|
|
166
|
-
const context =
|
|
167
|
-
const fullMessage =
|
|
165
|
+
private provideContextMessage(message: string, sessionId: string) {
|
|
166
|
+
const context = this.contextService.serialize();
|
|
167
|
+
const fullMessage = this.promptProvider.provideContextPrompt(context, message);
|
|
168
168
|
this.aiReporter.send({
|
|
169
169
|
msgType: AIServiceType.Chat,
|
|
170
170
|
actionType: ActionTypeEnum.ContextEnhance,
|