@codingame/monaco-vscode-chat-service-override 10.1.3 → 11.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 (50) hide show
  1. package/chat.js +6 -3
  2. package/package.json +6 -2
  3. package/vscode/src/vs/editor/common/diff/documentDiffProvider.js +8 -0
  4. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +84 -38
  5. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +265 -20
  6. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +20 -39
  7. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +373 -216
  8. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +4 -5
  9. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +1 -1
  10. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +4 -5
  11. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.js +54 -0
  12. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +6 -7
  13. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +12 -11
  14. package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +14 -42
  15. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +82 -50
  16. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.js +326 -0
  17. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingService.js +448 -0
  18. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.js +507 -0
  19. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelContentProviders.js +76 -0
  20. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +4 -4
  21. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditorActions.js +109 -0
  22. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditorController.js +284 -0
  23. package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipantContributions.js +116 -77
  24. package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +100 -9
  25. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +3 -3
  26. package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.js +1 -1
  27. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +7 -9
  28. package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +61 -42
  29. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +5 -5
  30. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +3 -3
  31. package/vscode/src/vs/workbench/contrib/chat/{common → browser}/languageModelToolsService.js +28 -31
  32. package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcomeContributions.js +75 -0
  33. package/vscode/src/vs/workbench/contrib/chat/common/chatCodeMapperService.js +120 -1
  34. package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.js +10 -8
  35. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +33 -18
  36. package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +1 -1
  37. package/vscode/src/vs/workbench/contrib/chat/common/ignoredFiles.js +21 -0
  38. package/vscode/src/vs/workbench/contrib/chat/common/languageModelStats.js +2 -2
  39. package/vscode/src/vs/workbench/contrib/chat/common/languageModels.js +6 -6
  40. package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +68 -47
  41. package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsParametersSchema.js +250 -0
  42. package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +2 -2
  43. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +7 -8
  44. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibilityHelp.js +1 -1
  45. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +1 -1
  46. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.js +3 -3
  47. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js +2 -2
  48. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +65 -128
  49. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +0 -170
  50. package/vscode/src/vs/workbench/contrib/chat/browser/chatGettingStarted.js +0 -131
@@ -1,8 +1,10 @@
1
1
  import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
+ import { timeout } from 'vscode/vscode/vs/base/common/async';
2
3
  import { isMarkdownString, MarkdownString } from 'vscode/vscode/vs/base/common/htmlContent';
3
4
  import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
4
5
  import { Schemas } from 'vscode/vscode/vs/base/common/network';
5
6
  import { isMacintosh } from 'vscode/vscode/vs/base/common/platform';
7
+ import { registerEditorContribution } from 'vscode/vscode/vs/editor/browser/editorExtensions';
6
8
  import { registerEditorFeature } from 'vscode/vscode/vs/editor/common/editorFeatures';
7
9
  import { localize } from 'vscode/vscode/vs/nls';
8
10
  import { AccessibleViewRegistry } from 'vscode/vscode/vs/platform/accessibility/browser/accessibleViewRegistry';
@@ -12,14 +14,18 @@ import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/d
12
14
  import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
13
15
  import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
14
16
  import { EditorPaneDescriptor } from 'vscode/vscode/vs/workbench/browser/editor';
15
- import { Extensions as Extensions$1, registerWorkbenchContribution2 } from 'vscode/vscode/vs/workbench/common/contributions';
17
+ import { registerWorkbenchContribution2 } from 'vscode/vscode/vs/workbench/common/contributions';
16
18
  import { EditorExtensions } from 'vscode/vscode/vs/workbench/common/editor';
17
19
  import { RegisteredEditorPriority } from 'vscode/vscode/vs/workbench/services/editor/common/editorResolverService';
18
20
  import { IEditorResolverService } from 'vscode/vscode/vs/workbench/services/editor/common/editorResolverService.service';
19
21
  import { ChatAgentLocation } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
20
22
  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 'vscode/vscode/vs/base/common/map';
24
+ import 'vscode/vscode/vs/base/common/strings';
25
+ import 'vscode/vscode/vs/base/common/path';
26
+ import 'vscode/vscode/vs/editor/common/languages';
27
+ import '@codingame/monaco-vscode-chat-extensions-interactive-notebook-quickaccess-search-terminal-common/vscode/vs/workbench/contrib/chat/common/chatColors';
28
+ import { chatVariableLeader } from '@codingame/monaco-vscode-chat-extensions-interactive-notebook-quickaccess-search-terminal-common/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
23
29
  import '../common/chatServiceImpl.js';
24
30
  import '../common/chatSlashCommands.js';
