@codingame/monaco-vscode-chat-service-override 1.85.1

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.
Files changed (34) hide show
  1. package/chat.d.ts +5 -0
  2. package/chat.js +39 -0
  3. package/external/rollup-plugin-styles/dist/runtime/inject-css.js +3 -0
  4. package/external/tslib/tslib.es6.js +11 -0
  5. package/index.d.ts +1 -0
  6. package/index.js +1 -0
  7. package/override/vs/platform/dialogs/common/dialogs.js +8 -0
  8. package/package.json +24 -0
  9. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClear.js +17 -0
  10. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +115 -0
  11. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +509 -0
  12. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +88 -0
  13. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +83 -0
  14. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +110 -0
  15. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +223 -0
  16. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTitleActions.js +283 -0
  17. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +283 -0
  18. package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js +61 -0
  19. package/vscode/src/vs/workbench/contrib/chat/browser/chatContributionServiceImpl.js +179 -0
  20. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +88 -0
  21. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +271 -0
  22. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +91 -0
  23. package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +165 -0
  24. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatHistoryVariables.js +26 -0
  25. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +626 -0
  26. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatEditor.css.js +6 -0
  27. package/vscode/src/vs/workbench/contrib/chat/common/chatColors.js +31 -0
  28. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +564 -0
  29. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +41 -0
  30. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +41 -0
  31. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatActions.js +748 -0
  32. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatDecorations.js +250 -0
  33. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js +62 -0
  34. package/vscode/src/vs/workbench/contrib/inlineChat/common/inlineChatServiceImpl.js +35 -0
