@codingame/monaco-vscode-chat-service-override 5.2.0 → 6.0.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/chat.js +5 -7
- package/package.json +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +160 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +17 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +15 -13
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +215 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +1 -9
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +6 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTitleActions.js +15 -93
- package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +27 -106
- package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js +5 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +6 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipantContributions.js +95 -51
- package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.js +94 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +64 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +2 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatContextAttachments.js +50 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputCompletions.js +370 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +19 -366
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +122 -63
- package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +12 -5
- package/vscode/src/vs/workbench/contrib/chat/common/languageModelStats.js +6 -5
- package/vscode/src/vs/workbench/contrib/chat/common/{voiceChat.js → voiceChatService.js} +58 -21
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +15 -14
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +33 -32
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +6 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatHistoryVariables.js +0 -26
- package/vscode/src/vs/workbench/contrib/chat/common/languageModels.js +0 -50
- package/vscode/src/vs/workbench/contrib/inlineChat/common/inlineChatServiceImpl.js +0 -33
|
@@ -3,12 +3,7 @@ import { MarkdownString } from 'vscode/vscode/vs/base/common/htmlContent';
|
|
|
3
3
|
import { Disposable, MutableDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
4
4
|
import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
|
|
5
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 { Action2, registerAction2 } from 'vscode/vscode/vs/platform/actions/common/actions';
|
|
10
6
|
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
11
|
-
import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
|
|
12
7
|
import 'vscode/vscode/vs/platform/theme/common/colorUtils';
|
|
13
8
|
import 'vscode/vscode/vs/platform/theme/common/colors/baseColors';
|
|
14
9
|
import 'vscode/vscode/vs/platform/theme/common/colors/chartsColors';
|
|
@@ -21,22 +16,14 @@ import 'vscode/vscode/vs/platform/theme/common/colors/miscColors';
|
|
|
21
16
|
import 'vscode/vscode/vs/platform/theme/common/colors/quickpickColors';
|
|
22
17
|
import 'vscode/vscode/vs/platform/theme/common/colors/searchColors';
|
|
23
18
|
import { IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeService.service';
|
|
24
|
-
import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
|
|
25
|
-
import { SubmitAction } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatExecuteActions';
|
|
26
|
-
import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat.service';
|
|
27
|
-
import { ChatInputPart } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatInputPart';
|
|
28
19
|
import { ChatWidget } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatWidget';
|
|
29
|
-
import { dynamicVariableDecorationType
|
|
20
|
+
import { dynamicVariableDecorationType } from 'vscode/vscode/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables';
|
|
30
21
|
import { ChatAgentLocation } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
|
|
31
22
|
import { IChatAgentService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
|
|
32
23
|
import { chatSlashCommandForeground, chatSlashCommandBackground } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatColors';
|
|
33
|
-
import { ChatRequestAgentPart, ChatRequestAgentSubcommandPart, ChatRequestSlashCommandPart, ChatRequestTextPart, ChatRequestVariablePart, chatAgentLeader, chatSubcommandLeader
|
|
24
|
+
import { ChatRequestAgentPart, ChatRequestAgentSubcommandPart, ChatRequestSlashCommandPart, ChatRequestTextPart, ChatRequestVariablePart, chatAgentLeader, chatSubcommandLeader } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
|
|
34
25
|
import { ChatRequestParser } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatRequestParser';
|
|
35
|
-
import { IChatSlashCommandService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatSlashCommands.service';
|
|
36
|
-
import { IChatVariablesService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatVariables.service';
|
|
37
26
|
|
|
38
|
-
var BuiltinDynamicCompletions_1, VariableCompletions_1;
|
|
39
|
-
const _moduleId = "vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib";
|
|
40
27
|
const decorationDescription = 'chat';
|
|
41
28
|
const placeholderDecorationType = 'chat-session-detail';
|
|
42
29
|
const slashCommandTextDecorationType = 'chat-session-text';
|
|
@@ -52,8 +39,8 @@ let InputEditorDecorations = class InputEditorDecorations extends Disposable {
|
|
|
52
39
|
this.themeService = themeService;
|
|
53
40
|
this.chatAgentService = chatAgentService;
|
|
54
41
|
this.id = 'inputEditorDecorations';
|
|
55
|
-
this.previouslyUsedAgents = (
|
|
56
|
-
this.viewModelDisposables = this._register((
|
|
42
|
+
this.previouslyUsedAgents = ( new Set());
|
|
43
|
+
this.viewModelDisposables = this._register(( new MutableDisposable()));
|
|
57
44
|
this.codeEditorService.registerDecorationType(decorationDescription, placeholderDecorationType, {});
|
|
58
45
|
this._register(this.themeService.onDidColorThemeChange(() => this.updateRegisteredDecorationTypes()));
|
|
59
46
|
this.updateRegisteredDecorationTypes();
|
|
@@ -153,7 +140,7 @@ let InputEditorDecorations = class InputEditorDecorations extends Disposable {
|
|
|
153
140
|
});
|
|
154
141
|
const onlyAgentAndWhitespace = agentPart && parsedRequest.every(p => p instanceof ChatRequestTextPart && !p.text.trim().length || p instanceof ChatRequestAgentPart);
|
|
155
142
|
if (onlyAgentAndWhitespace) {
|
|
156
|
-
const isFollowupSlashCommand = (
|
|
143
|
+
const isFollowupSlashCommand = ( this.previouslyUsedAgents.has(agentAndCommandToKey(agentPart.agent, undefined)));
|
|
157
144
|
const shouldRenderFollowupPlaceholder = isFollowupSlashCommand && agentPart.agent.metadata.followupPlaceholder;
|
|
158
145
|
if (agentPart.agent.description && exactlyOneSpaceAfterPart(agentPart)) {
|
|
159
146
|
placeholderDecoration = [{
|
|
@@ -169,7 +156,7 @@ let InputEditorDecorations = class InputEditorDecorations extends Disposable {
|
|
|
169
156
|
}
|
|
170
157
|
const onlyAgentCommandAndWhitespace = agentPart && agentSubcommandPart && parsedRequest.every(p => p instanceof ChatRequestTextPart && !p.text.trim().length || p instanceof ChatRequestAgentPart || p instanceof ChatRequestAgentSubcommandPart);
|
|
171
158
|
if (onlyAgentCommandAndWhitespace) {
|
|
172
|
-
const isFollowupSlashCommand = (
|
|
159
|
+
const isFollowupSlashCommand = ( this.previouslyUsedAgents.has(agentAndCommandToKey(agentPart.agent, agentSubcommandPart.command.name)));
|
|
173
160
|
const shouldRenderFollowupPlaceholder = isFollowupSlashCommand && agentSubcommandPart.command.followupPlaceholder;
|
|
174
161
|
if (agentSubcommandPart?.command.description && exactlyOneSpaceAfterPart(agentSubcommandPart)) {
|
|
175
162
|
placeholderDecoration = [{
|
|
@@ -187,11 +174,11 @@ let InputEditorDecorations = class InputEditorDecorations extends Disposable {
|
|
|
187
174
|
const textDecorations = [];
|
|
188
175
|
if (agentPart) {
|
|
189
176
|
const isDupe = !!this.chatAgentService.getAgents().find(other => other.name === agentPart.agent.name && other.id !== agentPart.agent.id);
|
|
190
|
-
const publisher = isDupe ? `(${agentPart.agent.
|
|
177
|
+
const publisher = isDupe ? `(${agentPart.agent.publisherDisplayName}) ` : '';
|
|
191
178
|
const agentHover = `${publisher}${agentPart.agent.description}`;
|
|
192
|
-
textDecorations.push({ range: agentPart.editorRange, hoverMessage: (
|
|
179
|
+
textDecorations.push({ range: agentPart.editorRange, hoverMessage: ( new MarkdownString(agentHover)) });
|
|
193
180
|
if (agentSubcommandPart) {
|
|
194
|
-
textDecorations.push({ range: agentSubcommandPart.editorRange, hoverMessage: (
|
|
181
|
+
textDecorations.push({ range: agentSubcommandPart.editorRange, hoverMessage: ( new MarkdownString(agentSubcommandPart.command.description)) });
|
|
195
182
|
}
|
|
196
183
|
}
|
|
197
184
|
if (slashCommandPart) {
|
|
@@ -206,11 +193,11 @@ let InputEditorDecorations = class InputEditorDecorations extends Disposable {
|
|
|
206
193
|
this.widget.inputEditor.setDecorationsByType(decorationDescription, variableTextDecorationType, varDecorations);
|
|
207
194
|
}
|
|
208
195
|
};
|
|
209
|
-
InputEditorDecorations = (
|
|
210
|
-
(
|
|
211
|
-
(
|
|
212
|
-
(
|
|
213
|
-
], InputEditorDecorations))
|
|
196
|
+
InputEditorDecorations = ( __decorate([
|
|
197
|
+
( __param(1, ICodeEditorService)),
|
|
198
|
+
( __param(2, IThemeService)),
|
|
199
|
+
( __param(3, IChatAgentService))
|
|
200
|
+
], InputEditorDecorations));
|
|
214
201
|
class InputEditorSlashCommandMode extends Disposable {
|
|
215
202
|
constructor(widget) {
|
|
216
203
|
super();
|
|
@@ -235,340 +222,6 @@ class InputEditorSlashCommandMode extends Disposable {
|
|
|
235
222
|
}
|
|
236
223
|
}
|
|
237
224
|
ChatWidget.CONTRIBS.push(InputEditorDecorations, InputEditorSlashCommandMode);
|
|
238
|
-
let SlashCommandCompletions = class SlashCommandCompletions extends Disposable {
|
|
239
|
-
constructor(languageFeaturesService, chatWidgetService, chatSlashCommandService) {
|
|
240
|
-
super();
|
|
241
|
-
this.languageFeaturesService = languageFeaturesService;
|
|
242
|
-
this.chatWidgetService = chatWidgetService;
|
|
243
|
-
this.chatSlashCommandService = chatSlashCommandService;
|
|
244
|
-
this._register(this.languageFeaturesService.completionProvider.register({ scheme: ChatInputPart.INPUT_SCHEME, hasAccessToAllModels: true }, {
|
|
245
|
-
_debugDisplayName: 'globalSlashCommands',
|
|
246
|
-
triggerCharacters: ['/'],
|
|
247
|
-
provideCompletionItems: async (model, position, _context, _token) => {
|
|
248
|
-
const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
|
|
249
|
-
if (!widget || !widget.viewModel || widget.location !== ChatAgentLocation.Panel ) {
|
|
250
|
-
return null;
|
|
251
|
-
}
|
|
252
|
-
const range = computeCompletionRanges(model, position, /\/\w*/g);
|
|
253
|
-
if (!range) {
|
|
254
|
-
return null;
|
|
255
|
-
}
|
|
256
|
-
const parsedRequest = widget.parsedInput.parts;
|
|
257
|
-
const usedAgent = parsedRequest.find(p => p instanceof ChatRequestAgentPart);
|
|
258
|
-
if (usedAgent) {
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
const slashCommands = this.chatSlashCommandService.getCommands();
|
|
262
|
-
if (!slashCommands) {
|
|
263
|
-
return null;
|
|
264
|
-
}
|
|
265
|
-
return {
|
|
266
|
-
suggestions: ( (slashCommands.map((c, i) => {
|
|
267
|
-
const withSlash = `/${c.command}`;
|
|
268
|
-
return {
|
|
269
|
-
label: withSlash,
|
|
270
|
-
insertText: c.executeImmediately ? '' : `${withSlash} `,
|
|
271
|
-
detail: c.detail,
|
|
272
|
-
range: ( (new Range(1, 1, 1, 1))),
|
|
273
|
-
sortText: c.sortText ?? 'a'.repeat(i + 1),
|
|
274
|
-
kind: 18 ,
|
|
275
|
-
command: c.executeImmediately ? { id: SubmitAction.ID, title: withSlash, arguments: [{ widget, inputValue: `${withSlash} ` }] } : undefined,
|
|
276
|
-
};
|
|
277
|
-
})))
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
}));
|
|
281
|
-
}
|
|
282
|
-
};
|
|
283
|
-
SlashCommandCompletions = ( (__decorate([
|
|
284
|
-
( (__param(0, ILanguageFeaturesService))),
|
|
285
|
-
( (__param(1, IChatWidgetService))),
|
|
286
|
-
( (__param(2, IChatSlashCommandService)))
|
|
287
|
-
], SlashCommandCompletions)));
|
|
288
|
-
( (Registry.as(Extensions.Workbench))).registerWorkbenchContribution(SlashCommandCompletions, 4 );
|
|
289
|
-
let AgentCompletions = class AgentCompletions extends Disposable {
|
|
290
|
-
constructor(languageFeaturesService, chatWidgetService, chatAgentService) {
|
|
291
|
-
super();
|
|
292
|
-
this.languageFeaturesService = languageFeaturesService;
|
|
293
|
-
this.chatWidgetService = chatWidgetService;
|
|
294
|
-
this.chatAgentService = chatAgentService;
|
|
295
|
-
this._register(this.languageFeaturesService.completionProvider.register({ scheme: ChatInputPart.INPUT_SCHEME, hasAccessToAllModels: true }, {
|
|
296
|
-
_debugDisplayName: 'chatAgent',
|
|
297
|
-
triggerCharacters: ['@'],
|
|
298
|
-
provideCompletionItems: async (model, position, _context, _token) => {
|
|
299
|
-
const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
|
|
300
|
-
if (!widget || !widget.viewModel || widget.location !== ChatAgentLocation.Panel ) {
|
|
301
|
-
return null;
|
|
302
|
-
}
|
|
303
|
-
const parsedRequest = widget.parsedInput.parts;
|
|
304
|
-
const usedAgent = parsedRequest.find(p => p instanceof ChatRequestAgentPart);
|
|
305
|
-
if (usedAgent && !Range.containsPosition(usedAgent.editorRange, position)) {
|
|
306
|
-
return;
|
|
307
|
-
}
|
|
308
|
-
const range = computeCompletionRanges(model, position, /@\w*/g);
|
|
309
|
-
if (!range) {
|
|
310
|
-
return null;
|
|
311
|
-
}
|
|
312
|
-
const agents = this.chatAgentService.getAgents()
|
|
313
|
-
.filter(a => !a.isDefault)
|
|
314
|
-
.filter(a => a.locations.includes(widget.location));
|
|
315
|
-
return {
|
|
316
|
-
suggestions: ( (agents.map((a, i) => {
|
|
317
|
-
const withAt = `@${a.name}`;
|
|
318
|
-
const isDupe = !!agents.find(other => other.name === a.name && other.id !== a.id);
|
|
319
|
-
return {
|
|
320
|
-
label: isDupe ?
|
|
321
|
-
{ label: withAt, description: a.description, detail: ` (${a.extensionPublisherDisplayName})` } :
|
|
322
|
-
withAt,
|
|
323
|
-
insertText: `${withAt} `,
|
|
324
|
-
detail: a.description,
|
|
325
|
-
range: ( (new Range(1, 1, 1, 1))),
|
|
326
|
-
command: { id: AssignSelectedAgentAction.ID, title: AssignSelectedAgentAction.ID, arguments: [{ agent: a, widget }] },
|
|
327
|
-
kind: 18 ,
|
|
328
|
-
};
|
|
329
|
-
})))
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
}));
|
|
333
|
-
this._register(this.languageFeaturesService.completionProvider.register({ scheme: ChatInputPart.INPUT_SCHEME, hasAccessToAllModels: true }, {
|
|
334
|
-
_debugDisplayName: 'chatAgentSubcommand',
|
|
335
|
-
triggerCharacters: ['/'],
|
|
336
|
-
provideCompletionItems: async (model, position, _context, token) => {
|
|
337
|
-
const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
|
|
338
|
-
if (!widget || !widget.viewModel || widget.location !== ChatAgentLocation.Panel ) {
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
const range = computeCompletionRanges(model, position, /\/\w*/g);
|
|
342
|
-
if (!range) {
|
|
343
|
-
return null;
|
|
344
|
-
}
|
|
345
|
-
const parsedRequest = widget.parsedInput.parts;
|
|
346
|
-
const usedAgentIdx = parsedRequest.findIndex((p) => p instanceof ChatRequestAgentPart);
|
|
347
|
-
if (usedAgentIdx < 0) {
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
const usedSubcommand = parsedRequest.find(p => p instanceof ChatRequestAgentSubcommandPart);
|
|
351
|
-
if (usedSubcommand) {
|
|
352
|
-
return;
|
|
353
|
-
}
|
|
354
|
-
for (const partAfterAgent of parsedRequest.slice(usedAgentIdx + 1)) {
|
|
355
|
-
if (!(partAfterAgent instanceof ChatRequestTextPart) || !partAfterAgent.text.trim().match(/^(\/\w*)?$/)) {
|
|
356
|
-
return;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
const usedAgent = parsedRequest[usedAgentIdx];
|
|
360
|
-
return {
|
|
361
|
-
suggestions: ( (usedAgent.agent.slashCommands.map((c, i) => {
|
|
362
|
-
const withSlash = `/${c.name}`;
|
|
363
|
-
return {
|
|
364
|
-
label: withSlash,
|
|
365
|
-
insertText: `${withSlash} `,
|
|
366
|
-
detail: c.description,
|
|
367
|
-
range,
|
|
368
|
-
kind: 18 ,
|
|
369
|
-
};
|
|
370
|
-
})))
|
|
371
|
-
};
|
|
372
|
-
}
|
|
373
|
-
}));
|
|
374
|
-
this._register(this.languageFeaturesService.completionProvider.register({ scheme: ChatInputPart.INPUT_SCHEME, hasAccessToAllModels: true }, {
|
|
375
|
-
_debugDisplayName: 'chatAgentAndSubcommand',
|
|
376
|
-
triggerCharacters: ['/'],
|
|
377
|
-
provideCompletionItems: async (model, position, _context, token) => {
|
|
378
|
-
const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
|
|
379
|
-
const viewModel = widget?.viewModel;
|
|
380
|
-
if (!widget || !viewModel || widget.location !== ChatAgentLocation.Panel ) {
|
|
381
|
-
return;
|
|
382
|
-
}
|
|
383
|
-
const range = computeCompletionRanges(model, position, /\/\w*/g);
|
|
384
|
-
if (!range) {
|
|
385
|
-
return null;
|
|
386
|
-
}
|
|
387
|
-
const agents = this.chatAgentService.getAgents()
|
|
388
|
-
.filter(a => a.locations.includes(widget.location));
|
|
389
|
-
const justAgents = ( (agents
|
|
390
|
-
.filter(a => !a.isDefault)
|
|
391
|
-
.map(agent => {
|
|
392
|
-
const isDupe = !!agents.find(other => other.name === agent.name && other.id !== agent.id);
|
|
393
|
-
const detail = agent.description;
|
|
394
|
-
const agentLabel = `${chatAgentLeader}${agent.name}`;
|
|
395
|
-
return {
|
|
396
|
-
label: isDupe ?
|
|
397
|
-
{ label: agentLabel, description: agent.description, detail: ` (${agent.extensionPublisherDisplayName})` } :
|
|
398
|
-
agentLabel,
|
|
399
|
-
detail,
|
|
400
|
-
filterText: `${chatSubcommandLeader}${agent.name}`,
|
|
401
|
-
insertText: `${agentLabel} `,
|
|
402
|
-
range: ( (new Range(1, 1, 1, 1))),
|
|
403
|
-
kind: 18 ,
|
|
404
|
-
sortText: `${chatSubcommandLeader}${agent.id}`,
|
|
405
|
-
command: { id: AssignSelectedAgentAction.ID, title: AssignSelectedAgentAction.ID, arguments: [{ agent, widget }] },
|
|
406
|
-
};
|
|
407
|
-
})));
|
|
408
|
-
return {
|
|
409
|
-
suggestions: justAgents.concat(agents.flatMap(agent => ( (agent.slashCommands.map((c, i) => {
|
|
410
|
-
const agentLabel = `${chatAgentLeader}${agent.name}`;
|
|
411
|
-
const withSlash = `${chatSubcommandLeader}${c.name}`;
|
|
412
|
-
return {
|
|
413
|
-
label: { label: withSlash, description: agentLabel },
|
|
414
|
-
filterText: `${chatSubcommandLeader}${agent.name}${c.name}`,
|
|
415
|
-
commitCharacters: [' '],
|
|
416
|
-
insertText: `${agentLabel} ${withSlash} `,
|
|
417
|
-
detail: `(${agentLabel}) ${c.description ?? ''}`,
|
|
418
|
-
range: ( (new Range(1, 1, 1, 1))),
|
|
419
|
-
kind: 18 ,
|
|
420
|
-
sortText: `${chatSubcommandLeader}${agent.id}${c.name}`,
|
|
421
|
-
command: { id: AssignSelectedAgentAction.ID, title: AssignSelectedAgentAction.ID, arguments: [{ agent, widget }] },
|
|
422
|
-
};
|
|
423
|
-
})))))
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
|
-
}));
|
|
427
|
-
}
|
|
428
|
-
};
|
|
429
|
-
AgentCompletions = ( (__decorate([
|
|
430
|
-
( (__param(0, ILanguageFeaturesService))),
|
|
431
|
-
( (__param(1, IChatWidgetService))),
|
|
432
|
-
( (__param(2, IChatAgentService)))
|
|
433
|
-
], AgentCompletions)));
|
|
434
|
-
( (Registry.as(Extensions.Workbench))).registerWorkbenchContribution(AgentCompletions, 4 );
|
|
435
|
-
class AssignSelectedAgentAction extends Action2 {
|
|
436
|
-
static { this.ID = 'workbench.action.chat.assignSelectedAgent'; }
|
|
437
|
-
constructor() {
|
|
438
|
-
super({
|
|
439
|
-
id: AssignSelectedAgentAction.ID,
|
|
440
|
-
title: ''
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
async run(accessor, ...args) {
|
|
444
|
-
const arg = args[0];
|
|
445
|
-
if (!arg || !arg.widget || !arg.agent) {
|
|
446
|
-
return;
|
|
447
|
-
}
|
|
448
|
-
arg.widget.lastSelectedAgent = arg.agent;
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
registerAction2(AssignSelectedAgentAction);
|
|
452
|
-
let BuiltinDynamicCompletions = class BuiltinDynamicCompletions extends Disposable {
|
|
453
|
-
static { BuiltinDynamicCompletions_1 = this; }
|
|
454
|
-
static { this.VariableNameDef = ( (new RegExp(`${chatVariableLeader}\\w*`, 'g'))); }
|
|
455
|
-
constructor(languageFeaturesService, chatWidgetService) {
|
|
456
|
-
super();
|
|
457
|
-
this.languageFeaturesService = languageFeaturesService;
|
|
458
|
-
this.chatWidgetService = chatWidgetService;
|
|
459
|
-
this._register(this.languageFeaturesService.completionProvider.register({ scheme: ChatInputPart.INPUT_SCHEME, hasAccessToAllModels: true }, {
|
|
460
|
-
_debugDisplayName: 'chatDynamicCompletions',
|
|
461
|
-
triggerCharacters: [chatVariableLeader],
|
|
462
|
-
provideCompletionItems: async (model, position, _context, _token) => {
|
|
463
|
-
const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
|
|
464
|
-
if (!widget || !widget.supportsFileReferences || widget.location !== ChatAgentLocation.Panel ) {
|
|
465
|
-
return null;
|
|
466
|
-
}
|
|
467
|
-
const range = computeCompletionRanges(model, position, BuiltinDynamicCompletions_1.VariableNameDef);
|
|
468
|
-
if (!range) {
|
|
469
|
-
return null;
|
|
470
|
-
}
|
|
471
|
-
const afterRange = ( (new Range(
|
|
472
|
-
position.lineNumber,
|
|
473
|
-
range.replace.startColumn,
|
|
474
|
-
position.lineNumber,
|
|
475
|
-
range.replace.startColumn + '#file:'.length
|
|
476
|
-
)));
|
|
477
|
-
return {
|
|
478
|
-
suggestions: [
|
|
479
|
-
{
|
|
480
|
-
label: `${chatVariableLeader}file`,
|
|
481
|
-
insertText: `${chatVariableLeader}file:`,
|
|
482
|
-
detail: ( localizeWithPath(_moduleId, 0, "Pick a file")),
|
|
483
|
-
range,
|
|
484
|
-
kind: 18 ,
|
|
485
|
-
command: { id: SelectAndInsertFileAction.ID, title: SelectAndInsertFileAction.ID, arguments: [{ widget, range: afterRange }] },
|
|
486
|
-
sortText: 'z'
|
|
487
|
-
}
|
|
488
|
-
]
|
|
489
|
-
};
|
|
490
|
-
}
|
|
491
|
-
}));
|
|
492
|
-
}
|
|
493
|
-
};
|
|
494
|
-
BuiltinDynamicCompletions = BuiltinDynamicCompletions_1 = ( (__decorate([
|
|
495
|
-
( (__param(0, ILanguageFeaturesService))),
|
|
496
|
-
( (__param(1, IChatWidgetService)))
|
|
497
|
-
], BuiltinDynamicCompletions)));
|
|
498
|
-
( (Registry.as(Extensions.Workbench))).registerWorkbenchContribution(BuiltinDynamicCompletions, 4 );
|
|
499
|
-
function computeCompletionRanges(model, position, reg) {
|
|
500
|
-
const varWord = getWordAtText(position.column, reg, model.getLineContent(position.lineNumber), 0);
|
|
501
|
-
if (!varWord && model.getWordUntilPosition(position).word) {
|
|
502
|
-
return;
|
|
503
|
-
}
|
|
504
|
-
let insert;
|
|
505
|
-
let replace;
|
|
506
|
-
if (!varWord) {
|
|
507
|
-
insert = replace = Range.fromPositions(position);
|
|
508
|
-
}
|
|
509
|
-
else {
|
|
510
|
-
insert = ( (new Range(
|
|
511
|
-
position.lineNumber,
|
|
512
|
-
varWord.startColumn,
|
|
513
|
-
position.lineNumber,
|
|
514
|
-
position.column
|
|
515
|
-
)));
|
|
516
|
-
replace = ( (new Range(
|
|
517
|
-
position.lineNumber,
|
|
518
|
-
varWord.startColumn,
|
|
519
|
-
position.lineNumber,
|
|
520
|
-
varWord.endColumn
|
|
521
|
-
)));
|
|
522
|
-
}
|
|
523
|
-
return { insert, replace, varWord };
|
|
524
|
-
}
|
|
525
|
-
let VariableCompletions = class VariableCompletions extends Disposable {
|
|
526
|
-
static { VariableCompletions_1 = this; }
|
|
527
|
-
static { this.VariableNameDef = ( (new RegExp(`${chatVariableLeader}\\w*`, 'g'))); }
|
|
528
|
-
constructor(languageFeaturesService, chatWidgetService, chatVariablesService) {
|
|
529
|
-
super();
|
|
530
|
-
this.languageFeaturesService = languageFeaturesService;
|
|
531
|
-
this.chatWidgetService = chatWidgetService;
|
|
532
|
-
this.chatVariablesService = chatVariablesService;
|
|
533
|
-
this._register(this.languageFeaturesService.completionProvider.register({ scheme: ChatInputPart.INPUT_SCHEME, hasAccessToAllModels: true }, {
|
|
534
|
-
_debugDisplayName: 'chatVariables',
|
|
535
|
-
triggerCharacters: [chatVariableLeader],
|
|
536
|
-
provideCompletionItems: async (model, position, _context, _token) => {
|
|
537
|
-
const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
|
|
538
|
-
if (!widget || widget.location !== ChatAgentLocation.Panel ) {
|
|
539
|
-
return null;
|
|
540
|
-
}
|
|
541
|
-
const range = computeCompletionRanges(model, position, VariableCompletions_1.VariableNameDef);
|
|
542
|
-
if (!range) {
|
|
543
|
-
return null;
|
|
544
|
-
}
|
|
545
|
-
const usedVariables = widget.parsedInput.parts.filter((p) => p instanceof ChatRequestVariablePart);
|
|
546
|
-
const variableItems = ( (Array.from(this.chatVariablesService.getVariables())
|
|
547
|
-
.filter(v => !( (usedVariables.some(usedVar => usedVar.variableName === v.name))))
|
|
548
|
-
.map(v => {
|
|
549
|
-
const withLeader = `${chatVariableLeader}${v.name}`;
|
|
550
|
-
return {
|
|
551
|
-
label: withLeader,
|
|
552
|
-
range,
|
|
553
|
-
insertText: withLeader + ' ',
|
|
554
|
-
detail: v.description,
|
|
555
|
-
kind: 18 ,
|
|
556
|
-
sortText: 'z'
|
|
557
|
-
};
|
|
558
|
-
})));
|
|
559
|
-
return {
|
|
560
|
-
suggestions: variableItems
|
|
561
|
-
};
|
|
562
|
-
}
|
|
563
|
-
}));
|
|
564
|
-
}
|
|
565
|
-
};
|
|
566
|
-
VariableCompletions = VariableCompletions_1 = ( (__decorate([
|
|
567
|
-
( (__param(0, ILanguageFeaturesService))),
|
|
568
|
-
( (__param(1, IChatWidgetService))),
|
|
569
|
-
( (__param(2, IChatVariablesService)))
|
|
570
|
-
], VariableCompletions)));
|
|
571
|
-
( (Registry.as(Extensions.Workbench))).registerWorkbenchContribution(VariableCompletions, 4 );
|
|
572
225
|
let ChatTokenDeleter = class ChatTokenDeleter extends Disposable {
|
|
573
226
|
constructor(widget, instantiationService) {
|
|
574
227
|
super();
|
|
@@ -592,12 +245,12 @@ let ChatTokenDeleter = class ChatTokenDeleter extends Disposable {
|
|
|
592
245
|
const deletedRangeOfToken = Range.intersectRanges(token.editorRange, change.range);
|
|
593
246
|
if (deletedRangeOfToken && Range.compareRangesUsingStarts(token.editorRange, change.range) < 0) {
|
|
594
247
|
const length = deletedRangeOfToken.endColumn - deletedRangeOfToken.startColumn;
|
|
595
|
-
const rangeToDelete = (
|
|
248
|
+
const rangeToDelete = ( new Range(
|
|
596
249
|
token.editorRange.startLineNumber,
|
|
597
250
|
token.editorRange.startColumn,
|
|
598
251
|
token.editorRange.endLineNumber,
|
|
599
252
|
token.editorRange.endColumn - length
|
|
600
|
-
))
|
|
253
|
+
));
|
|
601
254
|
this.widget.inputEditor.executeEdits(this.id, [{
|
|
602
255
|
range: rangeToDelete,
|
|
603
256
|
text: '',
|
|
@@ -610,7 +263,7 @@ let ChatTokenDeleter = class ChatTokenDeleter extends Disposable {
|
|
|
610
263
|
}));
|
|
611
264
|
}
|
|
612
265
|
};
|
|
613
|
-
ChatTokenDeleter = (
|
|
614
|
-
(
|
|
615
|
-
], ChatTokenDeleter))
|
|
266
|
+
ChatTokenDeleter = ( __decorate([
|
|
267
|
+
( __param(1, IInstantiationService))
|
|
268
|
+
], ChatTokenDeleter));
|
|
616
269
|
ChatWidget.CONTRIBS.push(ChatTokenDeleter);
|