25
31
  import { IChatSlashCommandService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatSlashCommands.service';
@@ -27,116 +33,135 @@ import { IChatVariablesService } from 'vscode/vscode/vs/workbench/contrib/chat/c
27
33
  import '../common/chatWidgetHistoryService.js';
28
34
  import '../common/languageModels.js';
29
35
  import '../common/languageModelStats.js';
30
- import '../common/languageModelToolsService.js';
31
36
  import { LanguageModelToolsExtensionPointHandler } from '../common/tools/languageModelToolsContribution.js';
32
37
  import '../common/voiceChatService.js';
33
- import { ChatAccessibilityHelp } from './actions/chatAccessibilityHelp.js';
34
- import { ChatCommandCenterRendering, registerChatActions } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
38
+ import { PanelChatAccessibilityHelp, QuickChatAccessibilityHelp } from './actions/chatAccessibilityHelp.js';
39
+ import { ChatCommandCenterRendering, registerChatActions } from '@codingame/monaco-vscode-chat-extensions-interactive-notebook-quickaccess-search-terminal-common/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
35
40
  import { ACTION_ID_NEW_CHAT, registerNewChatActions } from './actions/chatClearActions.js';
36
41
  import { registerChatCodeBlockActions, registerChatCodeCompareBlockActions } from './actions/chatCodeblockActions.js';
37
42
  import { registerChatContextActions } from './actions/chatContextActions.js';
38
43
  import { registerChatCopyActions } from './actions/chatCopyActions.js';
39
44
  import { registerChatDeveloperActions } from './actions/chatDeveloperActions.js';
40
- import { SubmitAction, registerChatExecuteActions } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatExecuteActions';
45
+ import { SubmitAction, registerChatExecuteActions } from '@codingame/monaco-vscode-chat-extensions-notebook-common/vscode/vs/workbench/contrib/chat/browser/actions/chatExecuteActions';
41
46
  import { registerChatFileTreeActions } from './actions/chatFileTreeActions.js';
42
47
  import { registerChatExportActions } from './actions/chatImportExport.js';
43
48
  import { registerMoveActions } from './actions/chatMoveActions.js';
44
- import { registerQuickChatActions } from './actions/chatQuickInputActions.js';
45
- import { registerChatTitleActions } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatTitleActions';
49
+ import { registerQuickChatActions } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions';
50
+ import { registerChatTitleActions } from '@codingame/monaco-vscode-chat-extensions-interactive-notebook-quickaccess-search-terminal-common/vscode/vs/workbench/contrib/chat/browser/actions/chatTitleActions';
46
51
  import './chatAccessibilityService.js';
47
- import 'vscode/vscode/vs/workbench/contrib/chat/browser/chatEditingService';
52
+ import 'vscode/vscode/vs/base/common/event';
53
+ import 'vscode/vscode/vs/base/common/resources';
54
+ import 'vscode/vscode/vs/base/browser/dom';
55
+ import './chatEditing/chatEditingService.js';
48
56
  import { ChatEditor } from './chatEditor.js';
49
- import { ChatEditorInput, ChatEditorInputSerializer } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatEditorInput';
50
- import { ChatGettingStartedContribution } from './chatGettingStarted.js';
51
- import { agentToMarkdown, agentSlashCommandToMarkdown } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatMarkdownDecorationsRenderer';
57
+ import { registerChatEditorActions } from './chatEditorActions.js';
58
+ import { ChatEditorController } from './chatEditorController.js';
59
+ import { ChatEditorInput, ChatEditorInputSerializer } from '@codingame/monaco-vscode-chat-extensions-interactive-notebook-quickaccess-search-terminal-common/vscode/vs/workbench/contrib/chat/browser/chatEditorInput';
60
+ import { ChatEditorSaving } from '@codingame/monaco-vscode-chat-extensions-notebook-common/vscode/vs/workbench/contrib/chat/browser/chatEditorSaving';
61
+ import { agentToMarkdown, agentSlashCommandToMarkdown } from '@codingame/monaco-vscode-chat-extensions-interactive-notebook-quickaccess-search-terminal-common/vscode/vs/workbench/contrib/chat/browser/chatMarkdownDecorationsRenderer';
52
62
  import { ChatExtensionPointHandler, ChatCompatibilityNotifier } from './chatParticipantContributions.js';
53
63
  import { ChatPasteProvidersFeature } from './chatPasteProviders.js';
54
64
  import './chatQuick.js';
55
65
  import { ChatResponseAccessibleView } from './chatResponseAccessibleView.js';
56
66
  import './chatVariables.js';
57
- import 'vscode/vscode/vs/workbench/contrib/chat/browser/chatWidget';
58
- import 'vscode/vscode/vs/workbench/contrib/chat/browser/contrib/chatContextAttachments';
59
- import 'vscode/vscode/vs/workbench/contrib/chat/browser/contrib/chatInputCompletions';
67
+ import '@codingame/monaco-vscode-chat-extensions-notebook-common/vscode/vs/workbench/contrib/chat/browser/chatWidget';
68
+ import '@codingame/monaco-vscode-chat-notebook-common/vscode/vs/workbench/contrib/chat/browser/contrib/chatInputCompletions';
60
69
  import './contrib/chatInputEditorContrib.js';
61
70
  import './contrib/chatInputEditorHover.js';
71
+ import { ChatImplicitContextContribution } from '@codingame/monaco-vscode-chat-extensions-notebook-common/vscode/vs/workbench/contrib/chat/browser/contrib/chatImplicitContext';
72
+ import './languageModelToolsService.js';
73
+ import { ChatViewsWelcomeHandler } from './viewsWelcome/chatViewsWelcomeContributions.js';
74
+ import { ChatGettingStartedContribution } from './actions/chatGettingStarted.js';
62
75
 
63
76
  const configurationRegistry = ( (Registry.as(Extensions.Configuration)));
64
77
  configurationRegistry.registerConfiguration({
65
78
  id: 'chatSidebar',
66
- title: ( localize(3166, "Chat")),
79
+ title: ( localize(2714, "Chat")),
67
80
  type: 'object',
68
81
  properties: {
69
82
  'chat.editor.fontSize': {
70
83
  type: 'number',
71
- description: ( localize(3167, "Controls the font size in pixels in chat codeblocks.")),
84
+ description: ( localize(2715, "Controls the font size in pixels in chat codeblocks.")),
72
85
  default: isMacintosh ? 12 : 14,
73
86
  },
74
87
  'chat.editor.fontFamily': {
75
88
  type: 'string',
76
- description: ( localize(3168, "Controls the font family in chat codeblocks.")),
89
+ description: ( localize(2716, "Controls the font family in chat codeblocks.")),
77
90
  default: 'default'
78
91
  },
79
92
  'chat.editor.fontWeight': {
80
93
  type: 'string',
81
- description: ( localize(3169, "Controls the font weight in chat codeblocks.")),
94
+ description: ( localize(2717, "Controls the font weight in chat codeblocks.")),
82
95
  default: 'default'
83
96
  },
84
97
  'chat.editor.wordWrap': {
85
98
  type: 'string',
86
- description: ( localize(3170, "Controls whether lines should wrap in chat codeblocks.")),
99
+ description: ( localize(2718, "Controls whether lines should wrap in chat codeblocks.")),
87
100
  default: 'off',
88
101
  enum: ['on', 'off']
89
102
  },
90
103
  'chat.editor.lineHeight': {
91
104
  type: 'number',
92
105
  description: ( localize(
93
- 3171,
106
+ 2719,
94
107
  "Controls the line height in pixels in chat codeblocks. Use 0 to compute the line height from the font size."
95
108
  )),
96
109
  default: 0
97
110
  },
98
111
  'chat.commandCenter.enabled': {
99
112
  type: 'boolean',
100
- tags: ['experimental'],
113
+ tags: ['preview'],
101
114
  markdownDescription: ( localize(
102
- 3172,
115
+ 2720,
103
116
  "Controls whether the command center shows a menu for chat actions (requires {0}).",
104
117
  '`#window.commandCenter#`'
105
118
  )),
106
- default: false
119
+ default: true
107
120
  },
108
- 'chat.experimental.implicitContext': {
121
+ 'chat.editing.alwaysSaveWithGeneratedChanges': {
109
122
  type: 'boolean',
110
- description: ( localize(
111
- 3173,
112
- "Controls whether a checkbox is shown to allow the user to determine which implicit context is included with a chat participant's prompt."
123
+ scope: 1 ,
124
+ markdownDescription: ( localize(
125
+ 2721,
126
+ "Whether to always ask before saving files with changes made by chat."
113
127
  )),
114
- deprecated: true,
115
- default: false
128
+ default: false,
116
129
  },
117
- 'chat.experimental.variables.editor': {
130
+ 'chat.editing.confirmEditRequestRemoval': {
118
131
  type: 'boolean',
119
- description: ( localize(3174, "Enables variables for editor chat.")),
120
- default: true
132
+ scope: 1 ,
133
+ markdownDescription: ( localize(
134
+ 2722,
135
+ "Whether to show a confirmation before removing a request and its associated edits."
136
+ )),
137
+ default: true,
121
138
  },
122
- 'chat.experimental.variables.notebook': {
139
+ 'chat.editing.confirmEditRequestRetry': {
123
140
  type: 'boolean',
124
- description: ( localize(3175, "Enables variables for notebook chat.")),
125
- default: true
141
+ scope: 1 ,
142
+ markdownDescription: ( localize(
143
+ 2723,
144
+ "Whether to show a confirmation before retrying a request and its associated edits."
145
+ )),
146
+ default: true,
126
147
  },
127
- 'chat.experimental.variables.terminal': {
148
+ 'chat.editing.experimental.enableRestoreFile': {
128
149
  type: 'boolean',
129
- description: ( localize(3176, "Enables variables for terminal chat.")),
130
- default: false
150
+ scope: 1 ,
151
+ markdownDescription: ( localize(
152
+ 2724,
153
+ "Whether to show a toggle to restore an earlier version of a file that was edited in a chat editing session request."
154
+ )),
155
+ default: false,
131
156
  },
132
157
  'chat.experimental.detectParticipant.enabled': {
133
158
  type: 'boolean',
134
- description: ( localize(3177, "Enables chat participant autodetection for panel chat.")),
159
+ description: ( localize(2725, "Enables chat participant autodetection for panel chat.")),
135
160
  default: null
136
161
  },
137
162
  }
138
163
  });
139
- ( (Registry.as(EditorExtensions.EditorPane))).registerEditorPane(EditorPaneDescriptor.create(ChatEditor, ChatEditorInput.EditorID, ( localize(3178, "Chat"))), [
164
+ ( (Registry.as(EditorExtensions.EditorPane))).registerEditorPane(EditorPaneDescriptor.create(ChatEditor, ChatEditorInput.EditorID, ( localize(2726, "Chat"))), [
140
165
  ( (new SyncDescriptor(ChatEditorInput)))
141
166
  ]);
142
167
  let ChatResolverContribution = class ChatResolverContribution extends Disposable {
@@ -145,7 +170,7 @@ let ChatResolverContribution = class ChatResolverContribution extends Disposable
145
170
  super();
146
171
  this._register(editorResolverService.registerEditor(`${Schemas.vscodeChatSesssion}:**/**`, {
147
172
  id: ChatEditorInput.EditorID,
148
- label: ( localize(3178, "Chat")),
173
+ label: ( localize(2726, "Chat")),
149
174
  priority: RegisteredEditorPriority.builtin
150
175
  }, {
151
176
  singlePerResource: true,
@@ -162,13 +187,15 @@ ChatResolverContribution = ( (__decorate([
162
187
  ( (__param(1, IInstantiationService)))
163
188
  ], ChatResolverContribution)));
164
189
  AccessibleViewRegistry.register(( (new ChatResponseAccessibleView())));
165
- AccessibleViewRegistry.register(( (new ChatAccessibilityHelp())));
190
+ AccessibleViewRegistry.register(( (new PanelChatAccessibilityHelp())));
191
+ AccessibleViewRegistry.register(( (new QuickChatAccessibilityHelp())));
166
192
  let ChatSlashStaticSlashCommandsContribution = class ChatSlashStaticSlashCommandsContribution extends Disposable {
193
+ static { this.ID = 'workbench.contrib.chatSlashStaticSlashCommands'; }
167
194
  constructor(slashCommandService, commandService, chatAgentService, chatVariablesService, instantiationService) {
168
195
  super();
169
196
  this._store.add(slashCommandService.registerSlashCommand({
170
197
  command: 'clear',
171
- detail: ( localize(3179, "Start a new chat")),
198
+ detail: ( localize(2727, "Start a new chat")),
172
199
  sortText: 'z2_clear',
173
200
  executeImmediately: true,
174
201
  locations: [ChatAgentLocation.Panel]
@@ -217,7 +244,7 @@ let ChatSlashStaticSlashCommandsContribution = class ChatSlashStaticSlashCommand
217
244
  }
218
245
  const variables = [
219
246
  ...chatVariablesService.getVariables(ChatAgentLocation.Panel),
220
- { name: 'file', description: ( localize(3180, "Choose a file in the workspace")) }
247
+ { name: 'file', description: ( localize(2728, "Choose a file in the workspace")) }
221
248
  ];
222
249
  const variableText = ( (variables
223
250
  .map(v => `* \`${chatVariableLeader}${v.name}\` - ${v.description}`)))
@@ -233,6 +260,7 @@ let ChatSlashStaticSlashCommandsContribution = class ChatSlashStaticSlashCommand
233
260
  progress.report({ content: ( (new MarkdownString(defaultAgent.metadata.helpTextPostfix))), kind: 'markdownContent' });
234
261
  }
235
262
  }
263
+ await timeout(200);
236
264
  }));
237
265
  }
238
266
  };
@@ -243,15 +271,17 @@ ChatSlashStaticSlashCommandsContribution = ( (__decorate([
243
271
  ( (__param(3, IChatVariablesService))),
244
272
  ( (__param(4, IInstantiationService)))
245
273
  ], ChatSlashStaticSlashCommandsContribution)));
246
- const workbenchContributionsRegistry = ( (Registry.as(Extensions$1.Workbench)));
247
- registerWorkbenchContribution2(ChatResolverContribution.ID, ChatResolverContribution, 1 );
248
- workbenchContributionsRegistry.registerWorkbenchContribution(ChatSlashStaticSlashCommandsContribution, 4 );
249
274
  ( (Registry.as(EditorExtensions.EditorFactory))).registerEditorSerializer(ChatEditorInput.TypeID, ChatEditorInputSerializer);
275
+ registerWorkbenchContribution2(ChatResolverContribution.ID, ChatResolverContribution, 1 );
276
+ registerWorkbenchContribution2(ChatSlashStaticSlashCommandsContribution.ID, ChatSlashStaticSlashCommandsContribution, 4 );
250
277
  registerWorkbenchContribution2(ChatExtensionPointHandler.ID, ChatExtensionPointHandler, 1 );
251
278
  registerWorkbenchContribution2(LanguageModelToolsExtensionPointHandler.ID, LanguageModelToolsExtensionPointHandler, 2 );
252
279
  registerWorkbenchContribution2(ChatCompatibilityNotifier.ID, ChatCompatibilityNotifier, 4 );
253
- registerWorkbenchContribution2(ChatGettingStartedContribution.ID, ChatGettingStartedContribution, 4 );
254
280
  registerWorkbenchContribution2(ChatCommandCenterRendering.ID, ChatCommandCenterRendering, 3 );
281
+ registerWorkbenchContribution2(ChatImplicitContextContribution.ID, ChatImplicitContextContribution, 4 );
282
+ registerWorkbenchContribution2(ChatEditorSaving.ID, ChatEditorSaving, 3 );
283
+ registerWorkbenchContribution2(ChatViewsWelcomeHandler.ID, ChatViewsWelcomeHandler, 1 );
284
+ registerWorkbenchContribution2(ChatGettingStartedContribution.ID, ChatGettingStartedContribution, 4 );
255
285
  registerChatActions();
256
286
  registerChatCopyActions();
257
287
  registerChatCodeBlockActions();
@@ -265,4 +295,6 @@ registerMoveActions();
265
295
  registerNewChatActions();
266
296
  registerChatContextActions();
267
297
  registerChatDeveloperActions();
298
+ registerChatEditorActions();
268
299
  registerEditorFeature(ChatPasteProvidersFeature);
300
+ registerEditorContribution(ChatEditorController.ID, ChatEditorController, 3 );
@@ -0,0 +1,326 @@
1
+ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
+ import { RunOnceScheduler, timeout } from 'vscode/vscode/vs/base/common/async';
3
+ import { Emitter } from 'vscode/vscode/vs/base/common/event';
4
+ import { Disposable, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
5
+ import { observableValue, transaction } from 'vscode/vscode/vs/base/common/observableInternal/base';
6
+ import 'vscode/vscode/vs/base/common/arrays';
7
+ import 'vscode/vscode/vs/base/common/observableInternal/autorun';
8
+ import 'vscode/vscode/vs/base/common/observableInternal/derived';
9
+ import 'vscode/vscode/vs/base/common/cancellation';
10
+ import 'vscode/vscode/vs/base/common/observableInternal/utils';
11
+ import { themeColorFromId } from 'vscode/vscode/vs/base/common/themables';
12
+ import { IBulkEditService } from 'vscode/vscode/vs/editor/browser/services/bulkEditService';
13
+ import { EditOperation } from 'vscode/vscode/vs/editor/common/core/editOperation';
14
+ import { OffsetEdit, SingleOffsetEdit } from 'vscode/vscode/vs/editor/common/core/offsetEdit';
15
+ import { OffsetRange } from 'vscode/vscode/vs/editor/common/core/offsetRange';
16
+ import { Range } from 'vscode/vscode/vs/editor/common/core/range';
17
+ import { nullDocumentDiff } from '../../../../../editor/common/diff/documentDiffProvider.js';
18
+ import { TextEdit } from 'vscode/vscode/vs/editor/common/languages';
19
+ import { ILanguageService } from 'vscode/vscode/vs/editor/common/languages/language';
20
+ import { OverviewRulerLane } from 'vscode/vscode/vs/editor/common/model';
21
+ import { SingleModelEditStackElement } from 'vscode/vscode/vs/editor/common/model/editStack';
22
+ import { ModelDecorationOptions, createTextBufferFactoryFromSnapshot } from 'vscode/vscode/vs/editor/common/model/textModel';
23
+ import { IEditorWorkerService } from 'vscode/vscode/vs/editor/common/services/editorWorker';
24
+ import { IModelService } from 'vscode/vscode/vs/editor/common/services/model';
25
+ import { ITextModelService } from 'vscode/vscode/vs/editor/common/services/resolverService';
26
+ import { localize } from 'vscode/vscode/vs/nls';
27
+ import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
28
+ import 'vscode/vscode/vs/platform/theme/common/colorUtils';
29
+ import 'vscode/vscode/vs/platform/theme/common/colors/baseColors';
30
+ import 'vscode/vscode/vs/platform/theme/common/colors/chartsColors';
31
+ import { editorSelectionBackground } from 'vscode/vscode/vs/platform/theme/common/colors/editorColors';
32
+ import 'vscode/vscode/vs/platform/theme/common/colors/inputColors';
33
+ import 'vscode/vscode/vs/platform/theme/common/colors/listColors';
34
+ import 'vscode/vscode/vs/platform/theme/common/colors/menuColors';
35
+ import 'vscode/vscode/vs/platform/theme/common/colors/minimapColors';
36
+ import 'vscode/vscode/vs/platform/theme/common/colors/miscColors';
37
+ import 'vscode/vscode/vs/platform/theme/common/colors/quickpickColors';
38
+ import 'vscode/vscode/vs/platform/theme/common/colors/searchColors';
39
+ import { IUndoRedoService } from 'vscode/vscode/vs/platform/undoRedo/common/undoRedo.service';
40
+ import { IChatService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService.service';
41
+ import { ChatEditingTextModelContentProvider, ChatEditingSnapshotTextModelContentProvider } from './chatEditingTextModelContentProviders.js';
42
+
43
+ var ChatEditingModifiedFileEntry_1;
44
+ let ChatEditingModifiedFileEntry = class ChatEditingModifiedFileEntry extends Disposable {
45
+ static { ChatEditingModifiedFileEntry_1 = this; }
46
+ static { this.scheme = 'modified-file-entry'; }
47
+ static { this.lastEntryId = 0; }
48
+ get onDidDelete() {
49
+ return this._onDidDelete.event;
50
+ }
51
+ get originalURI() {
52
+ return this.docSnapshot.uri;
53
+ }
54
+ get originalModel() {
55
+ return this.docSnapshot;
56
+ }
57
+ get modifiedURI() {
58
+ return this.doc.uri;
59
+ }
60
+ get modifiedModel() {
61
+ return this.doc;
62
+ }
63
+ get state() {
64
+ return this._stateObs;
65
+ }
66
+ get isCurrentlyBeingModified() {
67
+ return this._isCurrentlyBeingModifiedObs;
68
+ }
69
+ get diffInfo() {
70
+ return this._diffInfo;
71
+ }
72
+ static { this._editDecorationOptions = ModelDecorationOptions.register({
73
+ isWholeLine: true,
74
+ description: 'chat-editing',
75
+ className: 'rangeHighlight',
76
+ marginClassName: 'rangeHighlight',
77
+ overviewRuler: {
78
+ position: OverviewRulerLane.Full,
79
+ color: themeColorFromId(editorSelectionBackground)
80
+ },
81
+ }); }
82
+ get telemetryInfo() {
83
+ return this._telemetryInfo;
84
+ }
85
+ get lastModifyingRequestId() {
86
+ return this._telemetryInfo.requestId;
87
+ }
88
+ constructor(resource, resourceRef, _multiDiffEntryDelegate, _telemetryInfo, kind, modelService, textModelService, languageService, bulkEditService, _chatService, _editorWorkerService, _undoRedoService, _fileService) {
89
+ super();
90
+ this.resource = resource;
91
+ this._multiDiffEntryDelegate = _multiDiffEntryDelegate;
92
+ this._telemetryInfo = _telemetryInfo;
93
+ this.bulkEditService = bulkEditService;
94
+ this._chatService = _chatService;
95
+ this._editorWorkerService = _editorWorkerService;
96
+ this._undoRedoService = _undoRedoService;
97
+ this._fileService = _fileService;
98
+ this.entryId = `${ChatEditingModifiedFileEntry_1.scheme}::${++ChatEditingModifiedFileEntry_1.lastEntryId}`;
99
+ this._onDidDelete = this._register(( (new Emitter())));
100
+ this._stateObs = observableValue(this, 0 );
101
+ this._isCurrentlyBeingModifiedObs = observableValue(this, false);
102
+ this._isFirstEditAfterStartOrSnapshot = true;
103
+ this._edit = OffsetEdit.empty;
104
+ this._isEditFromUs = false;
105
+ this._diffOperationIds = 0;
106
+ this._diffInfo = observableValue(this, nullDocumentDiff);
107
+ this._editDecorationClear = this._register(( (new RunOnceScheduler(
108
+ () => { this._editDecorations = this.doc.deltaDecorations(this._editDecorations, []); },
109
+ 3000
110
+ ))));
111
+ this._editDecorations = [];
112
+ if (kind === 0 ) {
113
+ this.createdInRequestId = this._telemetryInfo.requestId;
114
+ }
115
+ this.doc = resourceRef.object.textEditorModel;
116
+ const docSnapshot = this.docSnapshot = this._register(modelService.createModel(createTextBufferFactoryFromSnapshot(this.doc.createSnapshot()), languageService.createById(this.doc.getLanguageId()), ChatEditingTextModelContentProvider.getFileURI(this.entryId, resource.path), false));
117
+ (async () => {
118
+ const reference = await textModelService.createModelReference(docSnapshot.uri);
119
+ if (this._store.isDisposed) {
120
+ reference.dispose();
121
+ return;
122
+ }
123
+ this._register(reference);
124
+ })();
125
+ this._register(resourceRef);
126
+ this._register(this.doc.onDidChangeContent(e => this._mirrorEdits(e)));
127
+ this._register(toDisposable(() => {
128
+ this._clearCurrentEditLineDecoration();
129
+ }));
130
+ }
131
+ _clearCurrentEditLineDecoration() {
132
+ this._editDecorations = this.doc.deltaDecorations(this._editDecorations, []);
133
+ }
134
+ updateTelemetryInfo(telemetryInfo) {
135
+ this._telemetryInfo = telemetryInfo;
136
+ }
137
+ createSnapshot(requestId) {
138
+ this._isFirstEditAfterStartOrSnapshot = true;
139
+ return {
140
+ resource: this.modifiedURI,
141
+ languageId: this.modifiedModel.getLanguageId(),
142
+ snapshotUri: ChatEditingSnapshotTextModelContentProvider.getSnapshotFileURI(requestId, this.modifiedURI.path),
143
+ original: this.originalModel.getValue(),
144
+ current: this.modifiedModel.getValue(),
145
+ originalToCurrentEdit: this._edit,
146
+ state: this.state.get(),
147
+ telemetryInfo: this._telemetryInfo
148
+ };
149
+ }
150
+ restoreFromSnapshot(snapshot) {
151
+ this._stateObs.set(snapshot.state, undefined);
152
+ this.docSnapshot.setValue(snapshot.original);
153
+ this._setDocValue(snapshot.current);
154
+ this._edit = snapshot.originalToCurrentEdit;
155
+ }
156
+ resetToInitialValue(value) {
157
+ this._setDocValue(value);
158
+ }
159
+ acceptStreamingEditsStart(tx) {
160
+ this._isCurrentlyBeingModifiedObs.set(false, tx);
161
+ this._clearCurrentEditLineDecoration();
162
+ }
163
+ acceptStreamingEditsEnd(tx) {
164
+ this._isCurrentlyBeingModifiedObs.set(false, tx);
165
+ this._clearCurrentEditLineDecoration();
166
+ }
167
+ _mirrorEdits(event) {
168
+ const edit = fromContentChange(event.changes);
169
+ if (this._isEditFromUs) {
170
+ const e_sum = this._edit;
171
+ const e_ai = edit;
172
+ this._edit = e_sum.compose(e_ai);
173
+ }
174
+ else {
175
+ const e_ai = this._edit;
176
+ const e_user = edit;
177
+ const e_user_r = e_user.tryRebase(e_ai.inverse(this.docSnapshot.getValue()), true);
178
+ if (e_user_r === undefined) {
179
+ this._edit = e_ai.compose(e_user);
180
+ }
181
+ else {
182
+ const edits = toEditOperations(e_user_r, this.docSnapshot);
183
+ this.docSnapshot.applyEdits(edits);
184
+ this._edit = e_ai.tryRebase(e_user_r);
185
+ }
186
+ }
187
+ this._updateDiffInfoSeq(!this._isEditFromUs);
188
+ }
189
+ acceptAgentEdits(textEdits) {
190
+ this._editDecorations = this.doc.deltaDecorations(this._editDecorations, ( (textEdits.map(edit => {
191
+ return {
192
+ options: ChatEditingModifiedFileEntry_1._editDecorationOptions,
193
+ range: edit.range
194
+ };
195
+ }))));
196
+ this._editDecorationClear.schedule();
197
+ if (this._isFirstEditAfterStartOrSnapshot) {
198
+ this._isFirstEditAfterStartOrSnapshot = false;
199
+ const request = this._chatService.getSession(this._telemetryInfo.sessionId)?.getRequests().at(-1);
200
+ const label = request?.message.text ? ( localize(10873, "Chat Edit: '{0}'", request.message.text)) : ( localize(10874, "Chat Edit"));
201
+ this._undoRedoService.pushElement(( (new SingleModelEditStackElement(label, 'chat.edit', this.doc, null))));
202
+ }
203
+ this._applyEdits(( (textEdits.map(TextEdit.asEditOperation))));
204
+ transaction((tx) => {
205
+ this._stateObs.set(0 , tx);
206
+ this._isCurrentlyBeingModifiedObs.set(true, tx);
207
+ });
208
+ }
209
+ _applyEdits(edits) {
210
+ this._isEditFromUs = true;
211
+ try {
212
+ this.doc.pushEditOperations(null, edits, () => null);
213
+ }
214
+ finally {
215
+ this._isEditFromUs = false;
216
+ }
217
+ }
218
+ _updateDiffInfoSeq(fast) {
219
+ const myDiffOperationId = ++this._diffOperationIds;
220
+ Promise.resolve(this._diffOperation).then(() => {
221
+ if (this._diffOperationIds === myDiffOperationId) {
222
+ this._diffOperation = this._updateDiffInfo(fast);
223
+ }
224
+ });
225
+ }
226
+ async _updateDiffInfo(fast) {
227
+ const docVersionNow = this.doc.getVersionId();
228
+ const snapshotVersionNow = this.docSnapshot.getVersionId();
229
+ const [diff] = await Promise.all([
230
+ this._editorWorkerService.computeDiff(this.docSnapshot.uri, this.doc.uri, { computeMoves: true, ignoreTrimWhitespace: false, maxComputationTimeMs: 3000 }, 'advanced'),
231
+ timeout(fast ? 50 : 800)
232
+ ]);
233
+ if (this.doc.getVersionId() === docVersionNow && this.docSnapshot.getVersionId() === snapshotVersionNow) {
234
+ const diff2 = diff ?? nullDocumentDiff;
235
+ this._diffInfo.set(diff2, undefined);
236
+ this._edit = fromDiff(this.docSnapshot, this.doc, diff2);
237
+ }
238
+ }
239
+ async accept(transaction) {
240
+ if (this._stateObs.get() !== 0 ) {
241
+ return;
242
+ }
243
+ this.docSnapshot.setValue(this.doc.createSnapshot());
244
+ this._stateObs.set(1 , transaction);
245
+ await this.collapse(transaction);
246
+ this._notifyAction('accepted');
247
+ }
248
+ async reject(transaction) {
249
+ if (this._stateObs.get() !== 0 ) {
250
+ return;
251
+ }
252
+ this._stateObs.set(2 , transaction);
253
+ this._notifyAction('rejected');
254
+ if (this.createdInRequestId === this._telemetryInfo.requestId) {
255
+ await this._fileService.del(this.resource);
256
+ this._onDidDelete.fire();
257
+ this.dispose();
258
+ }
259
+ else {
260
+ this._setDocValue(this.docSnapshot.getValue());
261
+ await this.collapse(transaction);
262
+ }
263
+ }
264
+ _setDocValue(value) {
265
+ this.doc.pushStackElement();
266
+ const edit = EditOperation.replace(this.doc.getFullModelRange(), value);
267
+ this._applyEdits([edit]);
268
+ this.doc.pushStackElement();
269
+ }
270
+ async collapse(transaction) {
271
+ this._multiDiffEntryDelegate.collapse(transaction);
272
+ }
273
+ _notifyAction(outcome) {
274
+ this._chatService.notifyUserAction({
275
+ action: { kind: 'chatEditingSessionAction', uri: this.resource, hasRemainingEdits: false, outcome },
276
+ agentId: this._telemetryInfo.agentId,
277
+ command: this._telemetryInfo.command,
278
+ sessionId: this._telemetryInfo.sessionId,
279
+ requestId: this._telemetryInfo.requestId,
280
+ result: this._telemetryInfo.result
281
+ });
282
+ }
283
+ };
284
+ ChatEditingModifiedFileEntry = ChatEditingModifiedFileEntry_1 = ( (__decorate([
285
+ ( (__param(5, IModelService))),
286
+ ( (__param(6, ITextModelService))),
287
+ ( (__param(7, ILanguageService))),
288
+ ( (__param(8, IBulkEditService))),
289
+ ( (__param(9, IChatService))),
290
+ ( (__param(10, IEditorWorkerService))),
291
+ ( (__param(11, IUndoRedoService))),
292
+ ( (__param(12, IFileService)))
293
+ ], ChatEditingModifiedFileEntry)));
294
+ function toEditOperations(offsetEdit, doc) {
295
+ const edits = [];
296
+ for (const singleEdit of offsetEdit.edits) {
297
+ const range = Range.fromPositions(doc.getPositionAt(singleEdit.replaceRange.start), doc.getPositionAt(singleEdit.replaceRange.start + singleEdit.replaceRange.length));
298
+ edits.push(EditOperation.replace(range, singleEdit.newText));
299
+ }
300
+ return edits;
301
+ }
302
+ function fromContentChange(contentChanges) {
303
+ const editsArr = ( (contentChanges.map(
304
+ c => ( (new SingleOffsetEdit(OffsetRange.ofStartAndLength(c.rangeOffset, c.rangeLength), c.text)))
305
+ )));
306
+ editsArr.reverse();
307
+ const edits = ( (new OffsetEdit(editsArr)));
308
+ return edits;
309
+ }
310
+ function fromDiff(original, modified, diff) {
311
+ const edits = [];
312
+ for (const c of diff.changes) {
313
+ for (const i of c.innerChanges ?? []) {
314
+ const newText = modified.getValueInRange(i.modifiedRange);
315
+ const startOrig = original.getOffsetAt(i.originalRange.getStartPosition());
316
+ const endExOrig = original.getOffsetAt(i.originalRange.getEndPosition());
317
+ const origRange = ( (new OffsetRange(startOrig, endExOrig)));
318
+ edits.push(( (new SingleOffsetEdit(origRange, newText))));
319
+ }
320
+ }
321
+ return (
322
+ (new OffsetEdit(edits))
323
+ );
324
+ }
325
+
326
+ export { ChatEditingModifiedFileEntry };