@codingame/monaco-vscode-chat-service-override 9.0.2 → 10.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.
Files changed (41) hide show
  1. package/chat.js +8 -2
  2. package/package.json +2 -2
  3. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +24 -25
  4. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +5 -7
  5. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +100 -293
  6. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +115 -26
  7. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +2 -2
  8. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +1 -1
  9. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +6 -8
  10. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +3 -3
  11. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +9 -7
  12. package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +448 -0
  13. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +58 -43
  14. package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js +2 -4
  15. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +7 -2
  16. package/vscode/src/vs/workbench/contrib/chat/browser/chatGettingStarted.js +131 -0
  17. package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipantContributions.js +88 -88
  18. package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +26 -0
  19. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +4 -2
  20. package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.js +6 -22
  21. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +11 -17
  22. package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +21 -14
  23. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +3 -3
  24. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/editorHoverWrapper.js +7 -1
  25. package/vscode/src/vs/workbench/contrib/chat/common/chatCodeMapperService.js +27 -0
  26. package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.js +52 -0
  27. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +25 -29
  28. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceTelemetry.js +8 -1
  29. package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +1 -2
  30. package/vscode/src/vs/workbench/contrib/chat/common/languageModelStats.js +7 -8
  31. package/vscode/src/vs/workbench/contrib/chat/common/languageModelToolsService.js +70 -20
  32. package/vscode/src/vs/workbench/contrib/chat/common/languageModels.js +172 -0
  33. package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +30 -12
  34. package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +1 -1
  35. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +11 -15
  36. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibilityHelp.js +1 -2
  37. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +5 -6
  38. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.js +5 -6
  39. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +5 -8
  40. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatContextAttachments.js +0 -58
  41. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputCompletions.js +0 -412
