@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
@@ -0,0 +1,109 @@
1
+ import { isCodeEditor } from 'vscode/vscode/vs/editor/browser/editorBrowser';
2
+ import { localize2 } from 'vscode/vscode/vs/nls';
3
+ import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
4
+ import { Action2, MenuId, registerAction2 } from 'vscode/vscode/vs/platform/actions/common/actions';
5
+ import { CHAT_CATEGORY } from '@codingame/monaco-vscode-chat-extensions-interactive-notebook-quickaccess-search-terminal-common/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
6
+ import { ctxHasEditorModification, ChatEditorController } from './chatEditorController.js';
7
+ import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
8
+ import { EditorContextKeys } from 'vscode/vscode/vs/editor/common/editorContextKeys';
9
+ import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService.service';
10
+ import { IChatEditingService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatEditingService.service';
11
+
12
+ class NavigateAction extends Action2 {
13
+ constructor(next) {
14
+ super({
15
+ id: next
16
+ ? 'chatEditor.action.navigateNext'
17
+ : 'chatEditor.action.navigatePrevious',
18
+ title: next
19
+ ? ( localize2(7588, 'Go to Next Chat Edit'))
20
+ : ( localize2(7589, 'Go to Previous Chat Edit')),
21
+ category: CHAT_CATEGORY,
22
+ icon: next ? Codicon.arrowDown : Codicon.arrowUp,
23
+ keybinding: {
24
+ primary: next
25
+ ? 512 | 63
26
+ : 512 | 1024 | 63 ,
27
+ weight: 100 ,
28
+ when: ( (ContextKeyExpr.and(ctxHasEditorModification, EditorContextKeys.focus))),
29
+ },
30
+ f1: true,
31
+ menu: {
32
+ id: MenuId.EditorTitle,
33
+ group: 'navigation',
34
+ order: next ? -100 : -101,
35
+ when: ctxHasEditorModification
36
+ }
37
+ });
38
+ this.next = next;
39
+ }
40
+ run(accessor) {
41
+ const editor = accessor.get(IEditorService).activeTextEditorControl;
42
+ if (!isCodeEditor(editor)) {
43
+ return;
44
+ }
45
+ if (this.next) {
46
+ ChatEditorController.get(editor)?.revealNext();
47
+ }
48
+ else {
49
+ ChatEditorController.get(editor)?.revealPrevious();
50
+ }
51
+ }
52
+ }
53
+ class AcceptDiscardAction extends Action2 {
54
+ constructor(accept) {
55
+ super({
56
+ id: accept
57
+ ? 'chatEditor.action.accept'
58
+ : 'chatEditor.action.reject',
59
+ title: accept
60
+ ? ( localize2(7590, 'Accept Chat Edit'))
61
+ : ( localize2(7591, 'Reject Chat Edit')),
62
+ category: CHAT_CATEGORY,
63
+ icon: accept
64
+ ? Codicon.check
65
+ : Codicon.discard,
66
+ menu: {
67
+ id: MenuId.EditorTitle,
68
+ group: 'navigation',
69
+ order: accept ? -103 : -102,
70
+ when: ctxHasEditorModification
71
+ }
72
+ });
73
+ this.accept = accept;
74
+ }
75
+ run(accessor) {
76
+ const chatEditingService = accessor.get(IChatEditingService);
77
+ const editorService = accessor.get(IEditorService);
78
+ const editor = editorService.activeTextEditorControl;
79
+ if (!isCodeEditor(editor) || !editor.hasModel()) {
80
+ return;
81
+ }
82
+ const session = chatEditingService.getEditingSession(editor.getModel().uri);
83
+ if (!session) {
84
+ return;
85
+ }
86
+ if (this.accept) {
87
+ session.accept(editor.getModel().uri);
88
+ }
89
+ else {
90
+ session.reject(editor.getModel().uri);
91
+ }
92
+ }
93
+ }
94
+ function registerChatEditorActions() {
95
+ registerAction2(class NextAction extends NavigateAction {
96
+ constructor() { super(true); }
97
+ });
98
+ registerAction2(class PrevAction extends NavigateAction {
99
+ constructor() { super(false); }
100
+ });
101
+ registerAction2(class AcceptAction extends AcceptDiscardAction {
102
+ constructor() { super(true); }
103
+ });
104
+ registerAction2(class RejectAction extends AcceptDiscardAction {
105
+ constructor() { super(false); }
106
+ });
107
+ }
108
+
109
+ export { registerChatEditorActions };
@@ -0,0 +1,284 @@
1
+ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
+ import { coalesceInPlace, binarySearch } from 'vscode/vscode/vs/base/common/arrays';
3
+ import { Disposable, DisposableStore, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
4
+ import 'vscode/vscode/vs/base/common/event';
5
+ import { autorun } from 'vscode/vscode/vs/base/common/observableInternal/autorun';
6
+ import { derived } from 'vscode/vscode/vs/base/common/observableInternal/derived';
7
+ import 'vscode/vscode/vs/base/common/cancellation';
8
+ import 'vscode/vscode/vs/base/common/observableInternal/utils';
9
+ import { isEqual } from 'vscode/vscode/vs/base/common/resources';
10
+ import { themeColorFromId } from 'vscode/vscode/vs/base/common/themables';
11
+ import { RenderOptions, LineSource, renderLines } from 'vscode/vscode/vs/editor/browser/widget/diffEditor/components/diffEditorViewZones/renderLines';
12
+ import { diffAddDecoration, diffWholeLineAddDecoration, diffDeleteDecoration } from 'vscode/vscode/vs/editor/browser/widget/diffEditor/registrations.contribution';
13
+ import { Range } from 'vscode/vscode/vs/editor/common/core/range';
14
+ import { OverviewRulerLane } from 'vscode/vscode/vs/editor/common/model';
15
+ import { ModelDecorationOptions } from 'vscode/vscode/vs/editor/common/model/textModel';
16
+ import { InlineDecoration } from 'vscode/vscode/vs/editor/common/viewModel';
17
+ import { localize } from 'vscode/vscode/vs/nls';
18
+ import { RawContextKey } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
19
+ import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey.service';
20
+ import { overviewRulerModifiedForeground, minimapGutterModifiedBackground, overviewRulerAddedForeground, minimapGutterAddedBackground, overviewRulerDeletedForeground, minimapGutterDeletedBackground } from 'vscode/vscode/vs/workbench/contrib/scm/browser/dirtydiffDecorator';
21
+ import { IChatEditingService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatEditingService.service';
22
+
23
+ var ChatEditorController_1;
24
+ const ctxHasEditorModification = ( (new RawContextKey('chat.hasEditorModifications', undefined, ( localize(7592, "The current editor contains chat modifications")))));
25
+ let ChatEditorController = class ChatEditorController extends Disposable {
26
+ static { ChatEditorController_1 = this; }
27
+ static { this.ID = 'editor.contrib.chatEditorController'; }
28
+ static get(editor) {
29
+ const controller = editor.getContribution(ChatEditorController_1.ID);
30
+ return controller;
31
+ }
32
+ constructor(_editor, _chatEditingService, contextKeyService) {
33
+ super();
34
+ this._editor = _editor;
35
+ this._chatEditingService = _chatEditingService;
36
+ this._sessionStore = this._register(( (new DisposableStore())));
37
+ this._decorations = this._editor.createDecorationsCollection();
38
+ this._viewZones = [];
39
+ this._register(this._editor.onDidChangeModel(() => this._update()));
40
+ this._register(this._chatEditingService.onDidChangeEditingSession(() => this._updateSessionDecorations()));
41
+ this._register(toDisposable(() => this._clearRendering()));
42
+ this._ctxHasEditorModification = ctxHasEditorModification.bindTo(contextKeyService);
43
+ this._register(autorun(r => {
44
+ if (this._editor.getOption(63 )) {
45
+ return;
46
+ }
47
+ const session = this._chatEditingService.currentEditingSessionObs.read(r);
48
+ const entry = session?.entries.read(r).find(e => isEqual(e.modifiedURI, this._editor.getModel()?.uri));
49
+ if (!entry || entry.state.read(r) !== 0 ) {
50
+ this._clearRendering();
51
+ return;
52
+ }
53
+ const diff = entry?.diffInfo.read(r);
54
+ this._updateWithDiff(entry, diff);
55
+ }));
56
+ const shouldBeReadOnly = derived(this, r => {
57
+ const value = this._chatEditingService.currentEditingSessionObs.read(r);
58
+ if (!value || value.state.read(r) !== 1 ) {
59
+ return false;
60
+ }
61
+ return (
62
+ (value.entries.read(r).some(e => isEqual(e.modifiedURI, this._editor.getModel()?.uri)))
63
+ );
64
+ });
65
+ let actualReadonly;
66
+ let actualDeco;
67
+ this._register(autorun(r => {
68
+ const value = shouldBeReadOnly.read(r);
69
+ if (value) {
70
+ actualReadonly ??= this._editor.getOption(94 );
71
+ actualDeco ??= this._editor.getOption(101 );
72
+ this._editor.updateOptions({
73
+ readOnly: true,
74
+ renderValidationDecorations: 'off'
75
+ });
76
+ }
77
+ else {
78
+ if (actualReadonly !== undefined && actualDeco !== undefined) {
79
+ this._editor.updateOptions({
80
+ readOnly: actualReadonly,
81
+ renderValidationDecorations: actualDeco
82
+ });
83
+ actualReadonly = undefined;
84
+ actualDeco = undefined;
85
+ }
86
+ }
87
+ }));
88
+ }
89
+ dispose() {
90
+ this._clearRendering();
91
+ super.dispose();
92
+ }
93
+ _update() {
94
+ this._sessionStore.clear();
95
+ if (!this._editor.hasModel()) {
96
+ return;
97
+ }
98
+ if (this._editor.getOption(63 )) {
99
+ return;
100
+ }
101
+ if (this._editor.getOption(63 )) {
102
+ this._clearRendering();
103
+ return;
104
+ }
105
+ this._updateSessionDecorations();
106
+ }
107
+ _updateSessionDecorations() {
108
+ if (!this._editor.hasModel()) {
109
+ this._clearRendering();
110
+ return;
111
+ }
112
+ const model = this._editor.getModel();
113
+ const editingSession = this._chatEditingService.getEditingSession(model.uri);
114
+ const entry = this._getEntry(editingSession, model);
115
+ if (!entry || entry.state.get() !== 0 ) {
116
+ this._clearRendering();
117
+ return;
118
+ }
119
+ const diff = entry.diffInfo.get();
120
+ this._updateWithDiff(entry, diff);
121
+ }
122
+ _getEntry(editingSession, model) {
123
+ if (!editingSession) {
124
+ return null;
125
+ }
126
+ return editingSession.entries.get().find(e => ( (e.modifiedURI.toString())) === ( (model.uri.toString()))) || null;
127
+ }
128
+ _clearRendering() {
129
+ this._editor.changeViewZones((viewZoneChangeAccessor) => {
130
+ for (const id of this._viewZones) {
131
+ viewZoneChangeAccessor.removeZone(id);
132
+ }
133
+ });
134
+ this._viewZones = [];
135
+ this._decorations.clear();
136
+ this._ctxHasEditorModification.reset();
137
+ }
138
+ _updateWithDiff(entry, diff) {
139
+ if (!diff) {
140
+ this._clearRendering();
141
+ return;
142
+ }
143
+ this._ctxHasEditorModification.set(true);
144
+ const originalModel = entry.originalModel;
145
+ const chatDiffAddDecoration = ModelDecorationOptions.createDynamic({
146
+ ...diffAddDecoration,
147
+ stickiness: 1
148
+ });
149
+ const chatDiffWholeLineAddDecoration = ModelDecorationOptions.createDynamic({
150
+ ...diffWholeLineAddDecoration,
151
+ stickiness: 1 ,
152
+ });
153
+ const createOverviewDecoration = (overviewRulerColor, minimapColor) => {
154
+ return ModelDecorationOptions.createDynamic({
155
+ description: 'chat-editing-decoration',
156
+ overviewRuler: { color: themeColorFromId(overviewRulerColor), position: OverviewRulerLane.Left },
157
+ minimap: { color: themeColorFromId(minimapColor), position: 2 },
158
+ });
159
+ };
160
+ const modifiedDecoration = createOverviewDecoration(overviewRulerModifiedForeground, minimapGutterModifiedBackground);
161
+ const addedDecoration = createOverviewDecoration(overviewRulerAddedForeground, minimapGutterAddedBackground);
162
+ const deletedDecoration = createOverviewDecoration(overviewRulerDeletedForeground, minimapGutterDeletedBackground);
163
+ this._editor.changeViewZones((viewZoneChangeAccessor) => {
164
+ for (const id of this._viewZones) {
165
+ viewZoneChangeAccessor.removeZone(id);
166
+ }
167
+ this._viewZones = [];
168
+ const modifiedDecorations = [];
169
+ const mightContainNonBasicASCII = originalModel.mightContainNonBasicASCII();
170
+ const mightContainRTL = originalModel.mightContainRTL();
171
+ const renderOptions = RenderOptions.fromEditor(this._editor);
172
+ for (const diffEntry of diff.changes) {
173
+ const originalRange = diffEntry.original;
174
+ originalModel.tokenization.forceTokenization(Math.max(1, originalRange.endLineNumberExclusive - 1));
175
+ const source = ( (new LineSource(
176
+ originalRange.mapToLineArray(l => originalModel.tokenization.getLineTokens(l)),
177
+ [],
178
+ mightContainNonBasicASCII,
179
+ mightContainRTL
180
+ )));
181
+ const decorations = [];
182
+ for (const i of diffEntry.innerChanges || []) {
183
+ decorations.push(( (new InlineDecoration(
184
+ i.originalRange.delta(-(diffEntry.original.startLineNumber - 1)),
185
+ diffDeleteDecoration.className,
186
+ 0
187
+ ))));
188
+ modifiedDecorations.push({
189
+ range: i.modifiedRange, options: chatDiffAddDecoration
190
+ });
191
+ }
192
+ if (!diffEntry.modified.isEmpty) {
193
+ modifiedDecorations.push({
194
+ range: diffEntry.modified.toInclusiveRange(), options: chatDiffWholeLineAddDecoration
195
+ });
196
+ }
197
+ if (diffEntry.original.isEmpty) {
198
+ modifiedDecorations.push({
199
+ range: diffEntry.modified.toInclusiveRange(),
200
+ options: addedDecoration
201
+ });
202
+ }
203
+ else if (diffEntry.modified.isEmpty) {
204
+ modifiedDecorations.push({
205
+ range: ( (new Range(
206
+ diffEntry.modified.startLineNumber,
207
+ 1,
208
+ diffEntry.modified.startLineNumber,
209
+ 1
210
+ ))),
211
+ options: deletedDecoration
212
+ });
213
+ }
214
+ else {
215
+ modifiedDecorations.push({
216
+ range: diffEntry.modified.toInclusiveRange(),
217
+ options: modifiedDecoration
218
+ });
219
+ }
220
+ const domNode = document.createElement('div');
221
+ domNode.className = 'chat-editing-original-zone view-lines line-delete monaco-mouse-cursor-text';
222
+ const result = renderLines(source, renderOptions, decorations, domNode);
223
+ const viewZoneData = {
224
+ afterLineNumber: diffEntry.modified.startLineNumber - 1,
225
+ heightInLines: result.heightInLines,
226
+ domNode,
227
+ ordinal: 50000 + 2
228
+ };
229
+ this._viewZones.push(viewZoneChangeAccessor.addZone(viewZoneData));
230
+ }
231
+ this._decorations.set(modifiedDecorations);
232
+ });
233
+ }
234
+ revealNext() {
235
+ this._reveal(true);
236
+ }
237
+ revealPrevious() {
238
+ this._reveal(false);
239
+ }
240
+ _reveal(next) {
241
+ const position = this._editor.getPosition();
242
+ if (!position) {
243
+ return;
244
+ }
245
+ const decorations = this._decorations
246
+ .getRanges()
247
+ .sort((a, b) => Range.compareRangesUsingStarts(a, b));
248
+ for (let i = 0; i < decorations.length; i++) {
249
+ const decoration = decorations[i];
250
+ for (let j = 0; j < decorations.length; j++) {
251
+ if (i !== j && decoration && decorations[j]?.containsRange(decoration)) {
252
+ decorations[i] = undefined;
253
+ break;
254
+ }
255
+ }
256
+ }
257
+ coalesceInPlace(decorations);
258
+ if (decorations.length === 0) {
259
+ return;
260
+ }
261
+ let idx = binarySearch(decorations, Range.fromPositions(position), Range.compareRangesUsingStarts);
262
+ if (idx < 0) {
263
+ idx = ~idx;
264
+ }
265
+ let target;
266
+ if (decorations[idx]?.containsPosition(position)) {
267
+ target = idx + (next ? 1 : -1);
268
+ }
269
+ else {
270
+ target = next ? idx : idx - 1;
271
+ }
272
+ target = (target + decorations.length) % decorations.length;
273
+ const targetPosition = decorations[target].getStartPosition();
274
+ this._editor.setPosition(targetPosition);
275
+ this._editor.revealPositionInCenter(targetPosition, 0 );
276
+ this._editor.focus();
277
+ }
278
+ };
279
+ ChatEditorController = ChatEditorController_1 = ( (__decorate([
280
+ ( (__param(1, IChatEditingService))),
281
+ ( (__param(2, IContextKeyService)))
282
+ ], ChatEditorController)));
283
+
284
+ export { ChatEditorController, ctxHasEditorModification };