@codingame/monaco-vscode-xterm-addons-common 24.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/empty.js +1 -0
- package/package.json +51 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContext.d.ts +25 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContext.js +315 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.d.ts +49 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +379 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/attachInstructionsAction.d.ts +17 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/attachInstructionsAction.js +101 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/newPromptFileActions.d.ts +4 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/newPromptFileActions.js +201 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptName.d.ts +7 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptName.js +79 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptSourceFolder.d.ts +8 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptSourceFolder.js +145 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.d.ts +73 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.js +468 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalUri.d.ts +18 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalUri.js +48 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.d.ts +80 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.js +583 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/markNavigationAddon.d.ts +64 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/markNavigationAddon.js +582 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermAddonImporter.d.ts +25 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermAddonImporter.js +43 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.d.ts +187 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.js +867 -0
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
|
|
4
|
+
import { VSDataTransfer, createStringDataTransferItem } from '@codingame/monaco-vscode-api/vscode/vs/base/common/dataTransfer';
|
|
5
|
+
import { HierarchicalKind } from '@codingame/monaco-vscode-api/vscode/vs/base/common/hierarchicalKind';
|
|
6
|
+
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
7
|
+
import { revive } from '@codingame/monaco-vscode-api/vscode/vs/base/common/marshalling';
|
|
8
|
+
import { Mimes } from '@codingame/monaco-vscode-api/vscode/vs/base/common/mime';
|
|
9
|
+
import { Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
|
|
10
|
+
import { joinPath, basename } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
|
|
11
|
+
import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
|
|
12
|
+
import { ILanguageFeaturesService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/languageFeatures.service';
|
|
13
|
+
import { IModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/model.service';
|
|
14
|
+
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
15
|
+
import { IEnvironmentService } from '@codingame/monaco-vscode-api/vscode/vs/platform/environment/common/environment.service';
|
|
16
|
+
import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
|
|
17
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
18
|
+
import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
19
|
+
import { isProposedApiEnabled } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions';
|
|
20
|
+
import { IExtensionService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions.service';
|
|
21
|
+
import { IChatVariablesService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatVariables.service';
|
|
22
|
+
import { IChatWidgetService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chat.service';
|
|
23
|
+
import { ChatDynamicVariableModel } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables';
|
|
24
|
+
import { cleanupOldImages, createFileForMedia, resizeImage, imageToHash } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/imageUtils';
|
|
25
|
+
|
|
26
|
+
var CopyAttachmentsProvider_1;
|
|
27
|
+
const COPY_MIME_TYPES = 'application/vnd.code.additional-editor-data';
|
|
28
|
+
let PasteImageProvider = class PasteImageProvider {
|
|
29
|
+
constructor(chatWidgetService, extensionService, fileService, environmentService, logService) {
|
|
30
|
+
this.chatWidgetService = chatWidgetService;
|
|
31
|
+
this.extensionService = extensionService;
|
|
32
|
+
this.fileService = fileService;
|
|
33
|
+
this.environmentService = environmentService;
|
|
34
|
+
this.logService = logService;
|
|
35
|
+
this.kind = ( new HierarchicalKind('chat.attach.image'));
|
|
36
|
+
this.providedPasteEditKinds = [this.kind];
|
|
37
|
+
this.copyMimeTypes = [];
|
|
38
|
+
this.pasteMimeTypes = ['image/*'];
|
|
39
|
+
this.imagesFolder = joinPath(this.environmentService.workspaceStorageHome, 'vscode-chat-images');
|
|
40
|
+
cleanupOldImages(this.fileService, this.logService, this.imagesFolder);
|
|
41
|
+
}
|
|
42
|
+
async provideDocumentPasteEdits(model, ranges, dataTransfer, context, token) {
|
|
43
|
+
if (!( this.extensionService.extensions.some(ext => isProposedApiEnabled(ext, 'chatReferenceBinaryData')))) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const supportedMimeTypes = [
|
|
47
|
+
'image/png',
|
|
48
|
+
'image/jpeg',
|
|
49
|
+
'image/jpg',
|
|
50
|
+
'image/bmp',
|
|
51
|
+
'image/gif',
|
|
52
|
+
'image/tiff'
|
|
53
|
+
];
|
|
54
|
+
let mimeType;
|
|
55
|
+
let imageItem;
|
|
56
|
+
for (const type of supportedMimeTypes) {
|
|
57
|
+
imageItem = dataTransfer.get(type);
|
|
58
|
+
if (imageItem) {
|
|
59
|
+
mimeType = type;
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (!imageItem || !mimeType) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const currClipboard = await imageItem.asFile()?.data();
|
|
67
|
+
if (token.isCancellationRequested || !currClipboard) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
|
|
71
|
+
if (!widget) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const attachedVariables = widget.attachmentModel.attachments;
|
|
75
|
+
const displayName = ( localize(5457, 'Pasted Image'));
|
|
76
|
+
let tempDisplayName = displayName;
|
|
77
|
+
for (let appendValue = 2; ( attachedVariables.some(attachment => attachment.name === tempDisplayName)); appendValue++) {
|
|
78
|
+
tempDisplayName = `${displayName} ${appendValue}`;
|
|
79
|
+
}
|
|
80
|
+
const fileReference = await createFileForMedia(this.fileService, this.imagesFolder, currClipboard, mimeType);
|
|
81
|
+
if (token.isCancellationRequested || !fileReference) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const scaledImageData = await resizeImage(currClipboard);
|
|
85
|
+
if (token.isCancellationRequested || !scaledImageData) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const scaledImageContext = await getImageAttachContext(scaledImageData, mimeType, token, tempDisplayName, fileReference);
|
|
89
|
+
if (token.isCancellationRequested || !scaledImageContext) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const currentContextIds = widget.attachmentModel.getAttachmentIDs();
|
|
93
|
+
if (( currentContextIds.has(scaledImageContext.id))) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const edit = createCustomPasteEdit(model, [scaledImageContext], mimeType, this.kind, ( localize(5458, 'Pasted Image Attachment')), this.chatWidgetService);
|
|
97
|
+
return createEditSession(edit);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
PasteImageProvider = ( __decorate([
|
|
101
|
+
( __param(2, IFileService)),
|
|
102
|
+
( __param(3, IEnvironmentService)),
|
|
103
|
+
( __param(4, ILogService))
|
|
104
|
+
], PasteImageProvider));
|
|
105
|
+
async function getImageAttachContext(data, mimeType, token, displayName, resource) {
|
|
106
|
+
const imageHash = await imageToHash(data);
|
|
107
|
+
if (token.isCancellationRequested) {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
kind: 'image',
|
|
112
|
+
value: data,
|
|
113
|
+
id: imageHash,
|
|
114
|
+
name: displayName,
|
|
115
|
+
icon: Codicon.fileMedia,
|
|
116
|
+
mimeType,
|
|
117
|
+
isPasted: true,
|
|
118
|
+
references: [{ reference: resource, kind: 'reference' }]
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function isImage(array) {
|
|
122
|
+
if (array.length < 4) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
const identifier = {
|
|
126
|
+
png: [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A],
|
|
127
|
+
jpeg: [0xFF, 0xD8, 0xFF],
|
|
128
|
+
bmp: [0x42, 0x4D],
|
|
129
|
+
gif: [0x47, 0x49, 0x46, 0x38],
|
|
130
|
+
tiff: [0x49, 0x49, 0x2A, 0x00]
|
|
131
|
+
};
|
|
132
|
+
return ( ( Object.values(identifier)).some((signature) => signature.every((byte, index) => array[index] === byte)));
|
|
133
|
+
}
|
|
134
|
+
class CopyTextProvider {
|
|
135
|
+
constructor() {
|
|
136
|
+
this.providedPasteEditKinds = [];
|
|
137
|
+
this.copyMimeTypes = [COPY_MIME_TYPES];
|
|
138
|
+
this.pasteMimeTypes = [];
|
|
139
|
+
}
|
|
140
|
+
async prepareDocumentPaste(model, ranges, dataTransfer, token) {
|
|
141
|
+
if (model.uri.scheme === Schemas.vscodeChatInput) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const customDataTransfer = ( new VSDataTransfer());
|
|
145
|
+
const data = { range: ranges[0], uri: model.uri.toJSON() };
|
|
146
|
+
customDataTransfer.append(COPY_MIME_TYPES, createStringDataTransferItem(JSON.stringify(data)));
|
|
147
|
+
return customDataTransfer;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
let CopyAttachmentsProvider = class CopyAttachmentsProvider {
|
|
151
|
+
static { CopyAttachmentsProvider_1 = this; }
|
|
152
|
+
static { this.ATTACHMENT_MIME_TYPE = 'application/vnd.chat.attachment+json'; }
|
|
153
|
+
constructor(chatWidgetService, chatVariableService) {
|
|
154
|
+
this.chatWidgetService = chatWidgetService;
|
|
155
|
+
this.chatVariableService = chatVariableService;
|
|
156
|
+
this.kind = ( new HierarchicalKind('chat.attach.attachments'));
|
|
157
|
+
this.providedPasteEditKinds = [this.kind];
|
|
158
|
+
this.copyMimeTypes = [CopyAttachmentsProvider_1.ATTACHMENT_MIME_TYPE];
|
|
159
|
+
this.pasteMimeTypes = [CopyAttachmentsProvider_1.ATTACHMENT_MIME_TYPE];
|
|
160
|
+
}
|
|
161
|
+
async prepareDocumentPaste(model, _ranges, _dataTransfer, _token) {
|
|
162
|
+
const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
|
|
163
|
+
if (!widget || !widget.viewModel) {
|
|
164
|
+
return undefined;
|
|
165
|
+
}
|
|
166
|
+
const attachments = widget.attachmentModel.attachments;
|
|
167
|
+
const dynamicVariables = this.chatVariableService.getDynamicVariables(widget.viewModel.sessionResource);
|
|
168
|
+
if (attachments.length === 0 && dynamicVariables.length === 0) {
|
|
169
|
+
return undefined;
|
|
170
|
+
}
|
|
171
|
+
const result = ( new VSDataTransfer());
|
|
172
|
+
result.append(CopyAttachmentsProvider_1.ATTACHMENT_MIME_TYPE, createStringDataTransferItem(JSON.stringify({ attachments, dynamicVariables })));
|
|
173
|
+
return result;
|
|
174
|
+
}
|
|
175
|
+
async provideDocumentPasteEdits(model, _ranges, dataTransfer, _context, token) {
|
|
176
|
+
const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
|
|
177
|
+
if (!widget || !widget.viewModel) {
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
const chatDynamicVariable = widget.getContrib(ChatDynamicVariableModel.ID);
|
|
181
|
+
if (!chatDynamicVariable) {
|
|
182
|
+
return undefined;
|
|
183
|
+
}
|
|
184
|
+
const text = dataTransfer.get(Mimes.text);
|
|
185
|
+
const data = dataTransfer.get(CopyAttachmentsProvider_1.ATTACHMENT_MIME_TYPE);
|
|
186
|
+
const rawData = await data?.asString();
|
|
187
|
+
const textdata = await text?.asString();
|
|
188
|
+
if (textdata === undefined || rawData === undefined) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (token.isCancellationRequested) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
let pastedData;
|
|
195
|
+
try {
|
|
196
|
+
pastedData = revive(JSON.parse(rawData));
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
}
|
|
200
|
+
if (!Array.isArray(pastedData?.attachments) && !Array.isArray(pastedData?.dynamicVariables)) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const edit = {
|
|
204
|
+
insertText: textdata,
|
|
205
|
+
title: ( localize(5459, 'Insert Prompt & Attachments')),
|
|
206
|
+
kind: this.kind,
|
|
207
|
+
handledMimeType: CopyAttachmentsProvider_1.ATTACHMENT_MIME_TYPE,
|
|
208
|
+
additionalEdit: {
|
|
209
|
+
edits: []
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
edit.additionalEdit?.edits.push({
|
|
213
|
+
resource: model.uri,
|
|
214
|
+
redo: () => {
|
|
215
|
+
widget.attachmentModel.addContext(...pastedData.attachments);
|
|
216
|
+
for (const dynamicVariable of pastedData.dynamicVariables) {
|
|
217
|
+
chatDynamicVariable?.addReference(dynamicVariable);
|
|
218
|
+
}
|
|
219
|
+
widget.refreshParsedInput();
|
|
220
|
+
},
|
|
221
|
+
undo: () => {
|
|
222
|
+
widget.attachmentModel.delete(...( pastedData.attachments.map(c => c.id)));
|
|
223
|
+
widget.refreshParsedInput();
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
return createEditSession(edit);
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
CopyAttachmentsProvider = CopyAttachmentsProvider_1 = ( __decorate([
|
|
230
|
+
( __param(0, IChatWidgetService)),
|
|
231
|
+
( __param(1, IChatVariablesService))
|
|
232
|
+
], CopyAttachmentsProvider));
|
|
233
|
+
class PasteTextProvider {
|
|
234
|
+
constructor(chatWidgetService, modelService) {
|
|
235
|
+
this.chatWidgetService = chatWidgetService;
|
|
236
|
+
this.modelService = modelService;
|
|
237
|
+
this.kind = ( new HierarchicalKind('chat.attach.text'));
|
|
238
|
+
this.providedPasteEditKinds = [this.kind];
|
|
239
|
+
this.copyMimeTypes = [];
|
|
240
|
+
this.pasteMimeTypes = [COPY_MIME_TYPES];
|
|
241
|
+
}
|
|
242
|
+
async provideDocumentPasteEdits(model, ranges, dataTransfer, _context, token) {
|
|
243
|
+
if (model.uri.scheme !== Schemas.vscodeChatInput) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
const text = dataTransfer.get(Mimes.text);
|
|
247
|
+
const editorData = dataTransfer.get('vscode-editor-data');
|
|
248
|
+
const additionalEditorData = dataTransfer.get(COPY_MIME_TYPES);
|
|
249
|
+
if (!editorData || !text || !additionalEditorData) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
const textdata = await text.asString();
|
|
253
|
+
const metadata = JSON.parse(await editorData.asString());
|
|
254
|
+
const additionalData = JSON.parse(await additionalEditorData.asString());
|
|
255
|
+
const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
|
|
256
|
+
if (!widget) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
const start = additionalData.range.startLineNumber;
|
|
260
|
+
const end = additionalData.range.endLineNumber;
|
|
261
|
+
if (start === end) {
|
|
262
|
+
const textModel = this.modelService.getModel(URI.revive(additionalData.uri));
|
|
263
|
+
if (!textModel) {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
const lineContent = textModel.getLineContent(start);
|
|
267
|
+
if (lineContent !== textdata) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
const copiedContext = getCopiedContext(textdata, URI.revive(additionalData.uri), metadata.mode, additionalData.range);
|
|
272
|
+
if (token.isCancellationRequested || !copiedContext) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
const currentContextIds = widget.attachmentModel.getAttachmentIDs();
|
|
276
|
+
if (( currentContextIds.has(copiedContext.id))) {
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
const edit = createCustomPasteEdit(model, [copiedContext], Mimes.text, this.kind, ( localize(5460, 'Pasted Code Attachment')), this.chatWidgetService);
|
|
280
|
+
edit.yieldTo = [{ kind: HierarchicalKind.Empty.append('text', 'plain') }];
|
|
281
|
+
return createEditSession(edit);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
function getCopiedContext(code, file, language, range) {
|
|
285
|
+
const fileName = basename(file);
|
|
286
|
+
const start = range.startLineNumber;
|
|
287
|
+
const end = range.endLineNumber;
|
|
288
|
+
const resultText = `Copied Selection of Code: \n\n\n From the file: ${fileName} From lines ${start} to ${end} \n \`\`\`${code}\`\`\``;
|
|
289
|
+
const pastedLines = start === end ? ( localize(5461, '1 line')) : ( localize(5462, '{0} lines', end + 1 - start));
|
|
290
|
+
return {
|
|
291
|
+
kind: 'paste',
|
|
292
|
+
value: resultText,
|
|
293
|
+
id: `${fileName}${start}${end}${range.startColumn}${range.endColumn}`,
|
|
294
|
+
name: `${fileName} ${pastedLines}`,
|
|
295
|
+
icon: Codicon.code,
|
|
296
|
+
pastedLines,
|
|
297
|
+
language,
|
|
298
|
+
fileName: ( file.toString()),
|
|
299
|
+
copiedFrom: {
|
|
300
|
+
uri: file,
|
|
301
|
+
range
|
|
302
|
+
},
|
|
303
|
+
code,
|
|
304
|
+
references: [{
|
|
305
|
+
reference: file,
|
|
306
|
+
kind: 'reference'
|
|
307
|
+
}]
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
function createCustomPasteEdit(model, context, handledMimeType, kind, title, chatWidgetService) {
|
|
311
|
+
const label = context.length === 1
|
|
312
|
+
? context[0].name
|
|
313
|
+
: ( localize(5463, '{0} and {1} more', context[0].name, context.length - 1));
|
|
314
|
+
const customEdit = {
|
|
315
|
+
resource: model.uri,
|
|
316
|
+
variable: context,
|
|
317
|
+
undo: () => {
|
|
318
|
+
const widget = chatWidgetService.getWidgetByInputUri(model.uri);
|
|
319
|
+
if (!widget) {
|
|
320
|
+
throw ( new Error('No widget found for undo'));
|
|
321
|
+
}
|
|
322
|
+
widget.attachmentModel.delete(...( context.map(c => c.id)));
|
|
323
|
+
},
|
|
324
|
+
redo: () => {
|
|
325
|
+
const widget = chatWidgetService.getWidgetByInputUri(model.uri);
|
|
326
|
+
if (!widget) {
|
|
327
|
+
throw ( new Error('No widget found for redo'));
|
|
328
|
+
}
|
|
329
|
+
widget.attachmentModel.addContext(...context);
|
|
330
|
+
},
|
|
331
|
+
metadata: {
|
|
332
|
+
needsConfirmation: false,
|
|
333
|
+
label
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
return {
|
|
337
|
+
insertText: '',
|
|
338
|
+
title,
|
|
339
|
+
kind,
|
|
340
|
+
handledMimeType,
|
|
341
|
+
additionalEdit: {
|
|
342
|
+
edits: [customEdit],
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
function createEditSession(edit) {
|
|
347
|
+
return {
|
|
348
|
+
edits: [edit],
|
|
349
|
+
dispose: () => { },
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
let ChatPasteProvidersFeature = class ChatPasteProvidersFeature extends Disposable {
|
|
353
|
+
constructor(instaService, languageFeaturesService, chatWidgetService, extensionService, fileService, modelService, environmentService, logService) {
|
|
354
|
+
super();
|
|
355
|
+
this._register(languageFeaturesService.documentPasteEditProvider.register({ scheme: Schemas.vscodeChatInput, pattern: '*', hasAccessToAllModels: true }, instaService.createInstance(CopyAttachmentsProvider)));
|
|
356
|
+
this._register(languageFeaturesService.documentPasteEditProvider.register({ scheme: Schemas.vscodeChatInput, pattern: '*', hasAccessToAllModels: true }, ( new PasteImageProvider(
|
|
357
|
+
chatWidgetService,
|
|
358
|
+
extensionService,
|
|
359
|
+
fileService,
|
|
360
|
+
environmentService,
|
|
361
|
+
logService
|
|
362
|
+
))));
|
|
363
|
+
this._register(languageFeaturesService.documentPasteEditProvider.register({ scheme: Schemas.vscodeChatInput, pattern: '*', hasAccessToAllModels: true }, ( new PasteTextProvider(chatWidgetService, modelService))));
|
|
364
|
+
this._register(languageFeaturesService.documentPasteEditProvider.register('*', ( new CopyTextProvider())));
|
|
365
|
+
this._register(languageFeaturesService.documentPasteEditProvider.register('*', ( new CopyTextProvider())));
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
ChatPasteProvidersFeature = ( __decorate([
|
|
369
|
+
( __param(0, IInstantiationService)),
|
|
370
|
+
( __param(1, ILanguageFeaturesService)),
|
|
371
|
+
( __param(2, IChatWidgetService)),
|
|
372
|
+
( __param(3, IExtensionService)),
|
|
373
|
+
( __param(4, IFileService)),
|
|
374
|
+
( __param(5, IModelService)),
|
|
375
|
+
( __param(6, IEnvironmentService)),
|
|
376
|
+
( __param(7, ILogService))
|
|
377
|
+
], ChatPasteProvidersFeature));
|
|
378
|
+
|
|
379
|
+
export { ChatPasteProvidersFeature, CopyTextProvider, PasteImageProvider, PasteTextProvider, isImage };
|
package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/attachInstructionsAction.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IChatWidget } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chat";
|
|
2
|
+
import { IPromptsService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.service";
|
|
3
|
+
import { IChatContextPickerItem, IChatContextPicker } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chatContextPickService";
|
|
4
|
+
/**
|
|
5
|
+
* Helper to register the `Attach Prompt` action.
|
|
6
|
+
*/
|
|
7
|
+
export declare function registerAttachPromptActions(): void;
|
|
8
|
+
export declare class ChatInstructionsPickerPick implements IChatContextPickerItem {
|
|
9
|
+
private readonly promptsService;
|
|
10
|
+
readonly type = "pickerPick";
|
|
11
|
+
readonly label: string;
|
|
12
|
+
readonly icon: import("@codingame/monaco-vscode-api/vscode/vs/base/common/themables").ThemeIcon;
|
|
13
|
+
readonly commandId = "workbench.action.chat.attach.instructions";
|
|
14
|
+
constructor(promptsService: IPromptsService);
|
|
15
|
+
isEnabled(widget: IChatWidget): Promise<boolean> | boolean;
|
|
16
|
+
asPicker(): IChatContextPicker;
|
|
17
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { ChatViewId } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chat';
|
|
4
|
+
import { CHAT_CONFIG_MENU_ID, CHAT_CATEGORY } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
|
|
5
|
+
import { localize2, localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
6
|
+
import { ChatContextKeys } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
|
|
7
|
+
import { IPromptsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.service';
|
|
8
|
+
import { PromptFilePickers } from './pickers/promptFilePickers.js';
|
|
9
|
+
import { Action2, registerAction2 } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
|
|
10
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
11
|
+
import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
|
|
12
|
+
import { getCleanPromptName } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/config/promptFileLocations';
|
|
13
|
+
import { ContextKeyExpr } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey';
|
|
14
|
+
import { PromptsType } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/promptTypes';
|
|
15
|
+
import { compare } from '@codingame/monaco-vscode-api/vscode/vs/base/common/strings';
|
|
16
|
+
import { toPromptFileVariableEntry, PromptFileVariableKind } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatVariableEntries';
|
|
17
|
+
import { CancellationToken } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
|
|
18
|
+
import { IOpenerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/opener/common/opener.service';
|
|
19
|
+
|
|
20
|
+
const ATTACH_INSTRUCTIONS_ACTION_ID = 'workbench.action.chat.attach.instructions';
|
|
21
|
+
const CONFIGURE_INSTRUCTIONS_ACTION_ID = 'workbench.action.chat.configure.instructions';
|
|
22
|
+
class ManageInstructionsFilesAction extends Action2 {
|
|
23
|
+
constructor() {
|
|
24
|
+
super({
|
|
25
|
+
id: CONFIGURE_INSTRUCTIONS_ACTION_ID,
|
|
26
|
+
title: ( localize2(5750, "Configure Instructions...")),
|
|
27
|
+
shortTitle: ( localize2(5751, "Chat Instructions")),
|
|
28
|
+
icon: Codicon.bookmark,
|
|
29
|
+
f1: true,
|
|
30
|
+
precondition: ChatContextKeys.enabled,
|
|
31
|
+
category: CHAT_CATEGORY,
|
|
32
|
+
menu: {
|
|
33
|
+
id: CHAT_CONFIG_MENU_ID,
|
|
34
|
+
when: ( ContextKeyExpr.and(ChatContextKeys.enabled, ( ContextKeyExpr.equals('view', ChatViewId)))),
|
|
35
|
+
order: 10,
|
|
36
|
+
group: '1_level'
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
async run(accessor) {
|
|
41
|
+
const openerService = accessor.get(IOpenerService);
|
|
42
|
+
const instaService = accessor.get(IInstantiationService);
|
|
43
|
+
const pickers = instaService.createInstance(PromptFilePickers);
|
|
44
|
+
const placeholder = ( localize(5752, 'Select the instructions file to open'));
|
|
45
|
+
const result = await pickers.selectPromptFile({ placeholder, type: PromptsType.instructions, optionEdit: false });
|
|
46
|
+
if (result !== undefined) {
|
|
47
|
+
await openerService.open(result.promptFile);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function registerAttachPromptActions() {
|
|
52
|
+
registerAction2(ManageInstructionsFilesAction);
|
|
53
|
+
}
|
|
54
|
+
let ChatInstructionsPickerPick = class ChatInstructionsPickerPick {
|
|
55
|
+
constructor(promptsService) {
|
|
56
|
+
this.promptsService = promptsService;
|
|
57
|
+
this.type = 'pickerPick';
|
|
58
|
+
this.label = ( localize(5753, 'Instructions...'));
|
|
59
|
+
this.icon = Codicon.bookmark;
|
|
60
|
+
this.commandId = ATTACH_INSTRUCTIONS_ACTION_ID;
|
|
61
|
+
}
|
|
62
|
+
isEnabled(widget) {
|
|
63
|
+
return !!widget.attachmentCapabilities.supportsInstructionAttachments;
|
|
64
|
+
}
|
|
65
|
+
asPicker() {
|
|
66
|
+
const picks = this.promptsService.listPromptFiles(PromptsType.instructions, CancellationToken.None).then(value => {
|
|
67
|
+
const result = [];
|
|
68
|
+
value = value.slice(0).sort((a, b) => compare(a.storage, b.storage));
|
|
69
|
+
let storageType;
|
|
70
|
+
for (const promptsPath of value) {
|
|
71
|
+
if (storageType !== promptsPath.storage) {
|
|
72
|
+
storageType = promptsPath.storage;
|
|
73
|
+
result.push({
|
|
74
|
+
type: 'separator',
|
|
75
|
+
label: this.promptsService.getPromptLocationLabel(promptsPath)
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
result.push({
|
|
79
|
+
label: promptsPath.name ?? getCleanPromptName(promptsPath.uri),
|
|
80
|
+
asAttachment: () => {
|
|
81
|
+
return toPromptFileVariableEntry(promptsPath.uri, PromptFileVariableKind.Instruction);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return result;
|
|
86
|
+
});
|
|
87
|
+
return {
|
|
88
|
+
placeholder: ( localize(5754, 'Select instructions files to attach')),
|
|
89
|
+
picks,
|
|
90
|
+
configure: {
|
|
91
|
+
label: ( localize(5755, 'Configure Instructions...')),
|
|
92
|
+
commandId: CONFIGURE_INSTRUCTIONS_ACTION_ID
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
ChatInstructionsPickerPick = ( __decorate([
|
|
98
|
+
( __param(0, IPromptsService))
|
|
99
|
+
], ChatInstructionsPickerPick));
|
|
100
|
+
|
|
101
|
+
export { ChatInstructionsPickerPick, registerAttachPromptActions };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const NEW_PROMPT_COMMAND_ID = "workbench.command.new.prompt";
|
|
2
|
+
export declare const NEW_INSTRUCTIONS_COMMAND_ID = "workbench.command.new.instructions";
|
|
3
|
+
export declare const NEW_AGENT_COMMAND_ID = "workbench.command.new.agent";
|
|
4
|
+
export declare function registerNewPromptFileActions(): void;
|