@@ -0,0 +1,448 @@
1
+ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
+ import { coalesce } from 'vscode/vscode/vs/base/common/arrays';
3
+ import { AsyncIterableObject } from 'vscode/vscode/vs/base/common/async';
4
+ import { VSBuffer } from 'vscode/vscode/vs/base/common/buffer';
5
+ import { CancellationTokenSource } from 'vscode/vscode/vs/base/common/cancellation';
6
+ import { isCancellationError } from 'vscode/vscode/vs/base/common/errors';
7
+ import { ResourceMap } from 'vscode/vscode/vs/base/common/map';
8
+ import { isEqual } from 'vscode/vscode/vs/base/common/resources';
9
+ import { splitLines } from 'vscode/vscode/vs/base/common/strings';
10
+ import { URI } from 'vscode/vscode/vs/base/common/uri';
11
+ import { isDiffEditor, isCodeEditor } from 'vscode/vscode/vs/editor/browser/editorBrowser';
12
+ import { ResourceTextEdit, IBulkEditService } from 'vscode/vscode/vs/editor/browser/services/bulkEditService';
13
+ import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
14
+ import { Range } from 'vscode/vscode/vs/editor/common/core/range';
15
+ import { isLocation } from 'vscode/vscode/vs/editor/common/languages';
16
+ import { ILanguageService } from 'vscode/vscode/vs/editor/common/languages/language';
17
+ import { ILanguageFeaturesService } from 'vscode/vscode/vs/editor/common/services/languageFeatures';
18
+ import { localize } from 'vscode/vscode/vs/nls';
19
+ import { IDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs.service';
20
+ import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
21
+ import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
22
+ import { IProgressService } from 'vscode/vscode/vs/platform/progress/common/progress.service';
23
+ import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService.service';
24
+ import { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles.service';
25
+ import { InlineChatController } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatController';
26
+ import { insertCell } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/controller/cellOperations';
27
+ import { CellKind, NOTEBOOK_EDITOR_ID } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
28
+ import { IChatService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService.service';
29
+ import { isResponseVM, isRequestVM } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatViewModel';
30
+
31
+ let InsertCodeBlockOperation = class InsertCodeBlockOperation {
32
+ constructor(editorService, textFileService, bulkEditService, codeEditorService, chatService, languageService, dialogService) {
33
+ this.editorService = editorService;
34
+ this.textFileService = textFileService;
35
+ this.bulkEditService = bulkEditService;
36
+ this.codeEditorService = codeEditorService;
37
+ this.chatService = chatService;
38
+ this.languageService = languageService;
39
+ this.dialogService = dialogService;
40
+ }
41
+ async run(context) {
42
+ const activeEditorControl = getEditableActiveCodeEditor(this.editorService);
43
+ if (activeEditorControl) {
44
+ await this.handleTextEditor(activeEditorControl, context);
45
+ }
46
+ else {
47
+ const activeNotebookEditor = getActiveNotebookEditor(this.editorService);
48
+ if (activeNotebookEditor) {
49
+ await this.handleNotebookEditor(activeNotebookEditor, context);
50
+ }
51
+ else {
52
+ this.notify(( localize(
53
+ 10728,
54
+ "To insert the code block, open a code editor or notebook editor and set the cursor at the location where to insert the code block."
55
+ )));
56
+ }
57
+ }
58
+ notifyUserAction(this.chatService, context, {
59
+ kind: 'insert',
60
+ codeBlockIndex: context.codeBlockIndex,
61
+ totalCharacters: context.code.length
62
+ });
63
+ }
64
+ async handleNotebookEditor(notebookEditor, codeBlockContext) {
65
+ if (notebookEditor.isReadOnly) {
66
+ this.notify(( localize(10729, "Cannot insert the code block to read-only notebook editor.")));
67
+ return false;
68
+ }
69
+ const focusRange = notebookEditor.getFocus();
70
+ const next = Math.max(focusRange.end - 1, 0);
71
+ insertCell(this.languageService, notebookEditor, next, CellKind.Code, 'below', codeBlockContext.code, true);
72
+ return true;
73
+ }
74
+ async handleTextEditor(codeEditor, codeBlockContext) {
75
+ const activeModel = codeEditor.getModel();
76
+ if (isReadOnly(activeModel, this.textFileService)) {
77
+ this.notify(( localize(10730, "Cannot insert the code block to read-only code editor.")));
78
+ return false;
79
+ }
80
+ const range = codeEditor.getSelection() ?? ( (new Range(activeModel.getLineCount(), 1, activeModel.getLineCount(), 1)));
81
+ const text = reindent(codeBlockContext.code, activeModel, range.startLineNumber);
82
+ const edits = [( (new ResourceTextEdit(activeModel.uri, { range, text })))];
83
+ await this.bulkEditService.apply(edits);
84
+ this.codeEditorService.listCodeEditors().find(editor => editor.getModel()?.uri.toString() === ( (activeModel.uri.toString())))?.focus();
85
+ return true;
86
+ }
87
+ notify(message) {
88
+ this.dialogService.info(message);
89
+ }
90
+ };
91
+ InsertCodeBlockOperation = ( (__decorate([
92
+ ( (__param(0, IEditorService))),
93
+ ( (__param(1, ITextFileService))),
94
+ ( (__param(2, IBulkEditService))),
95
+ ( (__param(3, ICodeEditorService))),
96
+ ( (__param(4, IChatService))),
97
+ ( (__param(5, ILanguageService))),
98
+ ( (__param(6, IDialogService)))
99
+ ], InsertCodeBlockOperation)));
100
+ let ApplyCodeBlockOperation = class ApplyCodeBlockOperation {
101
+ constructor(editorService, textFileService, bulkEditService, codeEditorService, chatService, languageFeaturesService, progressService, languageService, fileService, dialogService, logService) {
102
+ this.editorService = editorService;
103
+ this.textFileService = textFileService;
104
+ this.bulkEditService = bulkEditService;
105
+ this.codeEditorService = codeEditorService;
106
+ this.chatService = chatService;
107
+ this.languageFeaturesService = languageFeaturesService;
108
+ this.progressService = progressService;
109
+ this.languageService = languageService;
110
+ this.fileService = fileService;
111
+ this.dialogService = dialogService;
112
+ this.logService = logService;
113
+ }
114
+ async run(context) {
115
+ if (this.inlineChatPreview && this.inlineChatPreview.isOpen()) {
116
+ await this.dialogService.info(( localize(
117
+ 10731,
118
+ "Another code change is being previewed. Please apply or discard the pending changes first."
119
+ )));
120
+ return;
121
+ }
122
+ let activeEditorControl = getEditableActiveCodeEditor(this.editorService);
123
+ if (context.codemapperUri && !isEqual(activeEditorControl?.getModel().uri, context.codemapperUri)) {
124
+ try {
125
+ if (!(await this.fileService.exists(context.codemapperUri))) {
126
+ await this.fileService.writeFile(context.codemapperUri, VSBuffer.fromString(''));
127
+ }
128
+ await this.editorService.openEditor({ resource: context.codemapperUri });
129
+ activeEditorControl = getEditableActiveCodeEditor(this.editorService);
130
+ if (activeEditorControl) {
131
+ this.tryToRevealCodeBlock(activeEditorControl, context.code);
132
+ }
133
+ }
134
+ catch (e) {
135
+ this.logService.info('[ApplyCodeBlockOperation] error opening code mapper file', context.codemapperUri, e);
136
+ }
137
+ }
138
+ let result = undefined;
139
+ if (activeEditorControl) {
140
+ await this.handleTextEditor(activeEditorControl, context);
141
+ }
142
+ else {
143
+ const activeNotebookEditor = getActiveNotebookEditor(this.editorService);
144
+ if (activeNotebookEditor) {
145
+ result = await this.handleNotebookEditor(activeNotebookEditor, context);
146
+ }
147
+ else {
148
+ this.notify(( localize(10732, "To apply this code block, open a code or notebook editor.")));
149
+ }
150
+ }
151
+ notifyUserAction(this.chatService, context, {
152
+ kind: 'apply',
153
+ codeBlockIndex: context.codeBlockIndex,
154
+ totalCharacters: context.code.length,
155
+ codeMapper: result?.codeMapper,
156
+ editsProposed: !!result?.edits,
157
+ });
158
+ }
159
+ async handleNotebookEditor(notebookEditor, codeBlockContext) {
160
+ if (notebookEditor.isReadOnly) {
161
+ this.notify(( localize(10733, "Cannot apply code block to read-only notebook editor.")));
162
+ return undefined;
163
+ }
164
+ const focusRange = notebookEditor.getFocus();
165
+ const next = Math.max(focusRange.end - 1, 0);
166
+ insertCell(this.languageService, notebookEditor, next, CellKind.Code, 'below', codeBlockContext.code, true);
167
+ return undefined;
168
+ }
169
+ async handleTextEditor(codeEditor, codeBlockContext) {
170
+ if (isReadOnly(codeEditor.getModel(), this.textFileService)) {
171
+ this.notify(( localize(10734, "Cannot apply code block to read-only file.")));
172
+ return undefined;
173
+ }
174
+ const result = await this.computeEdits(codeEditor, codeBlockContext);
175
+ if (result.edits) {
176
+ const showWithPreview = await this.applyWithInlinePreview(result.edits, codeEditor);
177
+ if (!showWithPreview) {
178
+ await this.bulkEditService.apply(result.edits, { showPreview: true });
179
+ const activeModel = codeEditor.getModel();
180
+ this.codeEditorService.listCodeEditors().find(editor => editor.getModel()?.uri.toString() === ( (activeModel.uri.toString())))?.focus();
181
+ }
182
+ }
183
+ return result;
184
+ }
185
+ async computeEdits(codeEditor, codeBlockActionContext) {
186
+ const activeModel = codeEditor.getModel();
187
+ const mappedEditsProviders = this.languageFeaturesService.mappedEditsProvider.ordered(activeModel);
188
+ if (mappedEditsProviders.length > 0) {
189
+ const docRefs = [];
190
+ collectDocumentContextFromSelections(codeEditor, docRefs);
191
+ collectDocumentContextFromContext(codeBlockActionContext, docRefs);
192
+ const cancellationTokenSource = ( (new CancellationTokenSource()));
193
+ let codeMapper;
194
+ try {
195
+ const result = await this.progressService.withProgress({ location: 15 , delay: 500, sticky: true, cancellable: true }, async (progress) => {
196
+ for (const provider of mappedEditsProviders) {
197
+ codeMapper = provider.displayName;
198
+ progress.report({ message: ( localize(10735, "Applying code block using {0}...", codeMapper)) });
199
+ const mappedEdits = await provider.provideMappedEdits(activeModel, [codeBlockActionContext.code], {
200
+ documents: docRefs,
201
+ conversation: getChatConversation(codeBlockActionContext),
202
+ }, cancellationTokenSource.token);
203
+ if (mappedEdits) {
204
+ return { edits: mappedEdits.edits, codeMapper };
205
+ }
206
+ }
207
+ return undefined;
208
+ }, () => cancellationTokenSource.cancel());
209
+ if (result) {
210
+ return result;
211
+ }
212
+ }
213
+ catch (e) {
214
+ if (!isCancellationError(e)) {
215
+ this.notify(( localize(10736, "Failed to apply code block: {0}", e.message)));
216
+ }
217
+ }
218
+ finally {
219
+ cancellationTokenSource.dispose();
220
+ }
221
+ return { edits: [], codeMapper };
222
+ }
223
+ return { edits: [], codeMapper: undefined };
224
+ }
225
+ async applyWithInlinePreview(edits, codeEditor) {
226
+ const firstEdit = edits[0];
227
+ if (!ResourceTextEdit.is(firstEdit)) {
228
+ return false;
229
+ }
230
+ const resource = firstEdit.resource;
231
+ const textEdits = coalesce(( (edits.map(
232
+ edit => ResourceTextEdit.is(edit) && isEqual(resource, edit.resource) ? edit.textEdit : undefined
233
+ ))));
234
+ if (textEdits.length !== edits.length) {
235
+ return false;
236
+ }
237
+ const editorToApply = await this.codeEditorService.openCodeEditor({ resource }, codeEditor);
238
+ if (editorToApply) {
239
+ const inlineChatController = InlineChatController.get(editorToApply);
240
+ if (inlineChatController) {
241
+ const tokenSource = ( (new CancellationTokenSource()));
242
+ let isOpen = true;
243
+ const firstEdit = textEdits[0];
244
+ editorToApply.revealLineInCenterIfOutsideViewport(firstEdit.range.startLineNumber);
245
+ const promise = inlineChatController.reviewEdits(textEdits[0].range, AsyncIterableObject.fromArray(textEdits), tokenSource.token);
246
+ promise.finally(() => {
247
+ isOpen = false;
248
+ tokenSource.dispose();
249
+ });
250
+ this.inlineChatPreview = {
251
+ promise,
252
+ isOpen: () => isOpen,
253
+ cancel: () => tokenSource.cancel(),
254
+ };
255
+ return true;
256
+ }
257
+ }
258
+ return false;
259
+ }
260
+ tryToRevealCodeBlock(codeEditor, codeBlock) {
261
+ const match = codeBlock.match(/(\S[^\n]*)\n/);
262
+ if (match && match[1].length > 10) {
263
+ const findMatch = codeEditor.getModel().findNextMatch(match[1], { lineNumber: 1, column: 1 }, false, false, null, false);
264
+ if (findMatch) {
265
+ codeEditor.revealRangeInCenter(findMatch.range);
266
+ }
267
+ }
268
+ }
269
+ notify(message) {
270
+ this.dialogService.info(message);
271
+ }
272
+ };
273
+ ApplyCodeBlockOperation = ( (__decorate([
274
+ ( (__param(0, IEditorService))),
275
+ ( (__param(1, ITextFileService))),
276
+ ( (__param(2, IBulkEditService))),
277
+ ( (__param(3, ICodeEditorService))),
278
+ ( (__param(4, IChatService))),
279
+ ( (__param(5, ILanguageFeaturesService))),
280
+ ( (__param(6, IProgressService))),
281
+ ( (__param(7, ILanguageService))),
282
+ ( (__param(8, IFileService))),
283
+ ( (__param(9, IDialogService))),
284
+ ( (__param(10, ILogService)))
285
+ ], ApplyCodeBlockOperation)));
286
+ function notifyUserAction(chatService, context, action) {
287
+ if (isResponseVM(context.element)) {
288
+ chatService.notifyUserAction({
289
+ agentId: context.element.agent?.id,
290
+ command: context.element.slashCommand?.name,
291
+ sessionId: context.element.sessionId,
292
+ requestId: context.element.requestId,
293
+ result: context.element.result,
294
+ action
295
+ });
296
+ }
297
+ }
298
+ function getActiveNotebookEditor(editorService) {
299
+ const activeEditorPane = editorService.activeEditorPane;
300
+ if (activeEditorPane?.getId() === NOTEBOOK_EDITOR_ID) {
301
+ const notebookEditor = activeEditorPane.getControl();
302
+ if (notebookEditor.hasModel()) {
303
+ return notebookEditor;
304
+ }
305
+ }
306
+ return undefined;
307
+ }
308
+ function getEditableActiveCodeEditor(editorService) {
309
+ const activeCodeEditorInNotebook = getActiveNotebookEditor(editorService)?.activeCodeEditor;
310
+ if (activeCodeEditorInNotebook && activeCodeEditorInNotebook.hasTextFocus() && activeCodeEditorInNotebook.hasModel()) {
311
+ return activeCodeEditorInNotebook;
312
+ }
313
+ let activeEditorControl = editorService.activeTextEditorControl;
314
+ if (isDiffEditor(activeEditorControl)) {
315
+ activeEditorControl = activeEditorControl.getOriginalEditor().hasTextFocus() ? activeEditorControl.getOriginalEditor() : activeEditorControl.getModifiedEditor();
316
+ }
317
+ if (!isCodeEditor(activeEditorControl)) {
318
+ return undefined;
319
+ }
320
+ if (!activeEditorControl.hasModel()) {
321
+ return undefined;
322
+ }
323
+ return activeEditorControl;
324
+ }
325
+ function isReadOnly(model, textFileService) {
326
+ const activeTextModel = textFileService.files.get(model.uri) ?? textFileService.untitled.get(model.uri);
327
+ return !!activeTextModel?.isReadonly();
328
+ }
329
+ function collectDocumentContextFromSelections(codeEditor, result) {
330
+ const activeModel = codeEditor.getModel();
331
+ const currentDocUri = activeModel.uri;
332
+ const currentDocVersion = activeModel.getVersionId();
333
+ const selections = codeEditor.getSelections();
334
+ if (selections.length > 0) {
335
+ result.push([
336
+ {
337
+ uri: currentDocUri,
338
+ version: currentDocVersion,
339
+ ranges: selections,
340
+ }
341
+ ]);
342
+ }
343
+ }
344
+ function collectDocumentContextFromContext(context, result) {
345
+ if (isResponseVM(context.element) && context.element.usedContext?.documents) {
346
+ result.push(context.element.usedContext.documents);
347
+ }
348
+ }
349
+ function getChatConversation(context) {
350
+ if (isResponseVM(context.element)) {
351
+ return [{
352
+ type: 'response',
353
+ message: context.element.response.toMarkdown(),
354
+ references: getReferencesAsDocumentContext(context.element.contentReferences)
355
+ }];
356
+ }
357
+ else if (isRequestVM(context.element)) {
358
+ return [{
359
+ type: 'request',
360
+ message: context.element.messageText,
361
+ }];
362
+ }
363
+ else {
364
+ return [];
365
+ }
366
+ }
367
+ function getReferencesAsDocumentContext(res) {
368
+ const map = ( (new ResourceMap()));
369
+ for (const r of res) {
370
+ let uri;
371
+ let range;
372
+ if (URI.isUri(r.reference)) {
373
+ uri = r.reference;
374
+ }
375
+ else if (isLocation(r.reference)) {
376
+ uri = r.reference.uri;
377
+ range = r.reference.range;
378
+ }
379
+ if (uri) {
380
+ const item = map.get(uri);
381
+ if (item) {
382
+ if (range) {
383
+ item.ranges.push(range);
384
+ }
385
+ }
386
+ else {
387
+ map.set(uri, { uri, version: -1, ranges: range ? [range] : [] });
388
+ }
389
+ }
390
+ }
391
+ return [...( (map.values()))];
392
+ }
393
+ function reindent(codeBlockContent, model, seletionStartLine) {
394
+ const newContent = splitLines(codeBlockContent);
395
+ if (newContent.length === 0) {
396
+ return codeBlockContent;
397
+ }
398
+ const formattingOptions = model.getFormattingOptions();
399
+ const codeIndentLevel = computeIndentation(model.getLineContent(seletionStartLine), formattingOptions.tabSize).level;
400
+ const indents = ( (newContent.map(line => computeIndentation(line, formattingOptions.tabSize))));
401
+ const newContentIndentLevel = indents.reduce((min, indent, index) => {
402
+ if (indent.length !== newContent[index].length) {
403
+ return Math.min(indent.level, min);
404
+ }
405
+ return min;
406
+ }, Number.MAX_VALUE);
407
+ if (newContentIndentLevel === Number.MAX_VALUE || newContentIndentLevel === codeIndentLevel) {
408
+ return codeBlockContent;
409
+ }
410
+ const newLines = [];
411
+ for (let i = 0; i < newContent.length; i++) {
412
+ const { level, length } = indents[i];
413
+ const newLevel = Math.max(0, codeIndentLevel + level - newContentIndentLevel);
414
+ const newIndentation = formattingOptions.insertSpaces ? ' '.repeat(formattingOptions.tabSize * newLevel) : '\t'.repeat(newLevel);
415
+ newLines.push(newIndentation + newContent[i].substring(length));
416
+ }
417
+ return newLines.join('\n');
418
+ }
419
+ function computeIndentation(line, tabSize) {
420
+ let nSpaces = 0;
421
+ let level = 0;
422
+ let i = 0;
423
+ let length = 0;
424
+ const len = line.length;
425
+ while (i < len) {
426
+ const chCode = line.charCodeAt(i);
427
+ if (chCode === 32 ) {
428
+ nSpaces++;
429
+ if (nSpaces === tabSize) {
430
+ level++;
431
+ nSpaces = 0;
432
+ length = i + 1;
433
+ }
434
+ }
435
+ else if (chCode === 9 ) {
436
+ level++;
437
+ nSpaces = 0;
438
+ length = i + 1;
439
+ }
440
+ else {
441
+ break;
442
+ }
443
+ i++;
444
+ }
445
+ return { level, length };
446
+ }
447
+
448
+ export { ApplyCodeBlockOperation, InsertCodeBlockOperation, computeIndentation };
@@ -3,19 +3,35 @@ import { isMarkdownString, MarkdownString } from 'vscode/vscode/vs/base/common/h
3
3
  import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
4
4
  import { Schemas } from 'vscode/vscode/vs/base/common/network';
5
5
  import { isMacintosh } from 'vscode/vscode/vs/base/common/platform';
6
+ import { registerEditorFeature } from 'vscode/vscode/vs/editor/common/editorFeatures';
6
7
  import { localize } from 'vscode/vscode/vs/nls';
7
8
  import { AccessibleViewRegistry } from 'vscode/vscode/vs/platform/accessibility/browser/accessibleViewRegistry';
8
9
  import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands.service';
9
10
  import { Extensions } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
10
11
  import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
11
- import 'vscode/vscode/vs/platform/instantiation/common/extensions';
12
12
  import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
13
13
  import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
14
14
  import { EditorPaneDescriptor } from 'vscode/vscode/vs/workbench/browser/editor';
15
- import { Extensions as Extensions$1, registerWorkbenchContribution2, WorkbenchPhase } from 'vscode/vscode/vs/workbench/common/contributions';
15
+ import { Extensions as Extensions$1, registerWorkbenchContribution2 } from 'vscode/vscode/vs/workbench/common/contributions';
16
16
  import { EditorExtensions } from 'vscode/vscode/vs/workbench/common/editor';
17
+ import { RegisteredEditorPriority } from 'vscode/vscode/vs/workbench/services/editor/common/editorResolverService';
18
+ import { IEditorResolverService } from 'vscode/vscode/vs/workbench/services/editor/common/editorResolverService.service';
19
+ import { ChatAgentLocation } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
20
+ import { IChatAgentService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
21
+ import 'vscode/vscode/vs/workbench/contrib/chat/common/chatColors';
22
+ import { chatVariableLeader } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
23
+ import '../common/chatServiceImpl.js';
24
+ import '../common/chatSlashCommands.js';
25
+ import { IChatSlashCommandService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatSlashCommands.service';
26
+ import { IChatVariablesService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatVariables.service';
27
+ import '../common/chatWidgetHistoryService.js';
28
+ import '../common/languageModels.js';
29
+ import '../common/languageModelStats.js';
30
+ import '../common/languageModelToolsService.js';
31
+ import { LanguageModelToolsExtensionPointHandler } from '../common/tools/languageModelToolsContribution.js';
32
+ import '../common/voiceChatService.js';
17
33
  import { ChatAccessibilityHelp } from './actions/chatAccessibilityHelp.js';
18
- import { registerChatActions } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
34
+ import { ChatCommandCenterRendering, registerChatActions } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
19
35
  import { ACTION_ID_NEW_CHAT, registerNewChatActions } from './actions/chatClearActions.js';
20
36
  import { registerChatCodeBlockActions, registerChatCodeCompareBlockActions } from './actions/chatCodeblockActions.js';
21
37
  import { registerChatContextActions } from './actions/chatContextActions.js';
@@ -28,75 +44,71 @@ import { registerMoveActions } from './actions/chatMoveActions.js';
28
44
  import { registerQuickChatActions } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions';
29
45
  import { registerChatTitleActions } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatTitleActions';
30
46
  import './chatAccessibilityService.js';
47
+ import 'vscode/vscode/vs/workbench/contrib/chat/browser/chatEditingService';
31
48
  import { ChatEditor } from './chatEditor.js';
32
49
  import { ChatEditorInput, ChatEditorInputSerializer } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatEditorInput';
50
+ import { ChatGettingStartedContribution } from './chatGettingStarted.js';
33
51
  import { agentToMarkdown, agentSlashCommandToMarkdown } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatMarkdownDecorationsRenderer';
34
52
  import { ChatExtensionPointHandler, ChatCompatibilityNotifier } from './chatParticipantContributions.js';
53
+ import { ChatPasteProvidersFeature } from './chatPasteProviders.js';
35
54
  import './chatQuick.js';
36
55
  import { ChatResponseAccessibleView } from './chatResponseAccessibleView.js';
37
56
  import './chatVariables.js';
38
57
  import 'vscode/vscode/vs/workbench/contrib/chat/browser/chatWidget';
39
- import './contrib/chatContextAttachments.js';
40
- import './contrib/chatInputCompletions.js';
58
+ import 'vscode/vscode/vs/workbench/contrib/chat/browser/contrib/chatContextAttachments';
59
+ import 'vscode/vscode/vs/workbench/contrib/chat/browser/contrib/chatInputCompletions';
41
60
  import './contrib/chatInputEditorContrib.js';
42
61
  import './contrib/chatInputEditorHover.js';
43
- import { ChatAgentLocation } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
44
- import { IChatAgentService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
45
- import { chatVariableLeader } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
46
- import '../common/chatServiceImpl.js';
47
- import '../common/chatSlashCommands.js';
48
- import { IChatSlashCommandService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatSlashCommands.service';
49
- import { IChatVariablesService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatVariables.service';
50
- import '../common/chatWidgetHistoryService.js';
51
- import 'vscode/vscode/vs/workbench/contrib/chat/common/languageModels';
52
- import '../common/languageModelStats.js';
53
- import '../common/languageModelToolsService.js';
54
- import { LanguageModelToolsExtensionPointHandler } from '../common/tools/languageModelToolsContribution.js';
55
- import '../common/voiceChatService.js';
56
- import { RegisteredEditorPriority } from 'vscode/vscode/vs/workbench/services/editor/common/editorResolverService';
57
- import { IEditorResolverService } from 'vscode/vscode/vs/workbench/services/editor/common/editorResolverService.service';
58
- import { LifecyclePhase } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle';
59
- import 'vscode/vscode/vs/workbench/contrib/chat/common/chatColors';
60
62
 
61
63
  const configurationRegistry = ( (Registry.as(Extensions.Configuration)));
62
64
  configurationRegistry.registerConfiguration({
63
65
  id: 'chatSidebar',
64
- title: ( localize(3062, "Chat")),
66
+ title: ( localize(3139, "Chat")),
65
67
  type: 'object',
66
68
  properties: {
67
69
  'chat.editor.fontSize': {
68
70
  type: 'number',
69
- description: ( localize(3063, "Controls the font size in pixels in chat codeblocks.")),
71
+ description: ( localize(3140, "Controls the font size in pixels in chat codeblocks.")),
70
72
  default: isMacintosh ? 12 : 14,
71
73
  },
72
74
  'chat.editor.fontFamily': {
73
75
  type: 'string',
74
- description: ( localize(3064, "Controls the font family in chat codeblocks.")),
76
+ description: ( localize(3141, "Controls the font family in chat codeblocks.")),
75
77
  default: 'default'
76
78
  },
77
79
  'chat.editor.fontWeight': {
78
80
  type: 'string',
79
- description: ( localize(3065, "Controls the font weight in chat codeblocks.")),
81
+ description: ( localize(3142, "Controls the font weight in chat codeblocks.")),
80
82
  default: 'default'
81
83
  },
82
84
  'chat.editor.wordWrap': {
83
85
  type: 'string',
84
- description: ( localize(3066, "Controls whether lines should wrap in chat codeblocks.")),
86
+ description: ( localize(3143, "Controls whether lines should wrap in chat codeblocks.")),
85
87
  default: 'off',
86
88
  enum: ['on', 'off']
87
89
  },
88
90
  'chat.editor.lineHeight': {
89
91
  type: 'number',
90
92
  description: ( localize(
91
- 3067,
93
+ 3144,
92
94
  "Controls the line height in pixels in chat codeblocks. Use 0 to compute the line height from the font size."
93
95
  )),
94
96
  default: 0
95
97
  },
98
+ 'chat.commandCenter.enabled': {
99
+ type: 'boolean',
100
+ tags: ['experimental'],
101
+ markdownDescription: ( localize(
102
+ 3145,
103
+ "Controls whether the command center shows a menu for chat actions (requires {0}).",
104
+ '`#window.commandCenter#`'
105
+ )),
106
+ default: false
107
+ },
96
108
  'chat.experimental.implicitContext': {
97
109
  type: 'boolean',
98
110
  description: ( localize(
99
- 3068,
111
+ 3146,
100
112
  "Controls whether a checkbox is shown to allow the user to determine which implicit context is included with a chat participant's prompt."
101
113
  )),
102
114
  deprecated: true,
@@ -104,27 +116,27 @@ configurationRegistry.registerConfiguration({
104
116
  },
105
117
  'chat.experimental.variables.editor': {
106
118
  type: 'boolean',
107
- description: ( localize(3069, "Enables variables for editor chat.")),
119
+ description: ( localize(3147, "Enables variables for editor chat.")),
108
120
  default: true
109
121
  },
110
122
  'chat.experimental.variables.notebook': {
111
123
  type: 'boolean',
112
- description: ( localize(3070, "Enables variables for notebook chat.")),
113
- default: false
124
+ description: ( localize(3148, "Enables variables for notebook chat.")),
125
+ default: true
114
126
  },
115
127
  'chat.experimental.variables.terminal': {
116
128
  type: 'boolean',
117
- description: ( localize(3071, "Enables variables for terminal chat.")),
129
+ description: ( localize(3149, "Enables variables for terminal chat.")),
118
130
  default: false
119
131
  },
120
132
  'chat.experimental.detectParticipant.enabled': {
121
133
  type: 'boolean',
122
- description: ( localize(3072, "Enables chat participant autodetection for panel chat.")),
134
+ description: ( localize(3150, "Enables chat participant autodetection for panel chat.")),
123
135
  default: null
124
136
  },
125
137
  }
126
138
  });
127
- ( (Registry.as(EditorExtensions.EditorPane))).registerEditorPane(EditorPaneDescriptor.create(ChatEditor, ChatEditorInput.EditorID, ( localize(3073, "Chat"))), [
139
+ ( (Registry.as(EditorExtensions.EditorPane))).registerEditorPane(EditorPaneDescriptor.create(ChatEditor, ChatEditorInput.EditorID, ( localize(3151, "Chat"))), [
128
140
  ( (new SyncDescriptor(ChatEditorInput)))
129
141
  ]);
130
142
  let ChatResolverContribution = class ChatResolverContribution extends Disposable {
@@ -133,7 +145,7 @@ let ChatResolverContribution = class ChatResolverContribution extends Disposable
133
145
  super();
134
146
  this._register(editorResolverService.registerEditor(`${Schemas.vscodeChatSesssion}:**/**`, {
135
147
  id: ChatEditorInput.EditorID,
136
- label: ( localize(3073, "Chat")),
148
+ label: ( localize(3151, "Chat")),
137
149
  priority: RegisteredEditorPriority.builtin
138
150
  }, {
139
151
  singlePerResource: true,
@@ -156,7 +168,7 @@ let ChatSlashStaticSlashCommandsContribution = class ChatSlashStaticSlashCommand
156
168
  super();
157
169
  this._store.add(slashCommandService.registerSlashCommand({
158
170
  command: 'clear',
159
- detail: ( localize(3074, "Start a new chat")),
171
+ detail: ( localize(3152, "Start a new chat")),
160
172
  sortText: 'z2_clear',
161
173
  executeImmediately: true,
162
174
  locations: [ChatAgentLocation.Panel]
@@ -205,7 +217,7 @@ let ChatSlashStaticSlashCommandsContribution = class ChatSlashStaticSlashCommand
205
217
  }
206
218
  const variables = [
207
219
  ...chatVariablesService.getVariables(ChatAgentLocation.Panel),
208
- { name: 'file', description: ( localize(3075, "Choose a file in the workspace")) }
220
+ { name: 'file', description: ( localize(3153, "Choose a file in the workspace")) }
209
221
  ];
210
222
  const variableText = ( (variables
211
223
  .map(v => `* \`${chatVariableLeader}${v.name}\` - ${v.description}`)))
@@ -232,12 +244,14 @@ ChatSlashStaticSlashCommandsContribution = ( (__decorate([
232
244
  ( (__param(4, IInstantiationService)))
233
245
  ], ChatSlashStaticSlashCommandsContribution)));
234
246
  const workbenchContributionsRegistry = ( (Registry.as(Extensions$1.Workbench)));
235
- registerWorkbenchContribution2(ChatResolverContribution.ID, ChatResolverContribution, WorkbenchPhase.BlockStartup);
236
- workbenchContributionsRegistry.registerWorkbenchContribution(ChatSlashStaticSlashCommandsContribution, LifecyclePhase.Eventually);
247
+ registerWorkbenchContribution2(ChatResolverContribution.ID, ChatResolverContribution, 1 );
248
+ workbenchContributionsRegistry.registerWorkbenchContribution(ChatSlashStaticSlashCommandsContribution, 4 );
237
249
  ( (Registry.as(EditorExtensions.EditorFactory))).registerEditorSerializer(ChatEditorInput.TypeID, ChatEditorInputSerializer);
238
- registerWorkbenchContribution2(ChatExtensionPointHandler.ID, ChatExtensionPointHandler, WorkbenchPhase.BlockStartup);
239
- registerWorkbenchContribution2(LanguageModelToolsExtensionPointHandler.ID, LanguageModelToolsExtensionPointHandler, WorkbenchPhase.BlockRestore);
240
- registerWorkbenchContribution2(ChatCompatibilityNotifier.ID, ChatCompatibilityNotifier, WorkbenchPhase.Eventually);
250
+ registerWorkbenchContribution2(ChatExtensionPointHandler.ID, ChatExtensionPointHandler, 1 );
251
+ registerWorkbenchContribution2(LanguageModelToolsExtensionPointHandler.ID, LanguageModelToolsExtensionPointHandler, 2 );
252
+ registerWorkbenchContribution2(ChatCompatibilityNotifier.ID, ChatCompatibilityNotifier, 4 );
253
+ registerWorkbenchContribution2(ChatGettingStartedContribution.ID, ChatGettingStartedContribution, 4 );
254
+ registerWorkbenchContribution2(ChatCommandCenterRendering.ID, ChatCommandCenterRendering, 3 );
241
255
  registerChatActions();
242
256
  registerChatCopyActions();
243
257
  registerChatCodeBlockActions();
@@ -251,3 +265,4 @@ registerMoveActions();
251
265
  registerNewChatActions();
252
266
  registerChatContextActions();
253
267
  registerChatDeveloperActions();
268
+ registerEditorFeature(ChatPasteProvidersFeature);