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