-
Notifications
You must be signed in to change notification settings - Fork 141
Expand file tree
/
Copy pathchat.contribution.ts
More file actions
1106 lines (1070 loc) · 55.8 KB
/
chat.contribution.ts
File metadata and controls
1106 lines (1070 loc) · 55.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { timeout } from '../../../../base/common/async.js';
import { Event } from '../../../../base/common/event.js';
import { MarkdownString, isMarkdownString } from '../../../../base/common/htmlContent.js';
import { Disposable, DisposableMap } from '../../../../base/common/lifecycle.js';
import { Schemas } from '../../../../base/common/network.js';
import { isMacintosh } from '../../../../base/common/platform.js';
import { PolicyCategory } from '../../../../base/common/policy.js';
import { registerEditorFeature } from '../../../../editor/common/editorFeatures.js';
import * as nls from '../../../../nls.js';
import { AccessibleViewRegistry } from '../../../../platform/accessibility/browser/accessibleViewRegistry.js';
import { registerAction2 } from '../../../../platform/actions/common/actions.js';
import { ICommandService } from '../../../../platform/commands/common/commands.js';
import { Extensions as ConfigurationExtensions, ConfigurationScope, IConfigurationNode, IConfigurationRegistry } from '../../../../platform/configuration/common/configurationRegistry.js';
import { SyncDescriptor } from '../../../../platform/instantiation/common/descriptors.js';
import { InstantiationType, registerSingleton } from '../../../../platform/instantiation/common/extensions.js';
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
import { McpAccessValue, McpAutoStartValue, mcpAccessConfig, mcpAutoStartConfig, mcpGalleryServiceEnablementConfig, mcpGalleryServiceUrlConfig } from '../../../../platform/mcp/common/mcpManagement.js';
import product from '../../../../platform/product/common/product.js';
import { Registry } from '../../../../platform/registry/common/platform.js';
import { EditorPaneDescriptor, IEditorPaneRegistry } from '../../../browser/editor.js';
import { Extensions, IConfigurationMigrationRegistry } from '../../../common/configuration.js';
import { IWorkbenchContribution, WorkbenchPhase, registerWorkbenchContribution2 } from '../../../common/contributions.js';
import { EditorExtensions, IEditorFactoryRegistry } from '../../../common/editor.js';
import { IWorkbenchAssignmentService } from '../../../services/assignment/common/assignmentService.js';
import { ChatEntitlement, IChatEntitlementService } from '../../../services/chat/common/chatEntitlementService.js';
import { IEditorResolverService, RegisteredEditorPriority } from '../../../services/editor/common/editorResolverService.js';
import { AddConfigurationType, AssistedTypes } from '../../mcp/browser/mcpCommandsAddConfiguration.js';
import { allDiscoverySources, discoverySourceSettingsLabel, mcpDiscoverySection, mcpServerSamplingSection } from '../../mcp/common/mcpConfiguration.js';
import { ChatAgentNameService, ChatAgentService, IChatAgentNameService, IChatAgentService } from '../common/chatAgents.js';
import { CodeMapperService, ICodeMapperService } from '../common/chatCodeMapperService.js';
import '../common/chatColors.js';
import { IChatEditingService } from '../common/chatEditingService.js';
import { IChatLayoutService } from '../common/chatLayoutService.js';
import { ChatModeService, IChatModeService } from '../common/chatModes.js';
import { ChatResponseResourceFileSystemProvider } from '../common/chatResponseResourceFileSystemProvider.js';
import { IChatService } from '../common/chatService.js';
import { ChatService } from '../common/chatServiceImpl.js';
import { IChatSessionsService } from '../common/chatSessionsService.js';
import { ChatSlashCommandService, IChatSlashCommandService } from '../common/chatSlashCommands.js';
import { ChatTodoListService, IChatTodoListService } from '../common/chatTodoListService.js';
import { ChatTransferService, IChatTransferService } from '../common/chatTransferService.js';
import { IChatVariablesService } from '../common/chatVariables.js';
import { ChatWidgetHistoryService, IChatWidgetHistoryService } from '../common/chatWidgetHistoryService.js';
import { ChatAgentLocation, ChatConfiguration, ChatModeKind } from '../common/constants.js';
import { ILanguageModelIgnoredFilesService, LanguageModelIgnoredFilesService } from '../common/ignoredFiles.js';
import { ILanguageModelsService, LanguageModelsService } from '../common/languageModels.js';
import { ILanguageModelStatsService, LanguageModelStatsService } from '../common/languageModelStats.js';
import { ILanguageModelToolsConfirmationService } from '../common/languageModelToolsConfirmationService.js';
import { ILanguageModelToolsService } from '../common/languageModelToolsService.js';
import { ChatPromptFilesExtensionPointHandler } from '../common/promptSyntax/chatPromptFilesContribution.js';
import { PromptsConfig } from '../common/promptSyntax/config/config.js';
import { INSTRUCTIONS_DEFAULT_SOURCE_FOLDER, INSTRUCTION_FILE_EXTENSION, LEGACY_MODE_DEFAULT_SOURCE_FOLDER, LEGACY_MODE_FILE_EXTENSION, PROMPT_DEFAULT_SOURCE_FOLDER, PROMPT_FILE_EXTENSION } from '../common/promptSyntax/config/promptFileLocations.js';
import { PromptLanguageFeaturesProvider } from '../common/promptSyntax/promptFileContributions.js';
import { AGENT_DOCUMENTATION_URL, INSTRUCTIONS_DOCUMENTATION_URL, PROMPT_DOCUMENTATION_URL } from '../common/promptSyntax/promptTypes.js';
import { IPromptsService } from '../common/promptSyntax/service/promptsService.js';
import { PromptsService } from '../common/promptSyntax/service/promptsServiceImpl.js';
import { LanguageModelToolsExtensionPointHandler } from '../common/tools/languageModelToolsContribution.js';
import { BuiltinToolsContribution } from '../common/tools/tools.js';
import { IVoiceChatService, VoiceChatService } from '../common/voiceChatService.js';
import { registerChatAccessibilityActions } from './actions/chatAccessibilityActions.js';
import { AgentChatAccessibilityHelp, EditsChatAccessibilityHelp, PanelChatAccessibilityHelp, QuickChatAccessibilityHelp } from './actions/chatAccessibilityHelp.js';
import { ACTION_ID_NEW_CHAT, CopilotTitleBarMenuRendering, registerChatActions } from './actions/chatActions.js';
import { CodeBlockActionRendering, registerChatCodeBlockActions, registerChatCodeCompareBlockActions } from './actions/chatCodeblockActions.js';
import { ChatContextContributions } from './actions/chatContext.js';
import { registerChatContextActions } from './actions/chatContextActions.js';
import { registerChatCopyActions } from './actions/chatCopyActions.js';
import { registerChatDeveloperActions } from './actions/chatDeveloperActions.js';
import { ChatSubmitAction, registerChatExecuteActions } from './actions/chatExecuteActions.js';
import { registerChatFileTreeActions } from './actions/chatFileTreeActions.js';
import { ChatGettingStartedContribution } from './actions/chatGettingStarted.js';
import { registerChatExportActions } from './actions/chatImportExport.js';
import { registerLanguageModelActions } from './actions/chatLanguageModelActions.js';
import { registerMoveActions } from './actions/chatMoveActions.js';
import { registerNewChatActions } from './actions/chatNewActions.js';
import { registerChatPromptNavigationActions } from './actions/chatPromptNavigationActions.js';
import { registerQuickChatActions } from './actions/chatQuickInputActions.js';
import { ChatSessionsGettingStartedAction, DeleteChatSessionAction, OpenChatSessionInNewEditorGroupAction, OpenChatSessionInNewWindowAction, OpenChatSessionInSidebarAction, RenameChatSessionAction, ToggleAgentSessionsViewLocationAction, ToggleChatSessionsDescriptionDisplayAction } from './actions/chatSessionActions.js';
import { registerChatTitleActions } from './actions/chatTitleActions.js';
import { registerChatToolActions } from './actions/chatToolActions.js';
import { ChatTransferContribution } from './actions/chatTransfer.js';
import './agentSessions/agentSessionsView.js';
import { IChatAccessibilityService, IChatCodeBlockContextProviderService, IChatWidgetService, IQuickChatService } from './chat.js';
import { ChatAccessibilityService } from './chatAccessibilityService.js';
import './chatAttachmentModel.js';
import { ChatAttachmentResolveService, IChatAttachmentResolveService } from './chatAttachmentResolveService.js';
import { ChatMarkdownAnchorService, IChatMarkdownAnchorService } from './chatContentParts/chatMarkdownAnchorService.js';
import { ChatContextPickService, IChatContextPickService } from './chatContextPickService.js';
import { ChatInputBoxContentProvider } from './chatEdinputInputContentProvider.js';
import { ChatEditingEditorAccessibility } from './chatEditing/chatEditingEditorAccessibility.js';
import { registerChatEditorActions } from './chatEditing/chatEditingEditorActions.js';
import { ChatEditingEditorContextKeys } from './chatEditing/chatEditingEditorContextKeys.js';
import { ChatEditingEditorOverlay } from './chatEditing/chatEditingEditorOverlay.js';
import { ChatEditingService } from './chatEditing/chatEditingServiceImpl.js';
import { ChatEditingNotebookFileSystemProviderContrib } from './chatEditing/notebook/chatEditingNotebookFileSystemProvider.js';
import { SimpleBrowserOverlay } from './chatEditing/simpleBrowserEditorOverlay.js';
import { ChatEditor, IChatEditorOptions } from './chatEditor.js';
import { ChatEditorInput, ChatEditorInputSerializer } from './chatEditorInput.js';
import { ChatLayoutService } from './chatLayoutService.js';
import './chatManagement/chatManagement.contribution.js';
import { agentSlashCommandToMarkdown, agentToMarkdown } from './chatMarkdownDecorationsRenderer.js';
import { ChatOutputRendererService, IChatOutputRendererService } from './chatOutputItemRenderer.js';
import { ChatCompatibilityNotifier, ChatExtensionPointHandler } from './chatParticipant.contribution.js';
import { ChatPasteProvidersFeature } from './chatPasteProviders.js';
import { QuickChatService } from './chatQuick.js';
import { ChatResponseAccessibleView } from './chatResponseAccessibleView.js';
import { LocalChatSessionsProvider } from './chatSessions/localChatSessionsProvider.js';
import { ChatSessionsView, ChatSessionsViewContrib } from './chatSessions/view/chatSessionsView.js';
import { ChatSetupContribution, ChatTeardownContribution } from './chatSetup.js';
import { ChatStatusBarEntry } from './chatStatus.js';
import { ChatVariablesService } from './chatVariables.js';
import { ChatWidget, ChatWidgetService } from './chatWidget.js';
import { ChatCodeBlockContextProviderService } from './codeBlockContextProviderService.js';
import { ChatDynamicVariableModel } from './contrib/chatDynamicVariables.js';
import { ChatImplicitContextContribution } from './contrib/chatImplicitContext.js';
import './contrib/chatInputCompletions.js';
import './contrib/chatInputEditorContrib.js';
import './contrib/chatInputEditorHover.js';
import { ChatRelatedFilesContribution } from './contrib/chatInputRelatedFilesContrib.js';
import { LanguageModelToolsConfirmationService } from './languageModelToolsConfirmationService.js';
import { LanguageModelToolsService, globalAutoApproveDescription } from './languageModelToolsService.js';
import './promptSyntax/promptCodingAgentActionContribution.js';
import './promptSyntax/promptToolsCodeLensProvider.js';
import { PromptUrlHandler } from './promptSyntax/promptUrlHandler.js';
import { ConfigureToolSets, UserToolSetsContributions } from './tools/toolSetsContribution.js';
import { ChatViewsWelcomeHandler } from './viewsWelcome/chatViewsWelcomeHandler.js';
// --- Start Positron ---
import { PositronBuiltinToolsContribution } from './tools/tools.js';
import { ChatRuntimeSessionContextContribution } from './contrib/chatRuntimeSessionContext.js';
import { INSTRUCTIONS_POSITRON_SOURCE_FOLDER, PROMPT_POSITRON_SOURCE_FOLDER, LEGACY_MODE_POSITRON_SOURCE_FOLDER } from '../common/promptSyntax/config/promptFileLocations.js';
// --- End Positron ---
// Register configuration
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
configurationRegistry.registerConfiguration({
id: 'chatSidebar',
title: nls.localize('interactiveSessionConfigurationTitle', "Chat"),
type: 'object',
properties: {
'chat.fontSize': {
type: 'number',
description: nls.localize('chat.fontSize', "Controls the font size in pixels in chat messages."),
default: 13,
minimum: 6,
maximum: 100
},
'chat.fontFamily': {
type: 'string',
description: nls.localize('chat.fontFamily', "Controls the font family in chat messages."),
default: 'default'
},
'chat.editor.fontSize': {
type: 'number',
description: nls.localize('interactiveSession.editor.fontSize', "Controls the font size in pixels in chat codeblocks."),
default: isMacintosh ? 12 : 14,
},
'chat.editor.fontFamily': {
type: 'string',
description: nls.localize('interactiveSession.editor.fontFamily', "Controls the font family in chat codeblocks."),
default: 'default'
},
'chat.editor.fontWeight': {
type: 'string',
description: nls.localize('interactiveSession.editor.fontWeight', "Controls the font weight in chat codeblocks."),
default: 'default'
},
'chat.editor.wordWrap': {
type: 'string',
description: nls.localize('interactiveSession.editor.wordWrap', "Controls whether lines should wrap in chat codeblocks."),
default: 'off',
enum: ['on', 'off']
},
'chat.editor.lineHeight': {
type: 'number',
description: nls.localize('interactiveSession.editor.lineHeight', "Controls the line height in pixels in chat codeblocks. Use 0 to compute the line height from the font size."),
default: 0
},
'chat.commandCenter.enabled': {
type: 'boolean',
markdownDescription: nls.localize('chat.commandCenter.enabled', "Controls whether the command center shows a menu for actions to control chat (requires {0}).", '`#window.commandCenter#`'),
default: true
},
'chat.implicitContext.enabled': {
type: 'object',
tags: ['experimental'],
description: nls.localize('chat.implicitContext.enabled.1', "Enables automatically using the active editor as chat context for specified chat locations."),
additionalProperties: {
type: 'string',
enum: ['never', 'first', 'always'],
description: nls.localize('chat.implicitContext.value', "The value for the implicit context."),
enumDescriptions: [
nls.localize('chat.implicitContext.value.never', "Implicit context is never enabled."),
nls.localize('chat.implicitContext.value.first', "Implicit context is enabled for the first interaction."),
nls.localize('chat.implicitContext.value.always', "Implicit context is always enabled.")
]
},
default: {
'panel': 'always',
}
},
'chat.implicitContext.suggestedContext': {
type: 'boolean',
tags: ['experimental'],
markdownDescription: nls.localize('chat.implicitContext.suggestedContext', "Controls whether the new implicit context flow is shown. In Ask and Edit modes, the context will automatically be included. When using an agent, context will be suggested as an attachment. Selections are always included as context."),
default: true,
},
// --- Start Positron ---
'chat.implicitSessionContext.enabled': {
type: 'object',
tags: ['experimental'],
description: nls.localize('chat.implicitSessionContext.enabled.1', "Enables automatically using the active interpreter session as chat context for specified chat locations."),
additionalProperties: {
type: 'string',
enum: ['never', 'first', 'always'],
description: nls.localize('chat.implicitSessionContext.value', "The value for the implicit runtime context."),
enumDescriptions: [
nls.localize('chat.implicitSessionContext.value.never', "Implicit session context is never enabled."),
nls.localize('chat.implicitSessionContext.value.first', "Implicit session context is enabled for the first interaction."),
nls.localize('chat.implicitSessionContext.value.always', "Implicit session context is always enabled.")
]
},
default: {
'panel': 'always',
}
},
'chat.runtimeSessionContext.maxExecutionHistoryCharacters': {
type: 'number',
tags: ['experimental'],
description: nls.localize('chat.runtimeSessionContext.maxExecutionHistoryCharacters', "The maximum character count for the runtime session execution history context. This is used to limit the size of the context that is sent to the model. The default is 8192 characters."),
default: 8192, // 8k characters
minimum: 1024,
},
'chat.useCopilotParticipantsWithOtherProviders': {
type: 'boolean',
markdownDescription: nls.localize('chat.useCopilotParticipantsWithOtherProviders', "Allow any model in Positron Assistant to use chat participants provided by GitHub Copilot.\n\nThis requires that you are signed into Copilot, and **may send data to Copilot models regardless of the selected provider**.\n\n See also: `#positron.assistant.alwaysIncludeCopilotTools#`"),
default: false
},
// --- End Positron ---
'chat.editing.autoAcceptDelay': {
type: 'number',
markdownDescription: nls.localize('chat.editing.autoAcceptDelay', "Delay after which changes made by chat are automatically accepted. Values are in seconds, `0` means disabled and `100` seconds is the maximum."),
default: 0,
minimum: 0,
maximum: 100
},
'chat.editing.confirmEditRequestRemoval': {
type: 'boolean',
scope: ConfigurationScope.APPLICATION,
markdownDescription: nls.localize('chat.editing.confirmEditRequestRemoval', "Whether to show a confirmation before removing a request and its associated edits."),
default: true,
},
'chat.editing.confirmEditRequestRetry': {
type: 'boolean',
scope: ConfigurationScope.APPLICATION,
markdownDescription: nls.localize('chat.editing.confirmEditRequestRetry', "Whether to show a confirmation before retrying a request and its associated edits."),
default: true,
},
'chat.experimental.detectParticipant.enabled': {
type: 'boolean',
deprecationMessage: nls.localize('chat.experimental.detectParticipant.enabled.deprecated', "This setting is deprecated. Please use `chat.detectParticipant.enabled` instead."),
description: nls.localize('chat.experimental.detectParticipant.enabled', "Enables chat participant autodetection for panel chat."),
default: null
},
'chat.detectParticipant.enabled': {
type: 'boolean',
description: nls.localize('chat.detectParticipant.enabled', "Enables chat participant autodetection for panel chat."),
default: true
},
'chat.renderRelatedFiles': {
type: 'boolean',
description: nls.localize('chat.renderRelatedFiles', "Controls whether related files should be rendered in the chat input."),
default: false
},
'chat.notifyWindowOnConfirmation': {
type: 'boolean',
description: nls.localize('chat.notifyWindowOnConfirmation', "Controls whether a chat session should present the user with an OS notification when a confirmation is needed while the window is not in focus. This includes a window badge as well as notification toast."),
default: true,
},
[ChatConfiguration.GlobalAutoApprove]: {
default: false,
markdownDescription: globalAutoApproveDescription.value,
type: 'boolean',
scope: ConfigurationScope.APPLICATION_MACHINE,
tags: ['experimental'],
policy: {
name: 'ChatToolsAutoApprove',
category: PolicyCategory.InteractiveSession,
minimumVersion: '1.99',
value: (account) => account.chat_preview_features_enabled === false ? false : undefined,
localization: {
description: {
key: 'autoApprove2.description',
value: nls.localize('autoApprove2.description', 'Global auto approve also known as "YOLO mode" disables manual approval completely for all tools in all workspaces, allowing the agent to act fully autonomously. This is extremely dangerous and is *never* recommended, even containerized environments like Codespaces and Dev Containers have user keys forwarded into the container that could be compromised.\n\nThis feature disables critical security protections and makes it much easier for an attacker to compromise the machine.')
}
},
}
},
[ChatConfiguration.AutoApproveEdits]: {
default: {
'**/*': true,
'**/.vscode/*.json': false,
'**/.git/**': false,
'**/{package.json,package-lock.json,server.xml,build.rs,web.config,.gitattributes,.env}': false,
'**/*.{csproj,fsproj,vbproj,vcxproj,proj,targets,props}': false,
},
markdownDescription: nls.localize('chat.tools.autoApprove.edits', "Controls whether edits made by chat are automatically approved. The default is to approve all edits except those made to certain files which have the potential to cause immediate unintended side-effects, such as `**/.vscode/*.json`.\n\nSet to `true` to automatically approve edits to matching files, `false` to always require explicit approval. The last pattern matching a given file will determine whether the edit is automatically approved."),
type: 'object',
additionalProperties: {
type: 'boolean',
}
},
'chat.sendElementsToChat.enabled': {
default: true,
description: nls.localize('chat.sendElementsToChat.enabled', "Controls whether elements can be sent to chat from the Simple Browser."),
type: 'boolean',
tags: ['experimental']
},
'chat.sendElementsToChat.attachCSS': {
default: true,
markdownDescription: nls.localize('chat.sendElementsToChat.attachCSS', "Controls whether CSS of the selected element will be added to the chat. {0} must be enabled.", '`#chat.sendElementsToChat.enabled#`'),
type: 'boolean',
tags: ['experimental']
},
'chat.sendElementsToChat.attachImages': {
default: true,
markdownDescription: nls.localize('chat.sendElementsToChat.attachImages', "Controls whether a screenshot of the selected element will be added to the chat. {0} must be enabled.", '`#chat.sendElementsToChat.enabled#`'),
type: 'boolean',
tags: ['experimental']
},
'chat.undoRequests.restoreInput': {
default: true,
markdownDescription: nls.localize('chat.undoRequests.restoreInput', "Controls whether the input of the chat should be restored when an undo request is made. The input will be filled with the text of the request that was restored."),
type: 'boolean',
tags: ['experimental']
},
'chat.editRequests': {
markdownDescription: nls.localize('chat.editRequests', "Enables editing of requests in the chat. This allows you to change the request content and resubmit it to the model."),
type: 'string',
enum: ['inline', 'hover', 'input', 'none'],
default: 'inline',
},
[ChatConfiguration.EmptyStateHistoryEnabled]: {
type: 'boolean',
default: product.quality === 'insiders',
description: nls.localize('chat.emptyState.history.enabled', "Show recent chat history on the empty chat state."),
tags: ['experimental']
},
[ChatConfiguration.NotifyWindowOnResponseReceived]: {
type: 'boolean',
default: true,
description: nls.localize('chat.notifyWindowOnResponseReceived', "Controls whether a chat session should present the user with an OS notification when a response is received while the window is not in focus. This includes a window badge as well as notification toast."),
},
'chat.checkpoints.enabled': {
type: 'boolean',
default: true,
description: nls.localize('chat.checkpoints.enabled', "Enables checkpoints in chat. Checkpoints allow you to restore the chat to a previous state."),
},
'chat.checkpoints.showFileChanges': {
type: 'boolean',
description: nls.localize('chat.checkpoints.showFileChanges', "Controls whether to show chat checkpoint file changes."),
default: false
},
[mcpAccessConfig]: {
type: 'string',
description: nls.localize('chat.mcp.access', "Controls access to installed Model Context Protocol servers."),
enum: [
McpAccessValue.None,
McpAccessValue.Registry,
McpAccessValue.All
],
enumDescriptions: [
nls.localize('chat.mcp.access.none', "No access to MCP servers."),
nls.localize('chat.mcp.access.registry', "Allows access to MCP servers installed from the registry that VS Code is connected to."),
nls.localize('chat.mcp.access.any', "Allow access to any installed MCP server.")
],
default: McpAccessValue.All,
policy: {
name: 'ChatMCP',
category: PolicyCategory.InteractiveSession,
minimumVersion: '1.99',
value: (account) => {
if (account.mcp === false) {
return McpAccessValue.None;
}
if (account.mcpAccess === 'registry_only') {
return McpAccessValue.Registry;
}
return undefined;
},
localization: {
description: {
key: 'chat.mcp.access',
value: nls.localize('chat.mcp.access', "Controls access to installed Model Context Protocol servers.")
},
enumDescriptions: [
{
key: 'chat.mcp.access.none', value: nls.localize('chat.mcp.access.none', "No access to MCP servers."),
},
{
key: 'chat.mcp.access.registry', value: nls.localize('chat.mcp.access.registry', "Allows access to MCP servers installed from the registry that VS Code is connected to."),
},
{
key: 'chat.mcp.access.any', value: nls.localize('chat.mcp.access.any', "Allow access to any installed MCP server.")
}
]
},
}
},
[mcpAutoStartConfig]: {
type: 'string',
description: nls.localize('chat.mcp.autostart', "Controls whether MCP servers should be automatically started when the chat messages are submitted."),
default: McpAutoStartValue.NewAndOutdated,
enum: [
McpAutoStartValue.Never,
McpAutoStartValue.OnlyNew,
McpAutoStartValue.NewAndOutdated
],
enumDescriptions: [
nls.localize('chat.mcp.autostart.never', "Never automatically start MCP servers."),
nls.localize('chat.mcp.autostart.onlyNew', "Only automatically start new MCP servers that have never been run."),
nls.localize('chat.mcp.autostart.newAndOutdated', "Automatically start new and outdated MCP servers that are not yet running.")
],
tags: ['experimental'],
},
[mcpServerSamplingSection]: {
type: 'object',
description: nls.localize('chat.mcp.serverSampling', "Configures which models are exposed to MCP servers for sampling (making model requests in the background). This setting can be edited in a graphical way under the `{0}` command.", 'MCP: ' + nls.localize('mcp.list', 'List Servers')),
scope: ConfigurationScope.RESOURCE,
additionalProperties: {
type: 'object',
properties: {
allowedDuringChat: {
type: 'boolean',
description: nls.localize('chat.mcp.serverSampling.allowedDuringChat', "Whether this server is make sampling requests during its tool calls in a chat session."),
default: true,
},
allowedOutsideChat: {
type: 'boolean',
description: nls.localize('chat.mcp.serverSampling.allowedOutsideChat', "Whether this server is allowed to make sampling requests outside of a chat session."),
default: false,
},
allowedModels: {
type: 'array',
items: {
type: 'string',
description: nls.localize('chat.mcp.serverSampling.model', "A model the MCP server has access to."),
},
}
}
},
},
[AssistedTypes[AddConfigurationType.NuGetPackage].enabledConfigKey]: {
type: 'boolean',
description: nls.localize('chat.mcp.assisted.nuget.enabled.description', "Enables NuGet packages for AI-assisted MCP server installation. Used to install MCP servers by name from the central registry for .NET packages (NuGet.org)."),
default: false,
tags: ['experimental'],
experiment: {
mode: 'startup'
}
},
[ChatConfiguration.Edits2Enabled]: {
type: 'boolean',
description: nls.localize('chat.edits2Enabled', "Enable the new Edits mode that is based on tool-calling. When this is enabled, models that don't support tool-calling are unavailable for Edits mode."),
default: false,
},
[ChatConfiguration.ExtensionToolsEnabled]: {
type: 'boolean',
description: nls.localize('chat.extensionToolsEnabled', "Enable using tools contributed by third-party extensions."),
default: true,
policy: {
name: 'ChatAgentExtensionTools',
category: PolicyCategory.InteractiveSession,
minimumVersion: '1.99',
localization: {
description: {
key: 'chat.extensionToolsEnabled',
value: nls.localize('chat.extensionToolsEnabled', "Enable using tools contributed by third-party extensions.")
}
},
}
},
[ChatConfiguration.AgentEnabled]: {
type: 'boolean',
description: nls.localize('chat.agent.enabled.description', "Enable agent mode for chat. When this is enabled, agent mode can be activated via the dropdown in the view."),
default: true,
policy: {
name: 'ChatAgentMode',
category: PolicyCategory.InteractiveSession,
minimumVersion: '1.99',
value: (account) => account.chat_agent_enabled === false ? false : undefined,
localization: {
description: {
key: 'chat.agent.enabled.description',
value: nls.localize('chat.agent.enabled.description', "Enable agent mode for chat. When this is enabled, agent mode can be activated via the dropdown in the view."),
}
}
}
},
[ChatConfiguration.EnableMath]: {
type: 'boolean',
description: nls.localize('chat.mathEnabled.description', "Enable math rendering in chat responses using KaTeX."),
default: true,
tags: ['preview'],
},
[ChatConfiguration.AgentSessionsViewLocation]: {
type: 'string',
enum: ['disabled', 'view', 'single-view'],
description: nls.localize('chat.sessionsViewLocation.description', "Controls where to show the agent sessions menu."),
default: 'view',
tags: ['experimental'],
experiment: {
mode: 'auto'
}
},
[mcpDiscoverySection]: {
type: 'object',
properties: Object.fromEntries(allDiscoverySources.map(k => [k, { type: 'boolean', description: discoverySourceSettingsLabel[k] }])),
additionalProperties: false,
default: Object.fromEntries(allDiscoverySources.map(k => [k, false])),
markdownDescription: nls.localize('mcp.discovery.enabled', "Configures discovery of Model Context Protocol servers from configuration from various other applications."),
},
[mcpGalleryServiceEnablementConfig]: {
type: 'boolean',
default: false,
tags: ['preview'],
description: nls.localize('chat.mcp.gallery.enabled', "Enables the default Marketplace for Model Context Protocol (MCP) servers."),
included: product.quality === 'stable'
},
[mcpGalleryServiceUrlConfig]: {
type: 'string',
description: nls.localize('mcp.gallery.serviceUrl', "Configure the MCP Gallery service URL to connect to"),
default: '',
scope: ConfigurationScope.APPLICATION,
tags: ['usesOnlineServices', 'advanced'],
included: false,
policy: {
name: 'McpGalleryServiceUrl',
category: PolicyCategory.InteractiveSession,
minimumVersion: '1.101',
value: (account) => account.mcpRegistryUrl,
localization: {
description: {
key: 'mcp.gallery.serviceUrl',
value: nls.localize('mcp.gallery.serviceUrl', "Configure the MCP Gallery service URL to connect to"),
}
}
},
},
[PromptsConfig.INSTRUCTIONS_LOCATION_KEY]: {
type: 'object',
title: nls.localize(
'chat.instructions.config.locations.title',
"Instructions File Locations",
),
markdownDescription: nls.localize(
'chat.instructions.config.locations.description',
"Specify location(s) of instructions files (`*{0}`) that can be attached in Chat sessions. [Learn More]({1}).\n\nRelative paths are resolved from the root folder(s) of your workspace.",
INSTRUCTION_FILE_EXTENSION,
INSTRUCTIONS_DOCUMENTATION_URL,
),
default: {
[INSTRUCTIONS_DEFAULT_SOURCE_FOLDER]: true,
// --- Start Positron ---
[INSTRUCTIONS_POSITRON_SOURCE_FOLDER]: true,
// --- End Positron ---
},
additionalProperties: { type: 'boolean' },
restricted: true,
tags: ['prompts', 'reusable prompts', 'prompt snippets', 'instructions'],
examples: [
{
[INSTRUCTIONS_DEFAULT_SOURCE_FOLDER]: true,
},
{
[INSTRUCTIONS_DEFAULT_SOURCE_FOLDER]: true,
'/Users/vscode/repos/instructions': true,
},
],
},
[PromptsConfig.PROMPT_LOCATIONS_KEY]: {
type: 'object',
title: nls.localize(
'chat.reusablePrompts.config.locations.title',
"Prompt File Locations",
),
markdownDescription: nls.localize(
'chat.reusablePrompts.config.locations.description',
"Specify location(s) of reusable prompt files (`*{0}`) that can be run in Chat sessions. [Learn More]({1}).\n\nRelative paths are resolved from the root folder(s) of your workspace.",
PROMPT_FILE_EXTENSION,
PROMPT_DOCUMENTATION_URL,
),
default: {
[PROMPT_DEFAULT_SOURCE_FOLDER]: true,
// --- Start Positron ---
[PROMPT_POSITRON_SOURCE_FOLDER]: true,
// --- End Positron ---
},
additionalProperties: { type: 'boolean' },
unevaluatedProperties: { type: 'boolean' },
restricted: true,
tags: ['prompts', 'reusable prompts', 'prompt snippets', 'instructions'],
examples: [
{
[PROMPT_DEFAULT_SOURCE_FOLDER]: true,
},
{
[PROMPT_DEFAULT_SOURCE_FOLDER]: true,
'/Users/vscode/repos/prompts': true,
},
],
},
[PromptsConfig.MODE_LOCATION_KEY]: {
type: 'object',
title: nls.localize(
'chat.mode.config.locations.title',
"Mode File Locations",
),
markdownDescription: nls.localize(
'chat.mode.config.locations.description',
"Specify location(s) of custom chat mode files (`*{0}`). [Learn More]({1}).\n\nRelative paths are resolved from the root folder(s) of your workspace.",
LEGACY_MODE_FILE_EXTENSION,
AGENT_DOCUMENTATION_URL,
),
default: {
// --- Start Positron ---
[LEGACY_MODE_POSITRON_SOURCE_FOLDER]: true,
// --- End Positron ---
[LEGACY_MODE_DEFAULT_SOURCE_FOLDER]: true,
},
deprecationMessage: nls.localize('chat.mode.config.locations.deprecated', "This setting is deprecated and will be removed in future releases. Chat modes are now called custom agents and are located in `.github/agents`"),
additionalProperties: { type: 'boolean' },
unevaluatedProperties: { type: 'boolean' },
restricted: true,
tags: ['experimental', 'prompts', 'reusable prompts', 'prompt snippets', 'instructions'],
examples: [
{
[LEGACY_MODE_DEFAULT_SOURCE_FOLDER]: true,
},
{
[LEGACY_MODE_DEFAULT_SOURCE_FOLDER]: true,
'/Users/vscode/repos/chatmodes': true,
},
],
},
[PromptsConfig.USE_AGENT_MD]: {
type: 'boolean',
title: nls.localize('chat.useAgentMd.title', "Use AGENTS.MD file",),
markdownDescription: nls.localize('chat.useAgentMd.description', "Controls whether instructions from `AGENTS.MD` file found in a workspace roots are added to all chat requests.",),
default: true,
restricted: true,
disallowConfigurationDefault: true,
tags: ['prompts', 'reusable prompts', 'prompt snippets', 'instructions']
},
[PromptsConfig.USE_NESTED_AGENT_MD]: {
type: 'boolean',
title: nls.localize('chat.useNestedAgentMd.title', "Use nested AGENTS.MD files",),
markdownDescription: nls.localize('chat.useNestedAgentMd.description', "Controls whether instructions `AGENTS.MD` files found in the workspace are listed in all chat requests.",),
default: false,
restricted: true,
disallowConfigurationDefault: true,
tags: ['experimental', 'prompts', 'reusable prompts', 'prompt snippets', 'instructions']
},
[PromptsConfig.PROMPT_FILES_SUGGEST_KEY]: {
type: 'object',
scope: ConfigurationScope.RESOURCE,
title: nls.localize(
'chat.promptFilesRecommendations.title',
"Prompt File Recommendations",
),
markdownDescription: nls.localize(
'chat.promptFilesRecommendations.description',
"Configure which prompt files to recommend in the chat welcome view. Each key is a prompt file name, and the value can be `true` to always recommend, `false` to never recommend, or a [when clause](https://aka.ms/vscode-when-clause) expression like `resourceExtname == .js` or `resourceLangId == markdown`.",
),
default: {},
additionalProperties: {
oneOf: [
{ type: 'boolean' },
{ type: 'string' }
]
},
tags: ['prompts', 'reusable prompts', 'prompt snippets', 'instructions'],
examples: [
{
'plan': true,
'a11y-audit': 'resourceExtname == .html',
'document': 'resourceLangId == markdown'
}
],
},
[ChatConfiguration.TodosShowWidget]: {
type: 'boolean',
default: true,
description: nls.localize('chat.tools.todos.showWidget', "Controls whether to show the todo list widget above the chat input. When enabled, the widget displays todo items created by the agent and updates as progress is made."),
tags: ['experimental'],
experiment: {
mode: 'auto'
}
},
'chat.todoListTool.writeOnly': {
type: 'boolean',
default: false,
description: nls.localize('chat.todoListTool.writeOnly', "When enabled, the todo tool operates in write-only mode, requiring the agent to remember todos in context."),
tags: ['experimental'],
experiment: {
mode: 'auto'
}
},
'chat.todoListTool.descriptionField': {
type: 'boolean',
default: true,
description: nls.localize('chat.todoListTool.descriptionField', "When enabled, todo items include detailed descriptions for implementation context. This provides more information but uses additional tokens and may slow down responses."),
tags: ['experimental'],
experiment: {
mode: 'auto'
}
},
[ChatConfiguration.ThinkingStyle]: {
type: 'string',
default: 'fixedScrolling',
enum: ['collapsed', 'collapsedPreview', 'fixedScrolling'],
enumDescriptions: [
nls.localize('chat.agent.thinkingMode.collapsed', "Thinking parts will be collapsed by default."),
nls.localize('chat.agent.thinkingMode.collapsedPreview', "Thinking parts will be expanded first, then collapse once we reach a part that is not thinking."),
nls.localize('chat.agent.thinkingMode.fixedScrolling', "Show thinking in a fixed-height streaming panel that auto-scrolls; click header to expand to full height."),
],
description: nls.localize('chat.agent.thinkingStyle', "Controls how thinking is rendered."),
tags: ['experimental'],
},
'chat.agent.thinking.collapsedTools': {
type: 'string',
default: 'readOnly',
enum: ['none', 'all', 'readOnly'],
enumDescriptions: [
nls.localize('chat.agent.thinking.collapsedTools.none', "No tool calls are added into the collapsible thinking section."),
nls.localize('chat.agent.thinking.collapsedTools.all', "All tool calls are added into the collapsible thinking section."),
nls.localize('chat.agent.thinking.collapsedTools.readOnly', "Only read-only tool calls are added into the collapsible thinking section."),
],
markdownDescription: nls.localize('chat.agent.thinking.collapsedTools', "When enabled, tool calls are added into the collapsible thinking section according to the selected mode."),
tags: ['experimental'],
},
'chat.disableAIFeatures': {
type: 'boolean',
description: nls.localize('chat.disableAIFeatures', "Disable and hide built-in AI features provided by GitHub Copilot, including chat and inline suggestions."),
default: false,
scope: ConfigurationScope.WINDOW
},
[ChatConfiguration.UseCloudButtonV2]: {
type: 'boolean',
description: nls.localize('chat.useCloudButtonV2', "Experimental implementation of 'cloud button'"),
default: true,
tags: ['experimental'],
},
[ChatConfiguration.ShowAgentSessionsViewDescription]: {
type: 'boolean',
description: nls.localize('chat.showAgentSessionsViewDescription', "Controls whether session descriptions are displayed on a second row in the Chat Sessions view."),
default: true,
},
'chat.allowAnonymousAccess': { // TODO@bpasero remove me eventually
type: 'boolean',
description: nls.localize('chat.allowAnonymousAccess', "Controls whether anonymous access is allowed in chat."),
default: false,
tags: ['experimental'],
experiment: {
mode: 'auto'
}
},
'chat.signInWithAlternateScopes': { // TODO@bpasero remove me eventually
type: 'boolean',
description: nls.localize('chat.signInWithAlternateScopes', "Controls whether sign-in with alternate scopes is used."),
default: false,
tags: ['experimental'],
experiment: {
mode: 'auto'
}
},
'chat.extensionUnification.enabled': {
type: 'boolean',
description: nls.localize('chat.extensionUnification.enabled', "Enables the unification of GitHub Copilot extensions. When enabled, all GitHub Copilot functionality is served from the GitHub Copilot Chat extension. When disabled, the GitHub Copilot and GitHub Copilot Chat extensions operate independently."),
default: false,
tags: ['experimental'],
experiment: {
mode: 'auto'
}
},
[ChatConfiguration.SubagentToolCustomAgents]: {
type: 'boolean',
description: nls.localize('chat.subagentTool.customAgents', "Whether the runSubagent tool is able to use custom agents. When enabled, the tool can take the name of a custom agent, but it must be given the exact name of the agent."),
default: false,
tags: ['experimental'],
}
}
});
Registry.as<IEditorPaneRegistry>(EditorExtensions.EditorPane).registerEditorPane(
EditorPaneDescriptor.create(
ChatEditor,
ChatEditorInput.EditorID,
nls.localize('chat', "Chat")
),
[
new SyncDescriptor(ChatEditorInput)
]
);
Registry.as<IConfigurationMigrationRegistry>(Extensions.ConfigurationMigration).registerConfigurationMigrations([
{
key: 'chat.experimental.detectParticipant.enabled',
migrateFn: (value, _accessor) => ([
['chat.experimental.detectParticipant.enabled', { value: undefined }],
['chat.detectParticipant.enabled', { value: value !== false }]
])
},
{
key: mcpDiscoverySection,
migrateFn: (value: unknown) => {
if (typeof value === 'boolean') {
return { value: Object.fromEntries(allDiscoverySources.map(k => [k, value])) };
}
return { value };
}
},
]);
class ChatResolverContribution extends Disposable {
static readonly ID = 'workbench.contrib.chatResolver';
private readonly _editorRegistrations = this._register(new DisposableMap<string>());
constructor(
@IChatSessionsService chatSessionsService: IChatSessionsService,
@IEditorResolverService private readonly editorResolverService: IEditorResolverService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
) {
super();
this._registerEditor(Schemas.vscodeChatEditor);
this._registerEditor(Schemas.vscodeLocalChatSession);
this._register(chatSessionsService.onDidChangeContentProviderSchemes((e) => {
for (const scheme of e.added) {
this._registerEditor(scheme);
}
for (const scheme of e.removed) {
this._editorRegistrations.deleteAndDispose(scheme);
}
}));
for (const scheme of chatSessionsService.getContentProviderSchemes()) {
this._registerEditor(scheme);
}
}
private _registerEditor(scheme: string): void {
this._editorRegistrations.set(scheme, this.editorResolverService.registerEditor(`${scheme}:**/**`,
{
id: ChatEditorInput.EditorID,
label: nls.localize('chat', "Chat"),
priority: RegisteredEditorPriority.builtin
},
{
singlePerResource: true,
canSupportResource: resource => resource.scheme === scheme,
},
{
createEditorInput: ({ resource, options }) => {
return {
editor: this.instantiationService.createInstance(ChatEditorInput, resource, options as IChatEditorOptions),
options
};
}
}
));
}
}
class ChatAgentSettingContribution extends Disposable implements IWorkbenchContribution {
static readonly ID = 'workbench.contrib.chatAgentSetting';
constructor(
@IWorkbenchAssignmentService private readonly experimentService: IWorkbenchAssignmentService,
@IChatEntitlementService private readonly entitlementService: IChatEntitlementService,
) {
super();
this.registerMaxRequestsSetting();
}
private registerMaxRequestsSetting(): void {
let lastNode: IConfigurationNode | undefined;
const registerMaxRequestsSetting = () => {
const treatmentId = this.entitlementService.entitlement === ChatEntitlement.Free ?
'chatAgentMaxRequestsFree' :
'chatAgentMaxRequestsPro';
this.experimentService.getTreatment<number>(treatmentId).then(value => {
const defaultValue = value ?? (this.entitlementService.entitlement === ChatEntitlement.Free ? 25 : 25);
const node: IConfigurationNode = {
id: 'chatSidebar',
title: nls.localize('interactiveSessionConfigurationTitle', "Chat"),
type: 'object',
properties: {
'chat.agent.maxRequests': {
type: 'number',
markdownDescription: nls.localize('chat.agent.maxRequests', "The maximum number of requests to allow per-turn when using an agent. When the limit is reached, will ask to confirm to continue."),
default: defaultValue,
},
}
};
configurationRegistry.updateConfigurations({ remove: lastNode ? [lastNode] : [], add: [node] });
lastNode = node;
});
};
this._register(Event.runAndSubscribe(Event.debounce(this.entitlementService.onDidChangeEntitlement, () => { }, 1000), () => registerMaxRequestsSetting()));
}
}
AccessibleViewRegistry.register(new ChatResponseAccessibleView());
AccessibleViewRegistry.register(new PanelChatAccessibilityHelp());
AccessibleViewRegistry.register(new QuickChatAccessibilityHelp());
AccessibleViewRegistry.register(new EditsChatAccessibilityHelp());
AccessibleViewRegistry.register(new AgentChatAccessibilityHelp());
registerEditorFeature(ChatInputBoxContentProvider);
class ChatSlashStaticSlashCommandsContribution extends Disposable {
static readonly ID = 'workbench.contrib.chatSlashStaticSlashCommands';
constructor(
@IChatSlashCommandService slashCommandService: IChatSlashCommandService,
@ICommandService commandService: ICommandService,
@IChatAgentService chatAgentService: IChatAgentService,
@IChatWidgetService chatWidgetService: IChatWidgetService,
@IInstantiationService instantiationService: IInstantiationService,
) {
super();
this._store.add(slashCommandService.registerSlashCommand({
command: 'clear',
detail: nls.localize('clear', "Start a new chat"),
sortText: 'z2_clear',
executeImmediately: true,
locations: [ChatAgentLocation.Chat]
}, async () => {
commandService.executeCommand(ACTION_ID_NEW_CHAT);
}));
this._store.add(slashCommandService.registerSlashCommand({
command: 'help',
detail: '',
sortText: 'z1_help',
executeImmediately: true,
locations: [ChatAgentLocation.Chat],
modes: [ChatModeKind.Ask]
}, async (prompt, progress) => {
const defaultAgent = chatAgentService.getDefaultAgent(ChatAgentLocation.Chat);
const agents = chatAgentService.getAgents();
// Report prefix
if (defaultAgent?.metadata.helpTextPrefix) {
if (isMarkdownString(defaultAgent.metadata.helpTextPrefix)) {
progress.report({ content: defaultAgent.metadata.helpTextPrefix, kind: 'markdownContent' });
} else {
progress.report({ content: new MarkdownString(defaultAgent.metadata.helpTextPrefix), kind: 'markdownContent' });
}
progress.report({ content: new MarkdownString('\n\n'), kind: 'markdownContent' });
}
// Report agent list
const agentText = (await Promise.all(agents
.filter(a => !a.isDefault && !a.isCore)
.filter(a => a.locations.includes(ChatAgentLocation.Chat))
.map(async a => {
const description = a.description ? `- ${a.description}` : '';
const agentMarkdown = instantiationService.invokeFunction(accessor => agentToMarkdown(a, true, accessor));
const agentLine = `- ${agentMarkdown} ${description}`;
const commandText = a.slashCommands.map(c => {
const description = c.description ? `- ${c.description}` : '';
return `\t* ${agentSlashCommandToMarkdown(a, c)} ${description}`;
}).join('\n');
return (agentLine + '\n' + commandText).trim();
}))).join('\n');
progress.report({ content: new MarkdownString(agentText, { isTrusted: { enabledCommands: [ChatSubmitAction.ID] } }), kind: 'markdownContent' });
// Report help text ending
if (defaultAgent?.metadata.helpTextPostfix) {
progress.report({ content: new MarkdownString('\n\n'), kind: 'markdownContent' });
if (isMarkdownString(defaultAgent.metadata.helpTextPostfix)) {
progress.report({ content: defaultAgent.metadata.helpTextPostfix, kind: 'markdownContent' });
} else {
progress.report({ content: new MarkdownString(defaultAgent.metadata.helpTextPostfix), kind: 'markdownContent' });
}
}
// Without this, the response will be done before it renders and so it will not stream. This ensures that if the response starts