@@ -0,0 +1,626 @@
1
+ import { __decorate, __param } from '../../../../../../../../external/tslib/tslib.es6.js';
2
+ import { raceCancellation } from 'monaco-editor/esm/vs/base/common/async.js';
3
+ import { Disposable, MutableDisposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
4
+ import { ICodeEditorService } from 'monaco-editor/esm/vs/editor/browser/services/codeEditorService.js';
5
+ import { Range } from 'monaco-editor/esm/vs/editor/common/core/range.js';
6
+ import { getWordAtText } from 'monaco-editor/esm/vs/editor/common/core/wordHelper.js';
7
+ import { ILanguageFeaturesService } from 'monaco-editor/esm/vs/editor/common/services/languageFeatures.js';
8
+ import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
9
+ import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
10
+ import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
11
+ import { IProductService } from 'monaco-editor/esm/vs/platform/product/common/productService.js';
12
+ import { Registry } from 'monaco-editor/esm/vs/platform/registry/common/platform.js';
13
+ import { inputPlaceholderForeground } from 'monaco-editor/esm/vs/platform/theme/common/colorRegistry.js';
14
+ import { IThemeService } from 'monaco-editor/esm/vs/platform/theme/common/themeService.js';
15
+ import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
16
+ import { SubmitAction } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatExecuteActions';
17
+ import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat';
18
+ import { ChatInputPart } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatInputPart';
19
+ import { ChatWidget } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatWidget';
20
+ import { SelectAndInsertFileAction, dynamicVariableDecorationType } from 'vscode/vscode/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables';
21
+ import { IChatAgentService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
22
+ import { chatSlashCommandForeground, chatSlashCommandBackground } from '../../common/chatColors.js';
23
+ import { chatVariableLeader, ChatRequestAgentPart, ChatRequestAgentSubcommandPart, ChatRequestSlashCommandPart, ChatRequestTextPart, ChatRequestVariablePart, chatAgentLeader, chatSubcommandLeader } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
24
+ import { ChatRequestParser } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatRequestParser';
25
+ import { IChatService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService';
26
+ import { IChatSlashCommandService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatSlashCommands';
27
+ import { IChatVariablesService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatVariables';
28
+ import { isResponseVM } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatViewModel';
29
+
30
+ var BuiltinDynamicCompletions_1, VariableCompletions_1;
31
+ const decorationDescription = 'chat';
32
+ const placeholderDecorationType = 'chat-session-detail';
33
+ const slashCommandTextDecorationType = 'chat-session-text';
34
+ const variableTextDecorationType = 'chat-variable-text';
35
+ function agentAndCommandToKey(agent, subcommand) {
36
+ return `${agent}__${subcommand}`;
37
+ }
38
+ let InputEditorDecorations = class InputEditorDecorations extends Disposable {
39
+ constructor(widget, instantiationService, codeEditorService, themeService, chatService) {
40
+ super();
41
+ this.widget = widget;
42
+ this.instantiationService = instantiationService;
43
+ this.codeEditorService = codeEditorService;
44
+ this.themeService = themeService;
45
+ this.chatService = chatService;
46
+ this.id = 'inputEditorDecorations';
47
+ this.previouslyUsedAgents = ( new Set());
48
+ this.viewModelDisposables = this._register(( new MutableDisposable()));
49
+ this.codeEditorService.registerDecorationType(decorationDescription, placeholderDecorationType, {});
50
+ this._register(this.themeService.onDidColorThemeChange(() => this.updateRegisteredDecorationTypes()));
51
+ this.updateRegisteredDecorationTypes();
52
+ this.updateInputEditorDecorations();
53
+ this._register(this.widget.inputEditor.onDidChangeModelContent(() => this.updateInputEditorDecorations()));
54
+ this._register(this.widget.onDidChangeViewModel(() => {
55
+ this.registerViewModelListeners();
56
+ this.previouslyUsedAgents.clear();
57
+ this.updateInputEditorDecorations();
58
+ }));
59
+ this._register(this.chatService.onDidSubmitAgent((e) => {
60
+ if (e.sessionId === this.widget.viewModel?.sessionId) {
61
+ this.previouslyUsedAgents.add(agentAndCommandToKey(e.agent.id, e.slashCommand.name));
62
+ }
63
+ }));
64
+ this.registerViewModelListeners();
65
+ }
66
+ registerViewModelListeners() {
67
+ this.viewModelDisposables.value = this.widget.viewModel?.onDidChange(e => {
68
+ if (e?.kind === 'changePlaceholder' || e?.kind === 'initialize') {
69
+ this.updateInputEditorDecorations();
70
+ }
71
+ });
72
+ }
73
+ updateRegisteredDecorationTypes() {
74
+ this.codeEditorService.removeDecorationType(variableTextDecorationType);
75
+ this.codeEditorService.removeDecorationType(dynamicVariableDecorationType);
76
+ this.codeEditorService.removeDecorationType(slashCommandTextDecorationType);
77
+ const theme = this.themeService.getColorTheme();
78
+ this.codeEditorService.registerDecorationType(decorationDescription, slashCommandTextDecorationType, {
79
+ color: theme.getColor(chatSlashCommandForeground)?.toString(),
80
+ backgroundColor: theme.getColor(chatSlashCommandBackground)?.toString(),
81
+ borderRadius: '3px'
82
+ });
83
+ this.codeEditorService.registerDecorationType(decorationDescription, variableTextDecorationType, {
84
+ color: theme.getColor(chatSlashCommandForeground)?.toString(),
85
+ backgroundColor: theme.getColor(chatSlashCommandBackground)?.toString(),
86
+ borderRadius: '3px'
87
+ });
88
+ this.codeEditorService.registerDecorationType(decorationDescription, dynamicVariableDecorationType, {
89
+ color: theme.getColor(chatSlashCommandForeground)?.toString(),
90
+ backgroundColor: theme.getColor(chatSlashCommandBackground)?.toString(),
91
+ borderRadius: '3px'
92
+ });
93
+ this.updateInputEditorDecorations();
94
+ }
95
+ getPlaceholderColor() {
96
+ const theme = this.themeService.getColorTheme();
97
+ const transparentForeground = theme.getColor(inputPlaceholderForeground);
98
+ return transparentForeground?.toString();
99
+ }
100
+ async updateInputEditorDecorations() {
101
+ const inputValue = this.widget.inputEditor.getValue();
102
+ const viewModel = this.widget.viewModel;
103
+ if (!viewModel) {
104
+ return;
105
+ }
106
+ if (!inputValue) {
107
+ const viewModelPlaceholder = this.widget.viewModel?.inputPlaceholder;
108
+ const placeholder = viewModelPlaceholder ?? '';
109
+ const decoration = [
110
+ {
111
+ range: {
112
+ startLineNumber: 1,
113
+ endLineNumber: 1,
114
+ startColumn: 1,
115
+ endColumn: 1000
116
+ },
117
+ renderOptions: {
118
+ after: {
119
+ contentText: placeholder,
120
+ color: this.getPlaceholderColor()
121
+ }
122
+ }
123
+ }
124
+ ];
125
+ this.widget.inputEditor.setDecorationsByType(decorationDescription, placeholderDecorationType, decoration);
126
+ return;
127
+ }
128
+ const parsedRequest = (await this.instantiationService.createInstance(ChatRequestParser).parseChatRequest(viewModel.sessionId, inputValue)).parts;
129
+ let placeholderDecoration;
130
+ const agentPart = parsedRequest.find((p) => p instanceof ChatRequestAgentPart);
131
+ const agentSubcommandPart = parsedRequest.find((p) => p instanceof ChatRequestAgentSubcommandPart);
132
+ const slashCommandPart = parsedRequest.find((p) => p instanceof ChatRequestSlashCommandPart);
133
+ const exactlyOneSpaceAfterPart = (part) => {
134
+ const partIdx = parsedRequest.indexOf(part);
135
+ if (parsedRequest.length > partIdx + 2) {
136
+ return false;
137
+ }
138
+ const nextPart = parsedRequest[partIdx + 1];
139
+ return nextPart && nextPart instanceof ChatRequestTextPart && nextPart.text === ' ';
140
+ };
141
+ const onlyAgentAndWhitespace = agentPart && parsedRequest.every(p => p instanceof ChatRequestTextPart && !p.text.trim().length || p instanceof ChatRequestAgentPart);
142
+ if (onlyAgentAndWhitespace) {
143
+ if (agentPart.agent.metadata.description && exactlyOneSpaceAfterPart(agentPart)) {
144
+ placeholderDecoration = [{
145
+ range: {
146
+ startLineNumber: agentPart.editorRange.startLineNumber,
147
+ endLineNumber: agentPart.editorRange.endLineNumber,
148
+ startColumn: agentPart.editorRange.endColumn + 1,
149
+ endColumn: 1000
150
+ },
151
+ renderOptions: {
152
+ after: {
153
+ contentText: agentPart.agent.metadata.description,
154
+ color: this.getPlaceholderColor(),
155
+ }
156
+ }
157
+ }];
158
+ }
159
+ }
160
+ const onlyAgentCommandAndWhitespace = agentPart && agentSubcommandPart && parsedRequest.every(p => p instanceof ChatRequestTextPart && !p.text.trim().length || p instanceof ChatRequestAgentPart || p instanceof ChatRequestAgentSubcommandPart);
161
+ if (onlyAgentCommandAndWhitespace) {
162
+ const isFollowupSlashCommand = ( this.previouslyUsedAgents.has(agentAndCommandToKey(agentPart.agent.id, agentSubcommandPart.command.name)));
163
+ const shouldRenderFollowupPlaceholder = isFollowupSlashCommand && agentSubcommandPart.command.followupPlaceholder;
164
+ if (agentSubcommandPart?.command.description && exactlyOneSpaceAfterPart(agentSubcommandPart)) {
165
+ placeholderDecoration = [{
166
+ range: {
167
+ startLineNumber: agentSubcommandPart.editorRange.startLineNumber,
168
+ endLineNumber: agentSubcommandPart.editorRange.endLineNumber,
169
+ startColumn: agentSubcommandPart.editorRange.endColumn + 1,
170
+ endColumn: 1000
171
+ },
172
+ renderOptions: {
173
+ after: {
174
+ contentText: shouldRenderFollowupPlaceholder ? agentSubcommandPart.command.followupPlaceholder : agentSubcommandPart.command.description,
175
+ color: this.getPlaceholderColor(),
176
+ }
177
+ }
178
+ }];
179
+ }
180
+ }
181
+ const onlySlashCommandAndWhitespace = slashCommandPart && parsedRequest.every(p => p instanceof ChatRequestTextPart && !p.text.trim().length || p instanceof ChatRequestSlashCommandPart);
182
+ if (onlySlashCommandAndWhitespace) {
183
+ if (slashCommandPart.slashCommand.detail && exactlyOneSpaceAfterPart(slashCommandPart)) {
184
+ placeholderDecoration = [{
185
+ range: {
186
+ startLineNumber: slashCommandPart.editorRange.startLineNumber,
187
+ endLineNumber: slashCommandPart.editorRange.endLineNumber,
188
+ startColumn: slashCommandPart.editorRange.endColumn + 1,
189
+ endColumn: 1000
190
+ },
191
+ renderOptions: {
192
+ after: {
193
+ contentText: slashCommandPart.slashCommand.detail,
194
+ color: this.getPlaceholderColor(),
195
+ }
196
+ }
197
+ }];
198
+ }
199
+ }
200
+ this.widget.inputEditor.setDecorationsByType(decorationDescription, placeholderDecorationType, placeholderDecoration ?? []);
201
+ const textDecorations = [];
202
+ if (agentPart) {
203
+ textDecorations.push({ range: agentPart.editorRange });
204
+ if (agentSubcommandPart) {
205
+ textDecorations.push({ range: agentSubcommandPart.editorRange });
206
+ }
207
+ }
208
+ if (slashCommandPart) {
209
+ textDecorations.push({ range: slashCommandPart.editorRange });
210
+ }
211
+ this.widget.inputEditor.setDecorationsByType(decorationDescription, slashCommandTextDecorationType, textDecorations);
212
+ const varDecorations = [];
213
+ const variableParts = parsedRequest.filter((p) => p instanceof ChatRequestVariablePart);
214
+ for (const variable of variableParts) {
215
+ varDecorations.push({ range: variable.editorRange });
216
+ }
217
+ this.widget.inputEditor.setDecorationsByType(decorationDescription, variableTextDecorationType, varDecorations);
218
+ }
219
+ };
220
+ InputEditorDecorations = ( __decorate([
221
+ ( __param(1, IInstantiationService)),
222
+ ( __param(2, ICodeEditorService)),
223
+ ( __param(3, IThemeService)),
224
+ ( __param(4, IChatService))
225
+ ], InputEditorDecorations));
226
+ let InputEditorSlashCommandMode = class InputEditorSlashCommandMode extends Disposable {
227
+ constructor(widget, chatService) {
228
+ super();
229
+ this.widget = widget;
230
+ this.chatService = chatService;
231
+ this.id = 'InputEditorSlashCommandMode';
232
+ this._register(this.chatService.onDidSubmitAgent(e => {
233
+ if (this.widget.viewModel?.sessionId !== e.sessionId) {
234
+ return;
235
+ }
236
+ this.repopulateAgentCommand(e.agent, e.slashCommand);
237
+ }));
238
+ }
239
+ async repopulateAgentCommand(agent, slashCommand) {
240
+ if (slashCommand.shouldRepopulate) {
241
+ const value = `${chatAgentLeader}${agent.id} ${chatSubcommandLeader}${slashCommand.name} `;
242
+ this.widget.inputEditor.setValue(value);
243
+ this.widget.inputEditor.setPosition({ lineNumber: 1, column: value.length + 1 });
244
+ }
245
+ }
246
+ };
247
+ InputEditorSlashCommandMode = ( __decorate([
248
+ ( __param(1, IChatService))
249
+ ], InputEditorSlashCommandMode));
250
+ ChatWidget.CONTRIBS.push(InputEditorDecorations, InputEditorSlashCommandMode);
251
+ let SlashCommandCompletions = class SlashCommandCompletions extends Disposable {
252
+ constructor(languageFeaturesService, chatWidgetService, instantiationService, chatSlashCommandService) {
253
+ super();
254
+ this.languageFeaturesService = languageFeaturesService;
255
+ this.chatWidgetService = chatWidgetService;
256
+ this.instantiationService = instantiationService;
257
+ this.chatSlashCommandService = chatSlashCommandService;
258
+ this._register(this.languageFeaturesService.completionProvider.register({ scheme: ChatInputPart.INPUT_SCHEME, hasAccessToAllModels: true }, {
259
+ _debugDisplayName: 'globalSlashCommands',
260
+ triggerCharacters: ['/'],
261
+ provideCompletionItems: async (model, position, _context, _token) => {
262
+ const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
263
+ if (!widget || !widget.viewModel) {
264
+ return null;
265
+ }
266
+ const range = computeCompletionRanges(model, position, /\/\w*/g);
267
+ if (!range) {
268
+ return null;
269
+ }
270
+ const parsedRequest = (await this.instantiationService.createInstance(ChatRequestParser).parseChatRequest(widget.viewModel.sessionId, model.getValue())).parts;
271
+ const usedAgent = parsedRequest.find(p => p instanceof ChatRequestAgentPart);
272
+ if (usedAgent) {
273
+ return;
274
+ }
275
+ const slashCommands = this.chatSlashCommandService.getCommands();
276
+ if (!slashCommands) {
277
+ return null;
278
+ }
279
+ return {
280
+ suggestions: ( slashCommands.map((c, i) => {
281
+ const withSlash = `/${c.command}`;
282
+ return {
283
+ label: withSlash,
284
+ insertText: c.executeImmediately ? '' : `${withSlash} `,
285
+ detail: c.detail,
286
+ range: ( new Range(1, 1, 1, 1)),
287
+ sortText: c.sortText ?? 'a'.repeat(i + 1),
288
+ kind: 18 ,
289
+ command: c.executeImmediately ? { id: SubmitAction.ID, title: withSlash, arguments: [{ widget, inputValue: `${withSlash} ` }] } : undefined,
290
+ };
291
+ }))
292
+ };
293
+ }
294
+ }));
295
+ }
296
+ };
297
+ SlashCommandCompletions = ( __decorate([
298
+ ( __param(0, ILanguageFeaturesService)),
299
+ ( __param(1, IChatWidgetService)),
300
+ ( __param(2, IInstantiationService)),
301
+ ( __param(3, IChatSlashCommandService))
302
+ ], SlashCommandCompletions));
303
+ ( Registry.as(Extensions.Workbench)).registerWorkbenchContribution(SlashCommandCompletions, 4 );
304
+ let AgentCompletions = class AgentCompletions extends Disposable {
305
+ constructor(languageFeaturesService, chatWidgetService, chatAgentService, instantiationService) {
306
+ super();
307
+ this.languageFeaturesService = languageFeaturesService;
308
+ this.chatWidgetService = chatWidgetService;
309
+ this.chatAgentService = chatAgentService;
310
+ this.instantiationService = instantiationService;
311
+ this._register(this.languageFeaturesService.completionProvider.register({ scheme: ChatInputPart.INPUT_SCHEME, hasAccessToAllModels: true }, {
312
+ _debugDisplayName: 'chatAgent',
313
+ triggerCharacters: ['@'],
314
+ provideCompletionItems: async (model, position, _context, _token) => {
315
+ const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
316
+ if (!widget || !widget.viewModel) {
317
+ return null;
318
+ }
319
+ const parsedRequest = (await this.instantiationService.createInstance(ChatRequestParser).parseChatRequest(widget.viewModel.sessionId, model.getValue())).parts;
320
+ const usedAgent = parsedRequest.find(p => p instanceof ChatRequestAgentPart);
321
+ if (usedAgent && !Range.containsPosition(usedAgent.editorRange, position)) {
322
+ return;
323
+ }
324
+ const range = computeCompletionRanges(model, position, /@\w*/g);
325
+ if (!range) {
326
+ return null;
327
+ }
328
+ const agents = this.chatAgentService.getAgents()
329
+ .filter(a => !a.metadata.isDefault);
330
+ return {
331
+ suggestions: ( agents.map((c, i) => {
332
+ const withAt = `@${c.id}`;
333
+ return {
334
+ label: withAt,
335
+ insertText: `${withAt} `,
336
+ detail: c.metadata.description,
337
+ range,
338
+ kind: 18 ,
339
+ };
340
+ }))
341
+ };
342
+ }
343
+ }));
344
+ this._register(this.languageFeaturesService.completionProvider.register({ scheme: ChatInputPart.INPUT_SCHEME, hasAccessToAllModels: true }, {
345
+ _debugDisplayName: 'chatAgentSubcommand',
346
+ triggerCharacters: ['/'],
347
+ provideCompletionItems: async (model, position, _context, token) => {
348
+ const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
349
+ if (!widget || !widget.viewModel) {
350
+ return;
351
+ }
352
+ const range = computeCompletionRanges(model, position, /\/\w*/g);
353
+ if (!range) {
354
+ return null;
355
+ }
356
+ const parsedRequest = (await this.instantiationService.createInstance(ChatRequestParser).parseChatRequest(widget.viewModel.sessionId, model.getValue())).parts;
357
+ const usedAgentIdx = parsedRequest.findIndex((p) => p instanceof ChatRequestAgentPart);
358
+ if (usedAgentIdx < 0) {
359
+ return;
360
+ }
361
+ const usedSubcommand = parsedRequest.find(p => p instanceof ChatRequestAgentSubcommandPart);
362
+ if (usedSubcommand) {
363
+ return;
364
+ }
365
+ for (const partAfterAgent of parsedRequest.slice(usedAgentIdx + 1)) {
366
+ if (!(partAfterAgent instanceof ChatRequestTextPart) || !partAfterAgent.text.trim().match(/^(\/\w*)?$/)) {
367
+ return;
368
+ }
369
+ }
370
+ const usedAgent = parsedRequest[usedAgentIdx];
371
+ const commands = await usedAgent.agent.provideSlashCommands(token);
372
+ return {
373
+ suggestions: ( commands.map((c, i) => {
374
+ const withSlash = `/${c.name}`;
375
+ return {
376
+ label: withSlash,
377
+ insertText: `${withSlash} `,
378
+ detail: c.description,
379
+ range,
380
+ kind: 18 ,
381
+ };
382
+ }))
383
+ };
384
+ }
385
+ }));
386
+ this._register(this.languageFeaturesService.completionProvider.register({ scheme: ChatInputPart.INPUT_SCHEME, hasAccessToAllModels: true }, {
387
+ _debugDisplayName: 'chatAgentAndSubcommand',
388
+ triggerCharacters: ['/'],
389
+ provideCompletionItems: async (model, position, _context, token) => {
390
+ const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
391
+ if (!widget) {
392
+ return;
393
+ }
394
+ const range = computeCompletionRanges(model, position, /\/\w*/g);
395
+ if (!range) {
396
+ return null;
397
+ }
398
+ const agents = this.chatAgentService.getAgents();
399
+ const all = ( agents.map(agent => agent.provideSlashCommands(token)));
400
+ const commands = await raceCancellation(Promise.all(all), token);
401
+ if (!commands) {
402
+ return;
403
+ }
404
+ const justAgents = ( agents
405
+ .filter(a => !a.metadata.isDefault)
406
+ .map(agent => {
407
+ const agentLabel = `${chatAgentLeader}${agent.id}`;
408
+ return {
409
+ label: { label: agentLabel, description: agent.metadata.description },
410
+ filterText: `${chatSubcommandLeader}${agent.id}`,
411
+ insertText: `${agentLabel} `,
412
+ range: ( new Range(1, 1, 1, 1)),
413
+ kind: 18 ,
414
+ sortText: `${chatSubcommandLeader}${agent.id}`,
415
+ };
416
+ }));
417
+ return {
418
+ suggestions: justAgents.concat(agents.flatMap((agent, i) => ( commands[i].map((c, i) => {
419
+ const agentLabel = `${chatAgentLeader}${agent.id}`;
420
+ const withSlash = `${chatSubcommandLeader}${c.name}`;
421
+ return {
422
+ label: { label: withSlash, description: agentLabel },
423
+ filterText: `${chatSubcommandLeader}${agent.id}${c.name}`,
424
+ insertText: `${agentLabel} ${withSlash} `,
425
+ detail: `(${agentLabel}) ${c.description}`,
426
+ range: ( new Range(1, 1, 1, 1)),
427
+ kind: 18 ,
428
+ sortText: `${chatSubcommandLeader}${agent.id}${c.name}`,
429
+ };
430
+ }))))
431
+ };
432
+ }
433
+ }));
434
+ }
435
+ };
436
+ AgentCompletions = ( __decorate([
437
+ ( __param(0, ILanguageFeaturesService)),
438
+ ( __param(1, IChatWidgetService)),
439
+ ( __param(2, IChatAgentService)),
440
+ ( __param(3, IInstantiationService))
441
+ ], AgentCompletions));
442
+ ( Registry.as(Extensions.Workbench)).registerWorkbenchContribution(AgentCompletions, 4 );
443
+ let BuiltinDynamicCompletions = class BuiltinDynamicCompletions extends Disposable {
444
+ static { BuiltinDynamicCompletions_1 = this; }
445
+ static { this.VariableNameDef = ( new RegExp(`${chatVariableLeader}\\w*`, 'g')); }
446
+ constructor(languageFeaturesService, chatWidgetService, configurationService, productService) {
447
+ super();
448
+ this.languageFeaturesService = languageFeaturesService;
449
+ this.chatWidgetService = chatWidgetService;
450
+ this.configurationService = configurationService;
451
+ this.productService = productService;
452
+ this._register(this.languageFeaturesService.completionProvider.register({ scheme: ChatInputPart.INPUT_SCHEME, hasAccessToAllModels: true }, {
453
+ _debugDisplayName: 'chatDynamicCompletions',
454
+ triggerCharacters: [chatVariableLeader],
455
+ provideCompletionItems: async (model, position, _context, _token) => {
456
+ const fileVariablesEnabled = this.configurationService.getValue('chat.experimental.fileVariables') ?? this.productService.quality !== 'stable';
457
+ if (!fileVariablesEnabled) {
458
+ return;
459
+ }
460
+ const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
461
+ if (!widget || !widget.supportsFileReferences) {
462
+ return null;
463
+ }
464
+ const range = computeCompletionRanges(model, position, BuiltinDynamicCompletions_1.VariableNameDef);
465
+ if (!range) {
466
+ return null;
467
+ }
468
+ const afterRange = ( new Range(
469
+ position.lineNumber,
470
+ range.replace.startColumn,
471
+ position.lineNumber,
472
+ range.replace.endColumn + 'file:'.length
473
+ ));
474
+ return {
475
+ suggestions: [
476
+ {
477
+ label: `${chatVariableLeader}file`,
478
+ insertText: `${chatVariableLeader}file:`,
479
+ detail: ( localizeWithPath(
480
+ 'vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib',
481
+ 'pickFileLabel',
482
+ "Pick a file"
483
+ )),
484
+ range,
485
+ kind: 18 ,
486
+ command: { id: SelectAndInsertFileAction.ID, title: SelectAndInsertFileAction.ID, arguments: [{ widget, range: afterRange }] },
487
+ sortText: 'z'
488
+ }
489
+ ]
490
+ };
491
+ }
492
+ }));
493
+ }
494
+ };
495
+ BuiltinDynamicCompletions = BuiltinDynamicCompletions_1 = ( __decorate([
496
+ ( __param(0, ILanguageFeaturesService)),
497
+ ( __param(1, IChatWidgetService)),
498
+ ( __param(2, IConfigurationService)),
499
+ ( __param(3, IProductService))
500
+ ], BuiltinDynamicCompletions));
501
+ ( Registry.as(Extensions.Workbench)).registerWorkbenchContribution(BuiltinDynamicCompletions, 4 );
502
+ function computeCompletionRanges(model, position, reg) {
503
+ const varWord = getWordAtText(position.column, reg, model.getLineContent(position.lineNumber), 0);
504
+ if (!varWord && model.getWordUntilPosition(position).word) {
505
+ return;
506
+ }
507
+ let insert;
508
+ let replace;
509
+ if (!varWord) {
510
+ insert = replace = Range.fromPositions(position);
511
+ }
512
+ else {
513
+ insert = ( new Range(
514
+ position.lineNumber,
515
+ varWord.startColumn,
516
+ position.lineNumber,
517
+ position.column
518
+ ));
519
+ replace = ( new Range(
520
+ position.lineNumber,
521
+ varWord.startColumn,
522
+ position.lineNumber,
523
+ varWord.endColumn
524
+ ));
525
+ }
526
+ return { insert, replace, varWord };
527
+ }
528
+ let VariableCompletions = class VariableCompletions extends Disposable {
529
+ static { VariableCompletions_1 = this; }
530
+ static { this.VariableNameDef = ( new RegExp(`${chatVariableLeader}\\w*`, 'g')); }
531
+ constructor(languageFeaturesService, chatWidgetService, chatVariablesService, configurationService) {
532
+ super();
533
+ this.languageFeaturesService = languageFeaturesService;
534
+ this.chatWidgetService = chatWidgetService;
535
+ this.chatVariablesService = chatVariablesService;
536
+ this.configurationService = configurationService;
537
+ this._register(this.languageFeaturesService.completionProvider.register({ scheme: ChatInputPart.INPUT_SCHEME, hasAccessToAllModels: true }, {
538
+ _debugDisplayName: 'chatVariables',
539
+ triggerCharacters: [chatVariableLeader],
540
+ provideCompletionItems: async (model, position, _context, _token) => {
541
+ const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
542
+ if (!widget) {
543
+ return null;
544
+ }
545
+ const range = computeCompletionRanges(model, position, VariableCompletions_1.VariableNameDef);
546
+ if (!range) {
547
+ return null;
548
+ }
549
+ const history = widget.viewModel.getItems()
550
+ .filter(isResponseVM);
551
+ const historyVariablesEnabled = this.configurationService.getValue('chat.experimental.historyVariables');
552
+ const historyItems = historyVariablesEnabled ? ( history.map((h, i) => ({
553
+ label: `${chatVariableLeader}response:${i + 1}`,
554
+ detail: h.response.asString(),
555
+ insertText: `${chatVariableLeader}response:${String(i + 1).padStart(String(history.length).length, '0')} `,
556
+ kind: 18 ,
557
+ range,
558
+ }))) : [];
559
+ const variableItems = ( Array.from(this.chatVariablesService.getVariables()).map(v => {
560
+ const withLeader = `${chatVariableLeader}${v.name}`;
561
+ return {
562
+ label: withLeader,
563
+ range,
564
+ insertText: withLeader + ' ',
565
+ detail: v.description,
566
+ kind: 18 ,
567
+ sortText: 'z'
568
+ };
569
+ }));
570
+ return {
571
+ suggestions: [...variableItems, ...historyItems]
572
+ };
573
+ }
574
+ }));
575
+ }
576
+ };
577
+ VariableCompletions = VariableCompletions_1 = ( __decorate([
578
+ ( __param(0, ILanguageFeaturesService)),
579
+ ( __param(1, IChatWidgetService)),
580
+ ( __param(2, IChatVariablesService)),
581
+ ( __param(3, IConfigurationService))
582
+ ], VariableCompletions));
583
+ ( Registry.as(Extensions.Workbench)).registerWorkbenchContribution(VariableCompletions, 4 );
584
+ let ChatTokenDeleter = class ChatTokenDeleter extends Disposable {
585
+ constructor(widget, instantiationService) {
586
+ super();
587
+ this.widget = widget;
588
+ this.instantiationService = instantiationService;
589
+ this.id = 'chatTokenDeleter';
590
+ const parser = this.instantiationService.createInstance(ChatRequestParser);
591
+ const inputValue = this.widget.inputEditor.getValue();
592
+ let previousInputValue;
593
+ this.widget.inputEditor.onDidChangeModelContent(e => {
594
+ if (!previousInputValue) {
595
+ previousInputValue = inputValue;
596
+ }
597
+ const change = e.changes[0];
598
+ if (!change.text) {
599
+ parser.parseChatRequest(this.widget.viewModel.sessionId, previousInputValue).then(previousParsedValue => {
600
+ const deletableTokens = previousParsedValue.parts.filter(p => p instanceof ChatRequestAgentPart || p instanceof ChatRequestAgentSubcommandPart || p instanceof ChatRequestSlashCommandPart);
601
+ deletableTokens.forEach(token => {
602
+ const deletedRangeOfToken = Range.intersectRanges(token.editorRange, change.range);
603
+ if ((deletedRangeOfToken && !deletedRangeOfToken.isEmpty()) && Range.compareRangesUsingStarts(token.editorRange, change.range) < 0) {
604
+ const length = deletedRangeOfToken.endColumn - deletedRangeOfToken.startColumn;
605
+ const rangeToDelete = ( new Range(
606
+ token.editorRange.startLineNumber,
607
+ token.editorRange.startColumn,
608
+ token.editorRange.endLineNumber,
609
+ token.editorRange.endColumn - length
610
+ ));
611
+ this.widget.inputEditor.executeEdits(this.id, [{
612
+ range: rangeToDelete,
613
+ text: '',
614
+ }]);
615
+ }
616
+ });
617
+ });
618
+ }
619
+ previousInputValue = this.widget.inputEditor.getValue();
620
+ });
621
+ }
622
+ };
623
+ ChatTokenDeleter = ( __decorate([
624
+ ( __param(1, IInstantiationService))
625
+ ], ChatTokenDeleter));
626
+ ChatWidget.CONTRIBS.push(ChatTokenDeleter);
@@ -0,0 +1,6 @@
1
+ import n from '../../../../../../../../external/rollup-plugin-styles/dist/runtime/inject-css.js';
2
+
3
+ var css = ".show-file-icons .chat-editor-label.file-icon:before,.vs .show-file-icons .chat-editor-label.file-icon:before{content:\"\\EAC7\";font-family:codicon;font-size:16px}";
4
+ n(css,{});
5
+
6
+ export { css, css as default };
@@ -0,0 +1,31 @@
1
+ import { Color, RGBA } from 'monaco-editor/esm/vs/base/common/color.js';
2
+ import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
3
+ import { registerColor, contrastBorder, badgeBackground, badgeForeground, foreground } from 'monaco-editor/esm/vs/platform/theme/common/colorRegistry.js';
4
+
5
+ registerColor('chat.requestBorder', { dark: ( new Color(( new RGBA(255, 255, 255, 0.10)))), light: ( new Color(( new RGBA(0, 0, 0, 0.10)))), hcDark: contrastBorder, hcLight: contrastBorder, }, ( localizeWithPath(
6
+ 'vs/workbench/contrib/chat/common/chatColors',
7
+ 'chat.requestBorder',
8
+ 'The border color of a chat request.'
9
+ )));
10
+ const chatSlashCommandBackground = registerColor('chat.slashCommandBackground', { dark: '#34414B', light: '#D2ECFF', hcDark: Color.white, hcLight: badgeBackground }, ( localizeWithPath(
11
+ 'vs/workbench/contrib/chat/common/chatColors',
12
+ 'chat.slashCommandBackground',
13
+ 'The background color of a chat slash command.'
14
+ )));
15
+ const chatSlashCommandForeground = registerColor('chat.slashCommandForeground', { dark: '#40A6FF', light: '#306CA2', hcDark: Color.black, hcLight: badgeForeground }, ( localizeWithPath(
16
+ 'vs/workbench/contrib/chat/common/chatColors',
17
+ 'chat.slashCommandForeground',
18
+ 'The foreground color of a chat slash command.'
19
+ )));
20
+ registerColor('chat.avatarBackground', { dark: '#1f1f1f', light: '#f2f2f2', hcDark: Color.black, hcLight: Color.white, }, ( localizeWithPath(
21
+ 'vs/workbench/contrib/chat/common/chatColors',
22
+ 'chat.avatarBackground',
23
+ 'The background color of a chat avatar.'
24
+ )));
25
+ registerColor('chat.avatarForeground', { dark: foreground, light: foreground, hcDark: foreground, hcLight: foreground, }, ( localizeWithPath(
26
+ 'vs/workbench/contrib/chat/common/chatColors',
27
+ 'chat.avatarForeground',
28
+ 'The foreground color of a chat avatar.'
29
+ )));
30
+
31
+ export { chatSlashCommandBackground, chatSlashCommandForeground };