@opensumi/ide-ai-native 3.9.1-next-1749003325.0 → 3.9.1-next-1749007675.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-manager.service.d.ts +1 -0
- package/lib/browser/chat/chat-manager.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-manager.service.js +8 -3
- package/lib/browser/chat/chat-manager.service.js.map +1 -1
- package/lib/browser/chat/chat-model.d.ts +3 -1
- package/lib/browser/chat/chat-model.d.ts.map +1 -1
- package/lib/browser/chat/chat-model.js +48 -17
- package/lib/browser/chat/chat-model.js.map +1 -1
- package/lib/browser/chat/chat-proxy.service.d.ts +2 -0
- package/lib/browser/chat/chat-proxy.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-proxy.service.js +57 -50
- package/lib/browser/chat/chat-proxy.service.js.map +1 -1
- package/lib/browser/chat/chat.feature.registry.d.ts +4 -1
- package/lib/browser/chat/chat.feature.registry.d.ts.map +1 -1
- package/lib/browser/chat/chat.feature.registry.js +6 -0
- package/lib/browser/chat/chat.feature.registry.js.map +1 -1
- package/lib/browser/chat/chat.view.d.ts.map +1 -1
- package/lib/browser/chat/chat.view.js +29 -12
- package/lib/browser/chat/chat.view.js.map +1 -1
- package/lib/browser/components/ChatMentionInput.d.ts.map +1 -1
- package/lib/browser/components/ChatMentionInput.js +30 -141
- package/lib/browser/components/ChatMentionInput.js.map +1 -1
- package/lib/browser/components/ChatToolRender.module.less +0 -1
- package/lib/browser/components/components.module.less +7 -9
- package/lib/browser/components/mention-input/mention-input.d.ts.map +1 -1
- package/lib/browser/components/mention-input/mention-input.js +14 -161
- package/lib/browser/components/mention-input/mention-input.js.map +1 -1
- package/lib/browser/components/mention-input/mention-input.module.less +1 -165
- package/lib/browser/components/mention-input/types.d.ts +1 -16
- package/lib/browser/components/mention-input/types.d.ts.map +1 -1
- package/lib/browser/components/mention-input/types.js +0 -1
- package/lib/browser/components/mention-input/types.js.map +1 -1
- package/lib/browser/components/utils.d.ts +2 -2
- package/lib/browser/context/llm-context.service.d.ts +2 -21
- package/lib/browser/context/llm-context.service.d.ts.map +1 -1
- package/lib/browser/context/llm-context.service.js +20 -162
- package/lib/browser/context/llm-context.service.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/decoration/additions-deletions.decoration.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/decoration/additions-deletions.decoration.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/diff-computer.js +1 -1
- package/lib/browser/contrib/intelligent-completions/diff-computer.js.map +1 -1
- package/lib/browser/contrib/terminal/terminal.feature.registry.js.map +1 -1
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +0 -7
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/mcp/base-apply.service.d.ts +2 -2
- package/lib/browser/mcp/base-apply.service.d.ts.map +1 -1
- package/lib/browser/mcp/base-apply.service.js.map +1 -1
- package/lib/browser/mcp/tools/getDiagnosticsByPath.js.map +1 -1
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.js.map +1 -1
- package/lib/browser/mcp/tools/handlers/ListDir.js.map +1 -1
- package/lib/browser/mcp/tools/runTerminalCmd.js.map +1 -1
- package/lib/browser/model/msg-history-manager.d.ts +39 -1
- package/lib/browser/model/msg-history-manager.d.ts.map +1 -1
- package/lib/browser/model/msg-history-manager.js +170 -3
- package/lib/browser/model/msg-history-manager.js.map +1 -1
- package/lib/browser/preferences/schema.d.ts.map +1 -1
- package/lib/browser/preferences/schema.js +0 -5
- package/lib/browser/preferences/schema.js.map +1 -1
- package/lib/browser/types.d.ts +8 -1
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/types.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.component.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.component.js.map +1 -1
- package/lib/common/index.d.ts +0 -2
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +0 -2
- package/lib/common/index.js.map +1 -1
- package/lib/common/llm-context.d.ts +0 -19
- 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 -0
- package/lib/common/prompts/context-prompt-provider.d.ts.map +1 -1
- package/lib/common/prompts/context-prompt-provider.js +29 -35
- package/lib/common/prompts/context-prompt-provider.js.map +1 -1
- package/lib/common/types.d.ts +0 -7
- package/lib/common/types.d.ts.map +1 -1
- package/lib/node/base-language-model.d.ts.map +1 -1
- package/lib/node/base-language-model.js.map +1 -1
- package/package.json +24 -25
- package/src/browser/chat/chat-manager.service.ts +15 -6
- package/src/browser/chat/chat-model.ts +56 -19
- package/src/browser/chat/chat-proxy.service.ts +81 -68
- package/src/browser/chat/chat.feature.registry.ts +17 -1
- package/src/browser/chat/chat.view.tsx +28 -22
- package/src/browser/components/ChatMentionInput.tsx +35 -169
- package/src/browser/components/ChatToolRender.module.less +0 -1
- package/src/browser/components/components.module.less +7 -9
- package/src/browser/components/mention-input/mention-input.module.less +1 -165
- package/src/browser/components/mention-input/mention-input.tsx +32 -257
- package/src/browser/components/mention-input/types.ts +0 -16
- package/src/browser/context/llm-context.service.ts +21 -182
- package/src/browser/contrib/intelligent-completions/decoration/additions-deletions.decoration.ts +1 -1
- package/src/browser/contrib/intelligent-completions/diff-computer.ts +1 -1
- package/src/browser/contrib/terminal/terminal.feature.registry.ts +1 -1
- package/src/browser/index.ts +0 -8
- package/src/browser/mcp/base-apply.service.ts +1 -0
- package/src/browser/mcp/tools/getDiagnosticsByPath.ts +1 -1
- package/src/browser/mcp/tools/getOpenEditorFileDiagnostics.ts +1 -1
- package/src/browser/mcp/tools/handlers/ListDir.ts +1 -1
- package/src/browser/mcp/tools/runTerminalCmd.ts +1 -1
- package/src/browser/model/msg-history-manager.ts +230 -3
- package/src/browser/preferences/schema.ts +0 -5
- package/src/browser/types.ts +12 -0
- package/src/browser/widget/inline-stream-diff/live-preview.component.tsx +1 -0
- package/src/common/index.ts +0 -3
- package/src/common/llm-context.ts +0 -23
- package/src/common/prompts/context-prompt-provider.ts +40 -55
- package/src/common/types.ts +0 -8
- package/src/node/base-language-model.ts +1 -0
- package/lib/browser/components/mention-input/mention-select.d.ts +0 -28
- package/lib/browser/components/mention-input/mention-select.d.ts.map +0 -1
- package/lib/browser/components/mention-input/mention-select.js +0 -136
- package/lib/browser/components/mention-input/mention-select.js.map +0 -1
- package/lib/browser/components/mention-input/mention-select.module.less +0 -297
- package/lib/browser/rules/rules.contribution.d.ts +0 -29
- package/lib/browser/rules/rules.contribution.d.ts.map +0 -1
- package/lib/browser/rules/rules.contribution.js +0 -94
- package/lib/browser/rules/rules.contribution.js.map +0 -1
- package/lib/browser/rules/rules.module.less +0 -175
- package/lib/browser/rules/rules.service.d.ts +0 -25
- package/lib/browser/rules/rules.service.d.ts.map +0 -1
- package/lib/browser/rules/rules.service.js +0 -180
- package/lib/browser/rules/rules.service.js.map +0 -1
- package/lib/browser/rules/rules.view.d.ts +0 -3
- package/lib/browser/rules/rules.view.d.ts.map +0 -1
- package/lib/browser/rules/rules.view.js +0 -76
- package/lib/browser/rules/rules.view.js.map +0 -1
- package/lib/common/MDC_PARSER_README.md +0 -171
- package/lib/common/mdc-parser.d.ts +0 -60
- package/lib/common/mdc-parser.d.ts.map +0 -1
- package/lib/common/mdc-parser.js +0 -246
- package/lib/common/mdc-parser.js.map +0 -1
- package/lib/common/prompts/system-prompt.d.ts +0 -2
- package/lib/common/prompts/system-prompt.d.ts.map +0 -1
- package/lib/common/prompts/system-prompt.js +0 -5
- package/lib/common/prompts/system-prompt.js.map +0 -1
- package/src/browser/components/mention-input/mention-select.module.less +0 -297
- package/src/browser/components/mention-input/mention-select.tsx +0 -256
- package/src/browser/rules/rules.contribution.ts +0 -105
- package/src/browser/rules/rules.module.less +0 -175
- package/src/browser/rules/rules.service.ts +0 -189
- package/src/browser/rules/rules.view.tsx +0 -127
- package/src/common/MDC_PARSER_README.md +0 -171
- package/src/common/mdc-parser.ts +0 -295
- package/src/common/prompts/system-prompt.ts +0 -2
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { DataContent } from 'ai';
|
|
2
|
+
|
|
1
3
|
import { Autowired, Injectable } from '@opensumi/di';
|
|
2
|
-
import { PreferenceService } from '@opensumi/ide-core-browser';
|
|
3
4
|
import { AppConfig } from '@opensumi/ide-core-browser/lib/react-providers/config-provider';
|
|
4
|
-
import { AINativeSettingSectionsId, IApplicationService, RulesServiceToken } from '@opensumi/ide-core-common';
|
|
5
5
|
import { WithEventBus } from '@opensumi/ide-core-common/lib/event-bus/event-decorator';
|
|
6
6
|
import { MarkerSeverity } from '@opensumi/ide-core-common/lib/types/markers/markers';
|
|
7
|
-
import { Emitter,
|
|
7
|
+
import { Emitter, URI } from '@opensumi/ide-core-common/lib/utils';
|
|
8
8
|
import {
|
|
9
9
|
EditorDocumentModelCreationEvent,
|
|
10
10
|
EditorDocumentModelRemovalEvent,
|
|
@@ -15,12 +15,8 @@ import { EditorSelectionChangeEvent } from '@opensumi/ide-editor/lib/browser/typ
|
|
|
15
15
|
import { FileType, IFileServiceClient } from '@opensumi/ide-file-service';
|
|
16
16
|
import { IMarkerService } from '@opensumi/ide-markers/lib/common/types';
|
|
17
17
|
import { Range } from '@opensumi/ide-monaco';
|
|
18
|
-
import { ITerminalApiService } from '@opensumi/ide-terminal-next';
|
|
19
|
-
import { isString, match } from '@opensumi/ide-utils';
|
|
20
18
|
|
|
21
19
|
import { AttachFileContext, FileContext, LLMContextService, SerializedContext } from '../../common/llm-context';
|
|
22
|
-
import { ProjectRule } from '../../common/types';
|
|
23
|
-
import { RulesService } from '../rules/rules.service';
|
|
24
20
|
|
|
25
21
|
@Injectable()
|
|
26
22
|
export class LLMContextServiceImpl extends WithEventBus implements LLMContextService {
|
|
@@ -36,18 +32,6 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
|
|
|
36
32
|
@Autowired(IFileServiceClient)
|
|
37
33
|
protected readonly fileService: IFileServiceClient;
|
|
38
34
|
|
|
39
|
-
@Autowired(RulesServiceToken)
|
|
40
|
-
protected readonly rulesService: RulesService;
|
|
41
|
-
|
|
42
|
-
@Autowired(PreferenceService)
|
|
43
|
-
protected readonly preferenceService: PreferenceService;
|
|
44
|
-
|
|
45
|
-
@Autowired(ITerminalApiService)
|
|
46
|
-
protected readonly terminalService: ITerminalApiService;
|
|
47
|
-
|
|
48
|
-
@Autowired(IApplicationService)
|
|
49
|
-
protected readonly applicationService: IApplicationService;
|
|
50
|
-
|
|
51
35
|
private isAutoCollecting = false;
|
|
52
36
|
|
|
53
37
|
private contextVersion = 0;
|
|
@@ -57,13 +41,11 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
|
|
|
57
41
|
private readonly maxViewFilesLimit = 20;
|
|
58
42
|
private attachedFiles: FileContext[] = [];
|
|
59
43
|
private attachedFolders: FileContext[] = [];
|
|
60
|
-
private attachedRules: ProjectRule[] = [];
|
|
61
44
|
private readonly recentlyViewFiles: FileContext[] = [];
|
|
62
45
|
private readonly onDidContextFilesChangeEmitter = new Emitter<{
|
|
63
46
|
viewed: FileContext[];
|
|
64
47
|
attached: FileContext[];
|
|
65
48
|
attachedFolders: FileContext[];
|
|
66
|
-
attachedRules: ProjectRule[];
|
|
67
49
|
version: number;
|
|
68
50
|
}>();
|
|
69
51
|
private hasUserManualReference = false;
|
|
@@ -98,24 +80,6 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
|
|
|
98
80
|
}
|
|
99
81
|
}
|
|
100
82
|
|
|
101
|
-
addRuleToContext(uri: URI): void {
|
|
102
|
-
if (!uri) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (this.attachedRules.some((rule) => rule.path === uri.toString())) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const rule = this.rulesService.projectRules.find((rule) => rule.path === uri.toString());
|
|
111
|
-
if (!rule) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
this.attachedRules.push(rule);
|
|
116
|
-
this.notifyContextChange();
|
|
117
|
-
}
|
|
118
|
-
|
|
119
83
|
addFileToContext(uri: URI, selection?: [number, number], isManual = false): void {
|
|
120
84
|
if (!uri) {
|
|
121
85
|
return;
|
|
@@ -153,7 +117,6 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
|
|
|
153
117
|
this.attachedFiles = [];
|
|
154
118
|
this.attachedFolders = [];
|
|
155
119
|
this.hasUserManualReference = false;
|
|
156
|
-
this.attachedRules = [];
|
|
157
120
|
this.notifyContextChange();
|
|
158
121
|
}
|
|
159
122
|
|
|
@@ -162,7 +125,6 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
|
|
|
162
125
|
viewed: this.recentlyViewFiles,
|
|
163
126
|
attached: this.attachedFiles,
|
|
164
127
|
attachedFolders: this.attachedFolders,
|
|
165
|
-
attachedRules: this.attachedRules,
|
|
166
128
|
version: this.contextVersion++,
|
|
167
129
|
};
|
|
168
130
|
}
|
|
@@ -181,24 +143,6 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
|
|
|
181
143
|
this.notifyContextChange();
|
|
182
144
|
}
|
|
183
145
|
|
|
184
|
-
removeFolderFromContext(uri: URI): void {
|
|
185
|
-
const targetList = this.attachedFolders;
|
|
186
|
-
const index = targetList.findIndex((folder) => folder.uri.toString() === uri.toString());
|
|
187
|
-
if (index > -1) {
|
|
188
|
-
targetList.splice(index, 1);
|
|
189
|
-
}
|
|
190
|
-
this.notifyContextChange();
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
removeRuleFromContext(uri: URI): void {
|
|
194
|
-
const targetList = this.attachedRules;
|
|
195
|
-
const index = targetList.findIndex((rule) => rule.path === uri.toString());
|
|
196
|
-
if (index > -1) {
|
|
197
|
-
targetList.splice(index, 1);
|
|
198
|
-
}
|
|
199
|
-
this.notifyContextChange();
|
|
200
|
-
}
|
|
201
|
-
|
|
202
146
|
startAutoCollection(): void {
|
|
203
147
|
if (this.isAutoCollecting) {
|
|
204
148
|
return;
|
|
@@ -273,35 +217,25 @@ export class LLMContextServiceImpl extends WithEventBus implements LLMContextSer
|
|
|
273
217
|
return {
|
|
274
218
|
recentlyViewFiles: this.serializeRecentlyViewFiles(files.viewed, workspaceRoot),
|
|
275
219
|
attachedFiles: this.serializeAttachedFiles(files.attached, workspaceRoot),
|
|
276
|
-
attachedFolders: await this.serializeAttachedFolders(files.attachedFolders),
|
|
277
|
-
attachedRules: this.serializeAttachedRules(files.attachedRules),
|
|
278
|
-
globalRules: this.serializeGlobalRules(),
|
|
220
|
+
attachedFolders: await this.serializeAttachedFolders(files.attachedFolders, workspaceRoot),
|
|
279
221
|
};
|
|
280
222
|
}
|
|
281
223
|
|
|
282
|
-
private async serializeAttachedFolders(folders: FileContext[]): Promise<string[]> {
|
|
224
|
+
private async serializeAttachedFolders(folders: FileContext[], workspaceRoot: URI): Promise<string[]> {
|
|
283
225
|
// 去重
|
|
284
226
|
const folderPath = Array.from(new Set(folders.map((folder) => folder.uri.toString())));
|
|
285
|
-
|
|
286
|
-
const folderSections = await Promise.all(
|
|
227
|
+
return Promise.all(
|
|
287
228
|
folderPath.map(async (folder) => {
|
|
288
229
|
const folderUri = new URI(folder);
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
Contents of directory:
|
|
294
|
-
|
|
295
|
-
${folderStructure}`;
|
|
230
|
+
const root = workspaceRoot.relative(folderUri)?.toString() || '/';
|
|
231
|
+
return `\`\`\`\n${root}\n${(await this.getPartiaFolderStructure(folderUri.codeUri.fsPath))
|
|
232
|
+
.map((line) => `- ${line}`)
|
|
233
|
+
.join('\n')}\n\`\`\`\n`;
|
|
296
234
|
}),
|
|
297
235
|
);
|
|
298
|
-
if (folderSections.length > 0) {
|
|
299
|
-
return [header, ...folderSections, ''];
|
|
300
|
-
}
|
|
301
|
-
return [];
|
|
302
236
|
}
|
|
303
237
|
|
|
304
|
-
private async
|
|
238
|
+
private async getPartiaFolderStructure(folder: string, level = 2): Promise<string[]> {
|
|
305
239
|
const result: string[] = [];
|
|
306
240
|
try {
|
|
307
241
|
const stat = await this.fileService.getFileStat(folder);
|
|
@@ -313,27 +247,28 @@ ${folderStructure}`;
|
|
|
313
247
|
// 处理软链接
|
|
314
248
|
const target = await this.fileService.getFileStat(child.realUri || child.uri);
|
|
315
249
|
if (target) {
|
|
316
|
-
result.push(
|
|
250
|
+
result.push(`${relativePath} -> ${target} (symbolic link)`);
|
|
317
251
|
} else {
|
|
318
|
-
result.push(
|
|
252
|
+
result.push(`${relativePath} (broken symbolic link)`);
|
|
319
253
|
}
|
|
320
254
|
continue;
|
|
321
255
|
}
|
|
322
256
|
|
|
323
257
|
if (child.type === FileType.Directory) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
258
|
+
result.push(`${relativePath}/`);
|
|
259
|
+
if (level > 1) {
|
|
260
|
+
const subDirStructure = await this.getPartiaFolderStructure(child.uri, level - 1);
|
|
261
|
+
result.push(...subDirStructure.map((subEntry) => `${relativePath}/${subEntry}`));
|
|
262
|
+
}
|
|
328
263
|
} else if (child.type === FileType.File) {
|
|
329
|
-
result.push(
|
|
264
|
+
result.push(relativePath);
|
|
330
265
|
}
|
|
331
266
|
}
|
|
332
267
|
} catch {
|
|
333
|
-
return
|
|
268
|
+
return result;
|
|
334
269
|
}
|
|
335
270
|
|
|
336
|
-
return result
|
|
271
|
+
return result;
|
|
337
272
|
}
|
|
338
273
|
|
|
339
274
|
private serializeRecentlyViewFiles(files: FileContext[], workspaceRoot: URI): string[] {
|
|
@@ -360,7 +295,6 @@ ${folderStructure}`;
|
|
|
360
295
|
lineErrors: this.getFileErrors(file.uri),
|
|
361
296
|
path: workspaceRoot.relative(file.uri)!.toString(),
|
|
362
297
|
language: ref.instance.languageId!,
|
|
363
|
-
selection: file.selection,
|
|
364
298
|
};
|
|
365
299
|
} catch (e) {
|
|
366
300
|
return null;
|
|
@@ -376,99 +310,4 @@ ${folderStructure}`;
|
|
|
376
310
|
})
|
|
377
311
|
.map((marker) => marker.message);
|
|
378
312
|
}
|
|
379
|
-
|
|
380
|
-
private serializeGlobalRules(): string[] {
|
|
381
|
-
const globalRules = this.preferenceService.get<string>(AINativeSettingSectionsId.GlobalRules);
|
|
382
|
-
if (!globalRules) {
|
|
383
|
-
return [];
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
const platform =
|
|
387
|
-
this.applicationService.backendOS === OperatingSystem.Windows
|
|
388
|
-
? 'windows'
|
|
389
|
-
: this.applicationService.backendOS === OperatingSystem.Linux
|
|
390
|
-
? 'linux'
|
|
391
|
-
: 'darwin';
|
|
392
|
-
const shell = this.preferenceService.get<string>('terminal.type', 'zsh');
|
|
393
|
-
let shellName = shell;
|
|
394
|
-
if (shell === 'default') {
|
|
395
|
-
shellName = this.applicationService.backendOS === OperatingSystem.Windows ? 'cmd' : 'zsh';
|
|
396
|
-
}
|
|
397
|
-
const userInfoSection = `<user_info>
|
|
398
|
-
The user's OS version is ${platform}. The absolute path of the user's workspace is ${this.appConfig.workspaceDir}. The user's shell is /bin/${shellName}.
|
|
399
|
-
</user_info>`;
|
|
400
|
-
|
|
401
|
-
const rulesSection = `
|
|
402
|
-
|
|
403
|
-
<rules>
|
|
404
|
-
The rules section has a number of possible rules/memories/context that you should consider. In each subsection, we provide instructions about what information the subsection contains and how you should consider/follow the contents of the subsection.
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
<user_specific_rule description="This is a rule set by the user that the agent must follow.">
|
|
408
|
-
${globalRules}
|
|
409
|
-
</user_specific_rule>
|
|
410
|
-
|
|
411
|
-
</rules>`;
|
|
412
|
-
|
|
413
|
-
return [userInfoSection, rulesSection];
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
private findApplicableRules(attachedRules: ProjectRule[]): ProjectRule[] {
|
|
417
|
-
const otherRules = this.rulesService.projectRules.filter(
|
|
418
|
-
(rule) => !attachedRules.some((attachedRule) => attachedRule.path === rule.path),
|
|
419
|
-
);
|
|
420
|
-
const requestedByAgentRules = otherRules.filter((rule) => rule.description);
|
|
421
|
-
const alwaysApplyRules = otherRules.filter((rule) => rule.alwaysApply);
|
|
422
|
-
const requestedByFileRules = this.findFileMatchingRules(otherRules);
|
|
423
|
-
|
|
424
|
-
return [...requestedByFileRules, ...requestedByAgentRules, ...alwaysApplyRules];
|
|
425
|
-
}
|
|
426
|
-
private findFileMatchingRules(otherRules: ProjectRule[]): ProjectRule[] {
|
|
427
|
-
const requestedByFileRules = otherRules.filter((rule) => rule.globs);
|
|
428
|
-
const filePaths = this.attachedFiles.map((file) => file.uri.toString());
|
|
429
|
-
const folderPaths = this.attachedFolders.map((folder) => folder.uri.toString());
|
|
430
|
-
|
|
431
|
-
return requestedByFileRules.filter((rule) => {
|
|
432
|
-
let globs = rule.globs;
|
|
433
|
-
if (isString(globs)) {
|
|
434
|
-
globs = this.normalizeGlobs(globs.split(','));
|
|
435
|
-
} else {
|
|
436
|
-
globs = this.normalizeGlobs(globs || []);
|
|
437
|
-
}
|
|
438
|
-
const patterns = globs.map((pattern) => parseGlob(pattern));
|
|
439
|
-
return patterns.some((match) => filePaths.some((path) => match(path)) || folderPaths.some((path) => match(path)));
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
private normalizeGlobs(globs: string | string[]): string[] {
|
|
443
|
-
const globArray = isString(globs) ? globs.split(',') : globs || [];
|
|
444
|
-
return globArray.map((glob) => {
|
|
445
|
-
const p = glob.trim();
|
|
446
|
-
return p.startsWith('**') ? p : `**/${p}`;
|
|
447
|
-
});
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
private serializeAttachedRules(rules: ProjectRule[] = []): string[] {
|
|
451
|
-
rules = this.findApplicableRules(rules);
|
|
452
|
-
if (rules.length === 0) {
|
|
453
|
-
return [];
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
const header =
|
|
457
|
-
'\n<rules_context>\n\nRules are extra documentation provided by the user to help the AI understand the codebase.\nUse them if they seem useful to the users most recent query, but do not use them if they seem unrelated.\n\n';
|
|
458
|
-
|
|
459
|
-
const rulesSections = rules
|
|
460
|
-
.map((rule) => {
|
|
461
|
-
const ruleName =
|
|
462
|
-
rule.path
|
|
463
|
-
.split('/')
|
|
464
|
-
.pop()
|
|
465
|
-
?.replace(/.md(c)?$/, '') || 'Unnamed Rule';
|
|
466
|
-
return `Rule Name: ${ruleName}\nDescription: \n${rule.description || rule.content}`;
|
|
467
|
-
})
|
|
468
|
-
.join('\n\n');
|
|
469
|
-
|
|
470
|
-
const footer = '\n</rules_context>\n';
|
|
471
|
-
|
|
472
|
-
return [header, rulesSections, footer];
|
|
473
|
-
}
|
|
474
313
|
}
|
package/src/browser/contrib/intelligent-completions/decoration/additions-deletions.decoration.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ICodeEditor, IRange, TrackedRangeStickiness } from '@opensumi/ide-monaco';
|
|
1
|
+
import { ICodeEditor, IModelDeltaDecoration, IRange, TrackedRangeStickiness } from '@opensumi/ide-monaco';
|
|
2
2
|
|
|
3
3
|
import { EnhanceDecorationsCollection } from '../../../model/enhanceDecorationsCollection';
|
|
4
4
|
import { REWRITE_DECORATION_INLINE_ADD } from '../../../widget/rewrite/rewrite-widget';
|
|
@@ -267,7 +267,7 @@ export const computeMultiLineDiffChanges = (
|
|
|
267
267
|
lineNumber: number,
|
|
268
268
|
eol: string,
|
|
269
269
|
) => {
|
|
270
|
-
|
|
270
|
+
let rewriteDiffResult: IMultiLineDiffChangeResult[] =
|
|
271
271
|
rewriteDiffComputer.diff(originalContent, modifiedContent) || [];
|
|
272
272
|
let multiLineDiffResult: IMultiLineDiffChangeResult[] =
|
|
273
273
|
multiLineDiffComputer.diff(originalContent, modifiedContent) || [];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Injectable } from '@opensumi/di';
|
|
2
2
|
import { CancellationToken, Disposable } from '@opensumi/ide-core-common';
|
|
3
|
-
import { IReadableStream, isReadableStream, listenGroupReadable } from '@opensumi/ide-utils/lib/stream';
|
|
3
|
+
import { IReadableStream, isReadableStream, listenGroupReadable, listenReadable } from '@opensumi/ide-utils/lib/stream';
|
|
4
4
|
|
|
5
5
|
import { ITerminalCommandSuggestionDesc } from '../../../common/index';
|
|
6
6
|
import {
|
package/src/browser/index.ts
CHANGED
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
IntelligentCompletionsRegistryToken,
|
|
18
18
|
MCPConfigServiceToken,
|
|
19
19
|
ProblemFixRegistryToken,
|
|
20
|
-
RulesServiceToken,
|
|
21
20
|
TerminalRegistryToken,
|
|
22
21
|
} from '@opensumi/ide-core-common';
|
|
23
22
|
import { FolderFilePreferenceProvider } from '@opensumi/ide-preferences/lib/browser/folder-file-preference-provider';
|
|
@@ -78,8 +77,6 @@ import { ListDirTool } from './mcp/tools/listDir';
|
|
|
78
77
|
import { ReadFileTool } from './mcp/tools/readFile';
|
|
79
78
|
import { RunTerminalCommandTool } from './mcp/tools/runTerminalCmd';
|
|
80
79
|
import { AINativePreferencesContribution } from './preferences';
|
|
81
|
-
import { RulesContribution } from './rules/rules.contribution';
|
|
82
|
-
import { RulesService } from './rules/rules.service';
|
|
83
80
|
import { AINativeCoreContribution, MCPServerContribution, TokenMCPServerRegistry } from './types';
|
|
84
81
|
import { InlineChatFeatureRegistry } from './widget/inline-chat/inline-chat.feature.registry';
|
|
85
82
|
import { InlineChatService } from './widget/inline-chat/inline-chat.service';
|
|
@@ -122,7 +119,6 @@ export class AINativeModule extends BrowserModule {
|
|
|
122
119
|
|
|
123
120
|
// Context Service
|
|
124
121
|
LlmContextContribution,
|
|
125
|
-
RulesContribution,
|
|
126
122
|
{
|
|
127
123
|
token: LLMContextServiceToken,
|
|
128
124
|
useClass: LLMContextServiceImpl,
|
|
@@ -220,10 +216,6 @@ export class AINativeModule extends BrowserModule {
|
|
|
220
216
|
token: MCPConfigServiceToken,
|
|
221
217
|
useClass: MCPConfigService,
|
|
222
218
|
},
|
|
223
|
-
{
|
|
224
|
-
token: RulesServiceToken,
|
|
225
|
-
useClass: RulesService,
|
|
226
|
-
},
|
|
227
219
|
{
|
|
228
220
|
token: FolderFilePreferenceProvider,
|
|
229
221
|
useClass: MCPFolderPreferenceProvider,
|
|
@@ -2,7 +2,7 @@ import * as path from 'path';
|
|
|
2
2
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
import { Autowired } from '@opensumi/di';
|
|
5
|
+
import { Autowired, Injectable } from '@opensumi/di';
|
|
6
6
|
import { Domain, URI } from '@opensumi/ide-core-common';
|
|
7
7
|
import { IWorkspaceService } from '@opensumi/ide-workspace';
|
|
8
8
|
import { URI as MonacoURI } from '@opensumi/monaco-editor-core/esm/vs/base/common/uri';
|
|
@@ -2,7 +2,7 @@ import * as path from 'path';
|
|
|
2
2
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
import { Autowired } from '@opensumi/di';
|
|
5
|
+
import { Autowired, Injectable } from '@opensumi/di';
|
|
6
6
|
import { Domain, URI } from '@opensumi/ide-core-common';
|
|
7
7
|
import { WorkbenchEditorService } from '@opensumi/ide-editor';
|
|
8
8
|
import { IWorkspaceService } from '@opensumi/ide-workspace';
|
|
@@ -2,7 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
|
|
3
3
|
import { Autowired } from '@opensumi/di';
|
|
4
4
|
import { AppConfig } from '@opensumi/ide-core-browser';
|
|
5
|
-
import { Domain } from '@opensumi/ide-core-common';
|
|
5
|
+
import { Deferred, Domain } from '@opensumi/ide-core-common';
|
|
6
6
|
import { ITerminalController, ITerminalGroupViewService } from '@opensumi/ide-terminal-next/lib/common/controller';
|
|
7
7
|
|
|
8
8
|
import { IMCPServerRegistry, MCPLogger, MCPServerContribution, MCPToolDefinition } from '../../types';
|