@opensumi/ide-ai-native 3.8.1-next-1740452092.0 → 3.8.1-next-1740452912.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/components/ChatContext/index.js +2 -2
- package/lib/browser/components/ChatContext/index.js.map +1 -1
- package/lib/browser/context/llm-context.service.d.ts +5 -16
- package/lib/browser/context/llm-context.service.d.ts.map +1 -1
- package/lib/browser/context/llm-context.service.js +47 -75
- package/lib/browser/context/llm-context.service.js.map +1 -1
- package/lib/common/llm-context.d.ts +9 -12
- package/lib/common/llm-context.d.ts.map +1 -1
- package/lib/common/llm-context.js.map +1 -1
- package/package.json +23 -23
- package/src/browser/components/ChatContext/index.tsx +2 -2
- package/src/browser/context/llm-context.service.ts +55 -87
- package/src/common/llm-context.ts +4 -10
|
@@ -31,7 +31,7 @@ exports.ChatContext = (0, react_1.memo)(() => {
|
|
|
31
31
|
(0, react_1.useEffect)(() => {
|
|
32
32
|
const disposable = utils_1.Event.debounce(contextService.onDidContextFilesChangeEvent, (_, e) => e, 50)((files) => {
|
|
33
33
|
if (files) {
|
|
34
|
-
updateAddedFiles(
|
|
34
|
+
updateAddedFiles(files);
|
|
35
35
|
}
|
|
36
36
|
}, contextService);
|
|
37
37
|
return () => {
|
|
@@ -45,7 +45,7 @@ exports.ChatContext = (0, react_1.memo)(() => {
|
|
|
45
45
|
contextService.addFileToContext(uri, undefined, true);
|
|
46
46
|
}, []);
|
|
47
47
|
const onDidDeselect = (0, react_1.useCallback)((uri) => {
|
|
48
|
-
contextService.removeFileFromContext(uri
|
|
48
|
+
contextService.removeFileFromContext(uri);
|
|
49
49
|
}, []);
|
|
50
50
|
const onDidClickFile = (0, react_1.useCallback)((uri) => {
|
|
51
51
|
workbenchEditorService.open(uri);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/browser/components/ChatContext/index.tsx"],"names":[],"mappings":";;;;A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ChE;wBACP,wCAAM,SAAS,EAAE,2BAAM,CAAC,GAAG,IACxB,MAAA,WAAG,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,0CAAE,QAAQ,EAAE,CAClE;wBACP,8BAAC,WAAI,IAAC,IAAI,EAAC,OAAO,EAAC,SAAS,EAAE,2BAAM,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAI,CAC7F,CACP,CAAA;iBAAA,CAAC,CACE;gBACN,uCAAK,SAAS,EAAE,2BAAM,CAAC,WAAW,EAAE,OAAO,EAAE,kBAAkB;oBAC7D,8BAAC,WAAI,IAAC,IAAI,EAAC,KAAK,GAAG;gCAEf,CACA,CACC;QACV,cAAc,IAAI,CACjB,8BAAC,iCAAe,IACd,UAAU,EAAE,GAAG,EAAE,CAAC,oBAAoB,CAAC,KAAK,CAAC,EAC7C,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,UAAU,GACtB,CACH,CACG,CACP,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -9,28 +9,17 @@ export declare class LLMContextServiceImpl extends WithEventBus implements LLMCo
|
|
|
9
9
|
protected readonly docModelManager: IEditorDocumentModelService;
|
|
10
10
|
protected readonly markerService: IMarkerService;
|
|
11
11
|
private isAutoCollecting;
|
|
12
|
-
private
|
|
13
|
-
private
|
|
14
|
-
private
|
|
15
|
-
|
|
16
|
-
private readonly onDidContextFilesChangeEmitter;
|
|
17
|
-
onDidContextFilesChangeEvent: import("@opensumi/ide-utils/lib/event").Event<{
|
|
18
|
-
viewed: FileContext[];
|
|
19
|
-
attached: FileContext[];
|
|
20
|
-
}>;
|
|
21
|
-
private addFileToList;
|
|
12
|
+
private contextFiles;
|
|
13
|
+
private maxFiles;
|
|
14
|
+
private onDidContextFilesChangeEmitter;
|
|
15
|
+
onDidContextFilesChangeEvent: import("@opensumi/ide-utils/lib/event").Event<FileContext[]>;
|
|
22
16
|
addFileToContext(uri: URI, selection?: [number, number], isManual?: boolean): void;
|
|
23
|
-
private notifyContextChange;
|
|
24
17
|
cleanFileContext(): void;
|
|
25
18
|
private getAllContextFiles;
|
|
26
|
-
removeFileFromContext(uri: URI
|
|
19
|
+
removeFileFromContext(uri: URI): void;
|
|
27
20
|
startAutoCollection(): void;
|
|
28
21
|
private startAutoCollectionInternal;
|
|
29
22
|
stopAutoCollection(): void;
|
|
30
23
|
serialize(): SerializedContext;
|
|
31
|
-
private serializeRecentlyViewFiles;
|
|
32
|
-
private serializeAttachedFiles;
|
|
33
|
-
private serializeAttachedFile;
|
|
34
|
-
private getFileErrors;
|
|
35
24
|
}
|
|
36
25
|
//# sourceMappingURL=llm-context.service.d.ts.map
|
|
@@ -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,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAExE,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;AAExE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7F,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,YAAY,CAAqB;IAEzC,OAAO,CAAC,QAAQ,CAAc;IAE9B,OAAO,CAAC,8BAA8B,CAAgC;IACtE,4BAA4B,+DAA6C;IAEzE,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,UAAO,GAAG,IAAI;IAY/E,gBAAgB;IAKhB,OAAO,CAAC,kBAAkB;IAI1B,qBAAqB,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI;IAQrC,mBAAmB,IAAI,IAAI;IAS3B,OAAO,CAAC,2BAA2B;IAiDnC,kBAAkB,IAAI,IAAI;IAI1B,SAAS,IAAI,iBAAiB;CAwC/B"}
|
|
@@ -14,53 +14,32 @@ let LLMContextServiceImpl = class LLMContextServiceImpl extends event_decorator_
|
|
|
14
14
|
constructor() {
|
|
15
15
|
super(...arguments);
|
|
16
16
|
this.isAutoCollecting = false;
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
19
|
-
this.attachedFiles = [];
|
|
20
|
-
this.recentlyViewFiles = [];
|
|
17
|
+
this.contextFiles = [];
|
|
18
|
+
this.maxFiles = 10; // 上下文的最大长度限制
|
|
21
19
|
this.onDidContextFilesChangeEmitter = new utils_1.Emitter();
|
|
22
20
|
this.onDidContextFilesChangeEvent = this.onDidContextFilesChangeEmitter.event;
|
|
23
21
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
addFileToContext(uri, selection, isManual = true) {
|
|
23
|
+
this.removeFileFromContext(uri);
|
|
24
|
+
this.contextFiles.push({ uri, selection, isManual });
|
|
25
|
+
if (this.contextFiles.length > this.maxFiles) {
|
|
26
|
+
this.contextFiles.shift();
|
|
28
27
|
}
|
|
29
|
-
list.push(file);
|
|
30
|
-
if (list.length > maxLimit) {
|
|
31
|
-
list.shift();
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
addFileToContext(uri, selection, isManual = false) {
|
|
35
|
-
if (!uri) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
const file = { uri, selection };
|
|
39
|
-
const targetList = isManual ? this.attachedFiles : this.recentlyViewFiles;
|
|
40
|
-
const maxLimit = isManual ? this.maxAttachFilesLimit : this.maxViewFilesLimit;
|
|
41
|
-
this.addFileToList(file, targetList, maxLimit);
|
|
42
|
-
this.notifyContextChange();
|
|
43
|
-
}
|
|
44
|
-
notifyContextChange() {
|
|
45
28
|
this.onDidContextFilesChangeEmitter.fire(this.getAllContextFiles());
|
|
46
29
|
}
|
|
47
30
|
cleanFileContext() {
|
|
48
|
-
this.
|
|
49
|
-
this.
|
|
31
|
+
this.contextFiles = [];
|
|
32
|
+
this.onDidContextFilesChangeEmitter.fire(this.getAllContextFiles());
|
|
50
33
|
}
|
|
51
34
|
getAllContextFiles() {
|
|
52
|
-
return
|
|
53
|
-
viewed: this.recentlyViewFiles,
|
|
54
|
-
attached: this.attachedFiles,
|
|
55
|
-
};
|
|
35
|
+
return [...this.contextFiles];
|
|
56
36
|
}
|
|
57
|
-
removeFileFromContext(uri
|
|
58
|
-
const
|
|
59
|
-
const index = targetList.findIndex((file) => file.uri.toString() === uri.toString());
|
|
37
|
+
removeFileFromContext(uri) {
|
|
38
|
+
const index = this.contextFiles.findIndex((file) => file.uri.toString() === uri.toString());
|
|
60
39
|
if (index > -1) {
|
|
61
|
-
|
|
40
|
+
this.contextFiles.splice(index, 1);
|
|
41
|
+
this.onDidContextFilesChangeEmitter.fire(this.getAllContextFiles());
|
|
62
42
|
}
|
|
63
|
-
this.notifyContextChange();
|
|
64
43
|
}
|
|
65
44
|
startAutoCollection() {
|
|
66
45
|
if (this.isAutoCollecting) {
|
|
@@ -74,13 +53,13 @@ let LLMContextServiceImpl = class LLMContextServiceImpl extends event_decorator_
|
|
|
74
53
|
if (event.payload.uri.scheme !== 'file') {
|
|
75
54
|
return;
|
|
76
55
|
}
|
|
77
|
-
|
|
56
|
+
// FIXME: 暂时不自动添加
|
|
57
|
+
// this.addFileToContext(event.payload.uri);
|
|
78
58
|
}));
|
|
79
59
|
this.disposables.push(this.eventBus.on(types_1.EditorDocumentModelRemovalEvent, (event) => {
|
|
80
60
|
if (event.payload.scheme !== 'file') {
|
|
81
61
|
return;
|
|
82
62
|
}
|
|
83
|
-
this.removeFileFromContext(event.payload, false);
|
|
84
63
|
}));
|
|
85
64
|
this.disposables.push(this.eventBus.on(types_1.EditorDocumentModelSavedEvent, (event) => {
|
|
86
65
|
if (event.payload.scheme !== 'file') {
|
|
@@ -95,10 +74,10 @@ let LLMContextServiceImpl = class LLMContextServiceImpl extends event_decorator_
|
|
|
95
74
|
event.payload.selections[0].positionLineNumber,
|
|
96
75
|
].sort();
|
|
97
76
|
if (selection[0] === selection[1]) {
|
|
98
|
-
this.addFileToContext(event.payload.editorUri, undefined
|
|
77
|
+
this.addFileToContext(event.payload.editorUri, undefined);
|
|
99
78
|
}
|
|
100
79
|
else {
|
|
101
|
-
this.addFileToContext(event.payload.editorUri, selection.sort((a, b) => a - b)
|
|
80
|
+
this.addFileToContext(event.payload.editorUri, selection.sort((a, b) => a - b));
|
|
102
81
|
}
|
|
103
82
|
}
|
|
104
83
|
}));
|
|
@@ -108,47 +87,40 @@ let LLMContextServiceImpl = class LLMContextServiceImpl extends event_decorator_
|
|
|
108
87
|
}
|
|
109
88
|
serialize() {
|
|
110
89
|
const files = this.getAllContextFiles();
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
.filter(Boolean);
|
|
121
|
-
}
|
|
122
|
-
serializeAttachedFiles(files, workspaceRoot) {
|
|
123
|
-
return files
|
|
124
|
-
.map((file) => this.serializeAttachedFile(file, workspaceRoot))
|
|
90
|
+
const recentlyViewFiles = files
|
|
91
|
+
.filter((v) => !v.selection)
|
|
92
|
+
.map((file) => {
|
|
93
|
+
const relativePath = utils_1.URI.file(this.appConfig.workspaceDir).relative(file.uri);
|
|
94
|
+
if (relativePath) {
|
|
95
|
+
return relativePath.toString();
|
|
96
|
+
}
|
|
97
|
+
return file.uri.parent.toString();
|
|
98
|
+
})
|
|
125
99
|
.filter(Boolean);
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
100
|
+
const attachedFiles = files
|
|
101
|
+
.filter((v) => v.selection)
|
|
102
|
+
.map((file) => {
|
|
129
103
|
const ref = this.docModelManager.getModelReference(file.uri);
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
104
|
+
const content = ref.instance.getText();
|
|
105
|
+
const lineErrors = this.markerService
|
|
106
|
+
.getManager()
|
|
107
|
+
.getMarkers({
|
|
108
|
+
resource: file.uri.toString(),
|
|
109
|
+
severities: markers_1.MarkerSeverity.Error,
|
|
110
|
+
})
|
|
111
|
+
.map((marker) => marker.message);
|
|
133
112
|
return {
|
|
134
|
-
content
|
|
135
|
-
lineErrors
|
|
136
|
-
path:
|
|
137
|
-
language: ref.instance.languageId,
|
|
113
|
+
content,
|
|
114
|
+
lineErrors,
|
|
115
|
+
path: utils_1.URI.file(this.appConfig.workspaceDir).relative(file.uri).toString(),
|
|
116
|
+
language: ref === null || ref === void 0 ? void 0 : ref.instance.languageId,
|
|
138
117
|
};
|
|
139
|
-
}
|
|
140
|
-
catch (e) {
|
|
141
|
-
return null;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
getFileErrors(uri) {
|
|
145
|
-
return this.markerService
|
|
146
|
-
.getManager()
|
|
147
|
-
.getMarkers({
|
|
148
|
-
resource: uri.toString(),
|
|
149
|
-
severities: markers_1.MarkerSeverity.Error,
|
|
150
118
|
})
|
|
151
|
-
.
|
|
119
|
+
.filter(Boolean);
|
|
120
|
+
return {
|
|
121
|
+
recentlyViewFiles,
|
|
122
|
+
attachedFiles,
|
|
123
|
+
};
|
|
152
124
|
}
|
|
153
125
|
};
|
|
154
126
|
exports.LLMContextServiceImpl = 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,kEAAwE;AAKjE,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,8BAAY;IAAhD;;QAUG,qBAAgB,GAAG,KAAK,CAAC;
|
|
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;AAKjE,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,8BAAY;IAAhD;;QAUG,qBAAgB,GAAG,KAAK,CAAC;QAEzB,iBAAY,GAAkB,EAAE,CAAC;QAEjC,aAAQ,GAAW,EAAE,CAAC,CAAC,aAAa;QAEpC,mCAA8B,GAAG,IAAI,eAAO,EAAiB,CAAC;QACtE,iCAA4B,GAAG,IAAI,CAAC,8BAA8B,CAAC,KA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GAAG,GAAG,IAAI,CAAC,eAAe,CAAC,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC7D,MAAM,OAAO,GAAG,GAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YACxC,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa;iBAClC,UAAU,EAAE;iBACZ,UAAU,CAAC;gBACV,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE;gBAC7B,UAAU,EAAE,wBAAc,CAAC,KAAK;aACjC,CAAC;iBACD,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAEnC,OAAO;gBACL,OAAO;gBACP,UAAU;gBACV,IAAI,EAAE,WAAG,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAE,CAAC,QAAQ,EAAE;gBAC1E,QAAQ,EAAE,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,QAAQ,CAAC,UAAW;aACpC,CAAC;QACJ,CAAC,CAAC;aACD,MAAM,CAAC,OAAO,CAAC,CAAC;QAEnB,OAAO;YACL,iBAAiB;YACjB,aAAa;SACd,CAAC;IACJ,CAAC;CACF,CAAA;AAtJY,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,CAsJjC"}
|
|
@@ -10,31 +10,28 @@ export interface LLMContextService {
|
|
|
10
10
|
* 清除上下文
|
|
11
11
|
*/
|
|
12
12
|
cleanFileContext(): void;
|
|
13
|
-
onDidContextFilesChangeEvent: Event<
|
|
14
|
-
viewed: FileContext[];
|
|
15
|
-
attached: FileContext[];
|
|
16
|
-
}>;
|
|
13
|
+
onDidContextFilesChangeEvent: Event<FileContext[]>;
|
|
17
14
|
/**
|
|
18
15
|
* 从 context 中移除文件
|
|
19
16
|
* @param uri URI
|
|
20
17
|
*/
|
|
21
|
-
removeFileFromContext(uri: URI
|
|
18
|
+
removeFileFromContext(uri: URI): void;
|
|
22
19
|
/** 导出为可序列化格式 */
|
|
23
20
|
serialize(): SerializedContext;
|
|
24
21
|
}
|
|
25
22
|
export interface FileContext {
|
|
26
23
|
uri: URI;
|
|
27
24
|
selection?: [number, number];
|
|
25
|
+
isManual: boolean;
|
|
28
26
|
}
|
|
29
27
|
export declare const LLMContextServiceToken: unique symbol;
|
|
30
|
-
export interface AttachFileContext {
|
|
31
|
-
content: string;
|
|
32
|
-
lineErrors: string[];
|
|
33
|
-
path: string;
|
|
34
|
-
language: string;
|
|
35
|
-
}
|
|
36
28
|
export interface SerializedContext {
|
|
37
29
|
recentlyViewFiles: string[];
|
|
38
|
-
attachedFiles: Array<
|
|
30
|
+
attachedFiles: Array<{
|
|
31
|
+
content: string;
|
|
32
|
+
lineErrors: string[];
|
|
33
|
+
path: string;
|
|
34
|
+
language: string;
|
|
35
|
+
}>;
|
|
39
36
|
}
|
|
40
37
|
//# 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,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
|
|
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,WAAW,EAAE,CAAC,CAAC;IAEnD;;;OAGG;IACH,qBAAqB,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC;IAEtC,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;IAC7B,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,sBAAsB,eAA8B,CAAC;AAElE,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,aAAa,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,EAAE,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACjG"}
|
|
@@ -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":";;;AAmCa,QAAA,sBAAsB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensumi/ide-ai-native",
|
|
3
|
-
"version": "3.8.1-next-
|
|
3
|
+
"version": "3.8.1-next-1740452912.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib",
|
|
6
6
|
"src"
|
|
@@ -23,26 +23,26 @@
|
|
|
23
23
|
"@ai-sdk/deepseek": "^0.1.8",
|
|
24
24
|
"@ai-sdk/openai": "^1.1.9",
|
|
25
25
|
"@modelcontextprotocol/sdk": "^1.3.1",
|
|
26
|
-
"@opensumi/ide-addons": "3.8.1-next-
|
|
27
|
-
"@opensumi/ide-components": "3.8.1-next-
|
|
28
|
-
"@opensumi/ide-connection": "3.8.1-next-
|
|
29
|
-
"@opensumi/ide-core-common": "3.8.1-next-
|
|
30
|
-
"@opensumi/ide-core-node": "3.8.1-next-
|
|
31
|
-
"@opensumi/ide-debug": "3.8.1-next-
|
|
32
|
-
"@opensumi/ide-design": "3.8.1-next-
|
|
33
|
-
"@opensumi/ide-editor": "3.8.1-next-
|
|
34
|
-
"@opensumi/ide-file-search": "3.8.1-next-
|
|
35
|
-
"@opensumi/ide-file-service": "3.8.1-next-
|
|
36
|
-
"@opensumi/ide-main-layout": "3.8.1-next-
|
|
37
|
-
"@opensumi/ide-markers": "3.8.1-next-
|
|
38
|
-
"@opensumi/ide-monaco": "3.8.1-next-
|
|
39
|
-
"@opensumi/ide-overlay": "3.8.1-next-
|
|
40
|
-
"@opensumi/ide-preferences": "3.8.1-next-
|
|
41
|
-
"@opensumi/ide-search": "3.8.1-next-
|
|
42
|
-
"@opensumi/ide-terminal-next": "3.8.1-next-
|
|
43
|
-
"@opensumi/ide-theme": "3.8.1-next-
|
|
44
|
-
"@opensumi/ide-utils": "3.8.1-next-
|
|
45
|
-
"@opensumi/ide-workspace": "3.8.1-next-
|
|
26
|
+
"@opensumi/ide-addons": "3.8.1-next-1740452912.0",
|
|
27
|
+
"@opensumi/ide-components": "3.8.1-next-1740452912.0",
|
|
28
|
+
"@opensumi/ide-connection": "3.8.1-next-1740452912.0",
|
|
29
|
+
"@opensumi/ide-core-common": "3.8.1-next-1740452912.0",
|
|
30
|
+
"@opensumi/ide-core-node": "3.8.1-next-1740452912.0",
|
|
31
|
+
"@opensumi/ide-debug": "3.8.1-next-1740452912.0",
|
|
32
|
+
"@opensumi/ide-design": "3.8.1-next-1740452912.0",
|
|
33
|
+
"@opensumi/ide-editor": "3.8.1-next-1740452912.0",
|
|
34
|
+
"@opensumi/ide-file-search": "3.8.1-next-1740452912.0",
|
|
35
|
+
"@opensumi/ide-file-service": "3.8.1-next-1740452912.0",
|
|
36
|
+
"@opensumi/ide-main-layout": "3.8.1-next-1740452912.0",
|
|
37
|
+
"@opensumi/ide-markers": "3.8.1-next-1740452912.0",
|
|
38
|
+
"@opensumi/ide-monaco": "3.8.1-next-1740452912.0",
|
|
39
|
+
"@opensumi/ide-overlay": "3.8.1-next-1740452912.0",
|
|
40
|
+
"@opensumi/ide-preferences": "3.8.1-next-1740452912.0",
|
|
41
|
+
"@opensumi/ide-search": "3.8.1-next-1740452912.0",
|
|
42
|
+
"@opensumi/ide-terminal-next": "3.8.1-next-1740452912.0",
|
|
43
|
+
"@opensumi/ide-theme": "3.8.1-next-1740452912.0",
|
|
44
|
+
"@opensumi/ide-utils": "3.8.1-next-1740452912.0",
|
|
45
|
+
"@opensumi/ide-workspace": "3.8.1-next-1740452912.0",
|
|
46
46
|
"@xterm/xterm": "5.5.0",
|
|
47
47
|
"ai": "^4.1.21",
|
|
48
48
|
"ansi-regex": "^2.0.0",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"zod-to-json-schema": "^3.24.1"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@opensumi/ide-core-browser": "3.8.1-next-
|
|
60
|
+
"@opensumi/ide-core-browser": "3.8.1-next-1740452912.0"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "8a0d401874c0cb4ce0cf8f56c8bd636e0cf8b04e"
|
|
63
63
|
}
|
|
@@ -39,7 +39,7 @@ export const ChatContext = memo(() => {
|
|
|
39
39
|
50,
|
|
40
40
|
)((files) => {
|
|
41
41
|
if (files) {
|
|
42
|
-
updateAddedFiles(
|
|
42
|
+
updateAddedFiles(files);
|
|
43
43
|
}
|
|
44
44
|
}, contextService);
|
|
45
45
|
|
|
@@ -57,7 +57,7 @@ export const ChatContext = memo(() => {
|
|
|
57
57
|
}, []);
|
|
58
58
|
|
|
59
59
|
const onDidDeselect = useCallback((uri: URI) => {
|
|
60
|
-
contextService.removeFileFromContext(uri
|
|
60
|
+
contextService.removeFileFromContext(uri);
|
|
61
61
|
}, []);
|
|
62
62
|
|
|
63
63
|
const onDidClickFile = useCallback((uri: URI) => {
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
import { EditorSelectionChangeEvent } from '@opensumi/ide-editor/lib/browser/types';
|
|
13
13
|
import { IMarkerService } from '@opensumi/ide-markers/lib/common/types';
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import { FileContext, LLMContextService, SerializedContext } from '../../common/llm-context';
|
|
16
16
|
|
|
17
17
|
@Injectable()
|
|
18
18
|
export class LLMContextServiceImpl extends WithEventBus implements LLMContextService {
|
|
@@ -27,61 +27,40 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
|
|
|
27
27
|
|
|
28
28
|
private isAutoCollecting = false;
|
|
29
29
|
|
|
30
|
-
private
|
|
31
|
-
private readonly maxViewFilesLimit = 20;
|
|
32
|
-
private readonly attachedFiles: FileContext[] = [];
|
|
33
|
-
private readonly recentlyViewFiles: FileContext[] = [];
|
|
34
|
-
private readonly onDidContextFilesChangeEmitter = new Emitter<{ viewed: FileContext[]; attached: FileContext[] }>();
|
|
35
|
-
onDidContextFilesChangeEvent = this.onDidContextFilesChangeEmitter.event;
|
|
30
|
+
private contextFiles: FileContext[] = [];
|
|
36
31
|
|
|
37
|
-
private
|
|
38
|
-
const existingIndex = list.findIndex((f) => f.uri.toString() === file.uri.toString());
|
|
39
|
-
if (existingIndex > -1) {
|
|
40
|
-
list.splice(existingIndex, 1);
|
|
41
|
-
}
|
|
32
|
+
private maxFiles: number = 10; // 上下文的最大长度限制
|
|
42
33
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
list.shift();
|
|
46
|
-
}
|
|
47
|
-
}
|
|
34
|
+
private onDidContextFilesChangeEmitter = new Emitter<FileContext[]>();
|
|
35
|
+
onDidContextFilesChangeEvent = this.onDidContextFilesChangeEmitter.event;
|
|
48
36
|
|
|
49
|
-
addFileToContext(uri: URI, selection?: [number, number], isManual =
|
|
50
|
-
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
37
|
+
addFileToContext(uri: URI, selection?: [number, number], isManual = true): void {
|
|
38
|
+
this.removeFileFromContext(uri);
|
|
53
39
|
|
|
54
|
-
|
|
55
|
-
const targetList = isManual ? this.attachedFiles : this.recentlyViewFiles;
|
|
56
|
-
const maxLimit = isManual ? this.maxAttachFilesLimit : this.maxViewFilesLimit;
|
|
40
|
+
this.contextFiles.push({ uri, selection, isManual });
|
|
57
41
|
|
|
58
|
-
this.
|
|
59
|
-
|
|
60
|
-
|
|
42
|
+
if (this.contextFiles.length > this.maxFiles) {
|
|
43
|
+
this.contextFiles.shift();
|
|
44
|
+
}
|
|
61
45
|
|
|
62
|
-
private notifyContextChange(): void {
|
|
63
46
|
this.onDidContextFilesChangeEmitter.fire(this.getAllContextFiles());
|
|
64
47
|
}
|
|
65
48
|
|
|
66
49
|
cleanFileContext() {
|
|
67
|
-
this.
|
|
68
|
-
this.
|
|
50
|
+
this.contextFiles = [];
|
|
51
|
+
this.onDidContextFilesChangeEmitter.fire(this.getAllContextFiles());
|
|
69
52
|
}
|
|
70
53
|
|
|
71
54
|
private getAllContextFiles() {
|
|
72
|
-
return
|
|
73
|
-
viewed: this.recentlyViewFiles,
|
|
74
|
-
attached: this.attachedFiles,
|
|
75
|
-
};
|
|
55
|
+
return [...this.contextFiles];
|
|
76
56
|
}
|
|
77
57
|
|
|
78
|
-
removeFileFromContext(uri: URI
|
|
79
|
-
const
|
|
80
|
-
const index = targetList.findIndex((file) => file.uri.toString() === uri.toString());
|
|
58
|
+
removeFileFromContext(uri: URI): void {
|
|
59
|
+
const index = this.contextFiles.findIndex((file) => file.uri.toString() === uri.toString());
|
|
81
60
|
if (index > -1) {
|
|
82
|
-
|
|
61
|
+
this.contextFiles.splice(index, 1);
|
|
62
|
+
this.onDidContextFilesChangeEmitter.fire(this.getAllContextFiles());
|
|
83
63
|
}
|
|
84
|
-
this.notifyContextChange();
|
|
85
64
|
}
|
|
86
65
|
|
|
87
66
|
startAutoCollection(): void {
|
|
@@ -99,7 +78,8 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
|
|
|
99
78
|
if (event.payload.uri.scheme !== 'file') {
|
|
100
79
|
return;
|
|
101
80
|
}
|
|
102
|
-
|
|
81
|
+
// FIXME: 暂时不自动添加
|
|
82
|
+
// this.addFileToContext(event.payload.uri);
|
|
103
83
|
}),
|
|
104
84
|
);
|
|
105
85
|
|
|
@@ -108,8 +88,6 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
|
|
|
108
88
|
if (event.payload.scheme !== 'file') {
|
|
109
89
|
return;
|
|
110
90
|
}
|
|
111
|
-
|
|
112
|
-
this.removeFileFromContext(event.payload, false);
|
|
113
91
|
}),
|
|
114
92
|
);
|
|
115
93
|
|
|
@@ -131,12 +109,11 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
|
|
|
131
109
|
].sort() as [number, number];
|
|
132
110
|
|
|
133
111
|
if (selection[0] === selection[1]) {
|
|
134
|
-
this.addFileToContext(event.payload.editorUri, undefined
|
|
112
|
+
this.addFileToContext(event.payload.editorUri, undefined);
|
|
135
113
|
} else {
|
|
136
114
|
this.addFileToContext(
|
|
137
115
|
event.payload.editorUri,
|
|
138
116
|
selection.sort((a, b) => a - b),
|
|
139
|
-
false,
|
|
140
117
|
);
|
|
141
118
|
}
|
|
142
119
|
}
|
|
@@ -150,51 +127,42 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
|
|
|
150
127
|
|
|
151
128
|
serialize(): SerializedContext {
|
|
152
129
|
const files = this.getAllContextFiles();
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
return files
|
|
163
|
-
.map((file) => workspaceRoot.relative(file.uri)?.toString() || file.uri.parent.toString())
|
|
130
|
+
const recentlyViewFiles = files
|
|
131
|
+
.filter((v) => !v.selection)
|
|
132
|
+
.map((file) => {
|
|
133
|
+
const relativePath = URI.file(this.appConfig.workspaceDir).relative(file.uri);
|
|
134
|
+
if (relativePath) {
|
|
135
|
+
return relativePath.toString();
|
|
136
|
+
}
|
|
137
|
+
return file.uri.parent.toString();
|
|
138
|
+
})
|
|
164
139
|
.filter(Boolean);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
private serializeAttachedFiles(files: FileContext[], workspaceRoot: URI): AttachFileContext[] {
|
|
168
|
-
return files
|
|
169
|
-
.map((file) => this.serializeAttachedFile(file, workspaceRoot))
|
|
170
|
-
.filter(Boolean) as unknown as AttachFileContext[];
|
|
171
|
-
}
|
|
172
140
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
return this.markerService
|
|
193
|
-
.getManager()
|
|
194
|
-
.getMarkers({
|
|
195
|
-
resource: uri.toString(),
|
|
196
|
-
severities: MarkerSeverity.Error,
|
|
141
|
+
const attachedFiles = files
|
|
142
|
+
.filter((v) => v.selection)
|
|
143
|
+
.map((file) => {
|
|
144
|
+
const ref = this.docModelManager.getModelReference(file.uri);
|
|
145
|
+
const content = ref!.instance.getText();
|
|
146
|
+
const lineErrors = this.markerService
|
|
147
|
+
.getManager()
|
|
148
|
+
.getMarkers({
|
|
149
|
+
resource: file.uri.toString(),
|
|
150
|
+
severities: MarkerSeverity.Error,
|
|
151
|
+
})
|
|
152
|
+
.map((marker) => marker.message);
|
|
153
|
+
|
|
154
|
+
return {
|
|
155
|
+
content,
|
|
156
|
+
lineErrors,
|
|
157
|
+
path: URI.file(this.appConfig.workspaceDir).relative(file.uri)!.toString(),
|
|
158
|
+
language: ref?.instance.languageId!,
|
|
159
|
+
};
|
|
197
160
|
})
|
|
198
|
-
.
|
|
161
|
+
.filter(Boolean);
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
recentlyViewFiles,
|
|
165
|
+
attachedFiles,
|
|
166
|
+
};
|
|
199
167
|
}
|
|
200
168
|
}
|
|
@@ -15,13 +15,13 @@ export interface LLMContextService {
|
|
|
15
15
|
*/
|
|
16
16
|
cleanFileContext(): void;
|
|
17
17
|
|
|
18
|
-
onDidContextFilesChangeEvent: Event<
|
|
18
|
+
onDidContextFilesChangeEvent: Event<FileContext[]>;
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* 从 context 中移除文件
|
|
22
22
|
* @param uri URI
|
|
23
23
|
*/
|
|
24
|
-
removeFileFromContext(uri: URI
|
|
24
|
+
removeFileFromContext(uri: URI): void;
|
|
25
25
|
|
|
26
26
|
/** 导出为可序列化格式 */
|
|
27
27
|
serialize(): SerializedContext;
|
|
@@ -30,18 +30,12 @@ export interface LLMContextService {
|
|
|
30
30
|
export interface FileContext {
|
|
31
31
|
uri: URI;
|
|
32
32
|
selection?: [number, number];
|
|
33
|
+
isManual: boolean;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
export const LLMContextServiceToken = Symbol('LLMContextService');
|
|
36
37
|
|
|
37
|
-
export interface AttachFileContext {
|
|
38
|
-
content: string;
|
|
39
|
-
lineErrors: string[];
|
|
40
|
-
path: string;
|
|
41
|
-
language: string;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
38
|
export interface SerializedContext {
|
|
45
39
|
recentlyViewFiles: string[];
|
|
46
|
-
attachedFiles: Array<
|
|
40
|
+
attachedFiles: Array<{ content: string; lineErrors: string[]; path: string; language: string }>;
|
|
47
41
|
}
|