@codingame/monaco-vscode-xterm-addons-common 37.2.0 → 37.3.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/package.json +2 -2
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.js +3 -3
- package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/terminalStickyScrollOverlay.d.ts +58 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/terminalStickyScrollOverlay.js +462 -0
- package/vscode/src/vs/base/browser/htmlToMarkdown.d.ts +0 -1
- package/vscode/src/vs/base/browser/htmlToMarkdown.js +0 -144
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContext.d.ts +0 -59
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContext.js +0 -482
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/attachInstructionsAction.d.ts +0 -25
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/attachInstructionsAction.js +0 -95
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/newPromptFileActions.d.ts +0 -24
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/newPromptFileActions.js +0 -355
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptName.d.ts +0 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptName.js +0 -81
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptSourceFolder.d.ts +0 -15
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptSourceFolder.js +0 -181
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.d.ts +0 -75
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.js +0 -622
- package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/editor/chatPasteProviders.d.ts +0 -71
- package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/editor/chatPasteProviders.js +0 -800
- package/vscode/src/vs/workbench/contrib/git/common/utils.d.ts +0 -8
- package/vscode/src/vs/workbench/contrib/git/common/utils.js +0 -105
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalUri.d.ts +0 -18
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalUri.js +0 -51
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.d.ts +0 -79
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.js +0 -652
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/markNavigationAddon.d.ts +0 -64
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/markNavigationAddon.js +0 -564
package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.js
DELETED
|
@@ -1,622 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
-
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
4
|
-
import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
|
|
5
|
-
import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
|
|
6
|
-
import { ThemeIcon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/themables';
|
|
7
|
-
import { PromptsStorage, AgentInstructionFileType } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService';
|
|
8
|
-
import { IPromptsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.service';
|
|
9
|
-
import { extUri, dirname, joinPath, basename } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
|
|
10
|
-
import { DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
11
|
-
import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
|
|
12
|
-
import { IOpenerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/opener/common/opener.service';
|
|
13
|
-
import { IDialogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/dialogs/common/dialogs.service';
|
|
14
|
-
import { ICommandService } from '@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands.service';
|
|
15
|
-
import { getSkillFolderName, getCleanPromptName } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/config/promptFileLocations';
|
|
16
|
-
import { getDocumentationUrl, PromptsType } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/promptTypes';
|
|
17
|
-
import { NEW_PROMPT_COMMAND_ID, NEW_INSTRUCTIONS_COMMAND_ID, NEW_AGENT_COMMAND_ID, NEW_SKILL_COMMAND_ID } from '../newPromptFileActions.js';
|
|
18
|
-
import { GENERATE_AGENT_INSTRUCTIONS_COMMAND_ID, GENERATE_ON_DEMAND_INSTRUCTIONS_COMMAND_ID, GENERATE_PROMPT_COMMAND_ID, GENERATE_SKILL_COMMAND_ID, GENERATE_AGENT_COMMAND_ID } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
|
|
19
|
-
import { IQuickInputService } from '@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput.service';
|
|
20
|
-
import { askForPromptFileName } from './askForPromptName.js';
|
|
21
|
-
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
22
|
-
import { CancellationTokenSource, CancellationToken } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
|
|
23
|
-
import { askForPromptSourceFolder } from './askForPromptSourceFolder.js';
|
|
24
|
-
import { ILabelService } from '@codingame/monaco-vscode-api/vscode/vs/platform/label/common/label.service';
|
|
25
|
-
import { IProductService } from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service';
|
|
26
|
-
import { PromptFileRewriter } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/promptSyntax/promptFileRewriter';
|
|
27
|
-
import { isOrganizationPromptFile } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/utils/promptsServiceUtils';
|
|
28
|
-
import { assertNever } from '@codingame/monaco-vscode-api/vscode/vs/base/common/assert';
|
|
29
|
-
|
|
30
|
-
function newHelpButton(type) {
|
|
31
|
-
const iconClass = ThemeIcon.asClassName(Codicon.question);
|
|
32
|
-
const helpURI = ( URI.parse(getDocumentationUrl(type)));
|
|
33
|
-
switch (type) {
|
|
34
|
-
case PromptsType.prompt:
|
|
35
|
-
return {
|
|
36
|
-
tooltip: ( localize(8945, "Show help on prompt files")),
|
|
37
|
-
helpURI,
|
|
38
|
-
iconClass
|
|
39
|
-
};
|
|
40
|
-
case PromptsType.instructions:
|
|
41
|
-
return {
|
|
42
|
-
tooltip: ( localize(8946, "Show help on instruction files")),
|
|
43
|
-
helpURI,
|
|
44
|
-
iconClass
|
|
45
|
-
};
|
|
46
|
-
case PromptsType.agent:
|
|
47
|
-
return {
|
|
48
|
-
tooltip: ( localize(8947, "Show help on custom agent files")),
|
|
49
|
-
helpURI,
|
|
50
|
-
iconClass
|
|
51
|
-
};
|
|
52
|
-
case PromptsType.skill:
|
|
53
|
-
return {
|
|
54
|
-
tooltip: ( localize(8948, "Show help on skill files")),
|
|
55
|
-
helpURI,
|
|
56
|
-
iconClass
|
|
57
|
-
};
|
|
58
|
-
case PromptsType.hook:
|
|
59
|
-
return {
|
|
60
|
-
tooltip: ( localize(8949, "Show help on hook files")),
|
|
61
|
-
helpURI,
|
|
62
|
-
iconClass
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
function isHelpButton(button) {
|
|
67
|
-
return button.helpURI !== undefined;
|
|
68
|
-
}
|
|
69
|
-
function isPromptFileItem(item) {
|
|
70
|
-
return item.type === "item" && !!item.promptFileUri;
|
|
71
|
-
}
|
|
72
|
-
function isExtensionPromptPath(prompt) {
|
|
73
|
-
return prompt.storage === PromptsStorage.extension && !!prompt.extension;
|
|
74
|
-
}
|
|
75
|
-
const NEW_PROMPT_FILE_OPTION = {
|
|
76
|
-
type: "item",
|
|
77
|
-
label: `$(plus) ${( localize(8950, "New prompt file..."))}`,
|
|
78
|
-
pickable: false,
|
|
79
|
-
alwaysShow: true,
|
|
80
|
-
buttons: [newHelpButton(PromptsType.prompt)],
|
|
81
|
-
commandId: NEW_PROMPT_COMMAND_ID
|
|
82
|
-
};
|
|
83
|
-
const NEW_INSTRUCTIONS_FILE_OPTION = {
|
|
84
|
-
type: "item",
|
|
85
|
-
label: `$(plus) ${( localize(8951, "New instruction file..."))}`,
|
|
86
|
-
pickable: false,
|
|
87
|
-
alwaysShow: true,
|
|
88
|
-
buttons: [newHelpButton(PromptsType.instructions)],
|
|
89
|
-
commandId: NEW_INSTRUCTIONS_COMMAND_ID
|
|
90
|
-
};
|
|
91
|
-
const GENERATE_AGENT_INSTRUCTIONS_OPTION = {
|
|
92
|
-
type: "item",
|
|
93
|
-
label: `$(sparkle) ${( localize(8952, "Generate agent instructions..."))}`,
|
|
94
|
-
pickable: false,
|
|
95
|
-
alwaysShow: true,
|
|
96
|
-
buttons: [newHelpButton(PromptsType.instructions)],
|
|
97
|
-
commandId: GENERATE_AGENT_INSTRUCTIONS_COMMAND_ID
|
|
98
|
-
};
|
|
99
|
-
const GENERATE_ON_DEMAND_INSTRUCTIONS_OPTION = {
|
|
100
|
-
type: "item",
|
|
101
|
-
label: `$(sparkle) ${( localize(8953, "Generate on-demand instructions..."))}`,
|
|
102
|
-
pickable: false,
|
|
103
|
-
alwaysShow: true,
|
|
104
|
-
buttons: [newHelpButton(PromptsType.instructions)],
|
|
105
|
-
commandId: GENERATE_ON_DEMAND_INSTRUCTIONS_COMMAND_ID
|
|
106
|
-
};
|
|
107
|
-
const NEW_AGENT_FILE_OPTION = {
|
|
108
|
-
type: "item",
|
|
109
|
-
label: `$(plus) ${( localize(8954, "Create new custom agent..."))}`,
|
|
110
|
-
pickable: false,
|
|
111
|
-
alwaysShow: true,
|
|
112
|
-
buttons: [newHelpButton(PromptsType.agent)],
|
|
113
|
-
commandId: NEW_AGENT_COMMAND_ID
|
|
114
|
-
};
|
|
115
|
-
const NEW_SKILL_FILE_OPTION = {
|
|
116
|
-
type: "item",
|
|
117
|
-
label: `$(plus) ${( localize(8955, "New skill..."))}`,
|
|
118
|
-
pickable: false,
|
|
119
|
-
alwaysShow: true,
|
|
120
|
-
buttons: [newHelpButton(PromptsType.skill)],
|
|
121
|
-
commandId: NEW_SKILL_COMMAND_ID
|
|
122
|
-
};
|
|
123
|
-
const GENERATE_PROMPT_OPTION = {
|
|
124
|
-
type: "item",
|
|
125
|
-
label: `$(sparkle) ${( localize(8956, "Generate prompt..."))}`,
|
|
126
|
-
pickable: false,
|
|
127
|
-
alwaysShow: true,
|
|
128
|
-
buttons: [newHelpButton(PromptsType.prompt)],
|
|
129
|
-
commandId: GENERATE_PROMPT_COMMAND_ID
|
|
130
|
-
};
|
|
131
|
-
const GENERATE_SKILL_OPTION = {
|
|
132
|
-
type: "item",
|
|
133
|
-
label: `$(sparkle) ${( localize(8957, "Generate skill..."))}`,
|
|
134
|
-
pickable: false,
|
|
135
|
-
alwaysShow: true,
|
|
136
|
-
buttons: [newHelpButton(PromptsType.skill)],
|
|
137
|
-
commandId: GENERATE_SKILL_COMMAND_ID
|
|
138
|
-
};
|
|
139
|
-
const GENERATE_AGENT_OPTION = {
|
|
140
|
-
type: "item",
|
|
141
|
-
label: `$(sparkle) ${( localize(8958, "Generate agent..."))}`,
|
|
142
|
-
pickable: false,
|
|
143
|
-
alwaysShow: true,
|
|
144
|
-
buttons: [newHelpButton(PromptsType.agent)],
|
|
145
|
-
commandId: GENERATE_AGENT_COMMAND_ID
|
|
146
|
-
};
|
|
147
|
-
const EDIT_BUTTON = {
|
|
148
|
-
tooltip: ( localize(8959, "Open in Editor")),
|
|
149
|
-
iconClass: ThemeIcon.asClassName(Codicon.fileCode)
|
|
150
|
-
};
|
|
151
|
-
const DELETE_BUTTON = {
|
|
152
|
-
tooltip: ( localize(8960, "Delete")),
|
|
153
|
-
iconClass: ThemeIcon.asClassName(Codicon.trash)
|
|
154
|
-
};
|
|
155
|
-
const RENAME_BUTTON = {
|
|
156
|
-
tooltip: ( localize(8961, "Move and/or Rename")),
|
|
157
|
-
iconClass: ThemeIcon.asClassName(Codicon.replace)
|
|
158
|
-
};
|
|
159
|
-
const COPY_BUTTON = {
|
|
160
|
-
tooltip: ( localize(8962, "Make a Copy")),
|
|
161
|
-
iconClass: ThemeIcon.asClassName(Codicon.copy)
|
|
162
|
-
};
|
|
163
|
-
const MAKE_VISIBLE_BUTTON = {
|
|
164
|
-
tooltip: ( localize(8963, "Hidden from chat view agent picker. Click to show.")),
|
|
165
|
-
iconClass: ThemeIcon.asClassName(Codicon.eyeClosed),
|
|
166
|
-
alwaysVisible: true
|
|
167
|
-
};
|
|
168
|
-
const MAKE_INVISIBLE_BUTTON = {
|
|
169
|
-
tooltip: ( localize(8964, "Shown in chat view agent picker. Click to hide.")),
|
|
170
|
-
iconClass: ThemeIcon.asClassName(Codicon.eye)
|
|
171
|
-
};
|
|
172
|
-
const RUN_IN_CHAT_BUTTON = {
|
|
173
|
-
tooltip: ( localize(8965, "Run in Chat View")),
|
|
174
|
-
iconClass: ThemeIcon.asClassName(Codicon.play)
|
|
175
|
-
};
|
|
176
|
-
let PromptFilePickers = class PromptFilePickers {
|
|
177
|
-
constructor(
|
|
178
|
-
_quickInputService,
|
|
179
|
-
_openerService,
|
|
180
|
-
_fileService,
|
|
181
|
-
_dialogService,
|
|
182
|
-
_commandService,
|
|
183
|
-
_instaService,
|
|
184
|
-
_promptsService,
|
|
185
|
-
_labelService,
|
|
186
|
-
_productService
|
|
187
|
-
) {
|
|
188
|
-
this._quickInputService = _quickInputService;
|
|
189
|
-
this._openerService = _openerService;
|
|
190
|
-
this._fileService = _fileService;
|
|
191
|
-
this._dialogService = _dialogService;
|
|
192
|
-
this._commandService = _commandService;
|
|
193
|
-
this._instaService = _instaService;
|
|
194
|
-
this._promptsService = _promptsService;
|
|
195
|
-
this._labelService = _labelService;
|
|
196
|
-
this._productService = _productService;
|
|
197
|
-
}
|
|
198
|
-
async selectPromptFile(options) {
|
|
199
|
-
const cts = ( new CancellationTokenSource());
|
|
200
|
-
const quickPick = this._quickInputService.createQuickPick({
|
|
201
|
-
useSeparators: true
|
|
202
|
-
});
|
|
203
|
-
quickPick.busy = true;
|
|
204
|
-
quickPick.placeholder = ( localize(8966, "Searching file system..."));
|
|
205
|
-
try {
|
|
206
|
-
const fileOptions = await this._createPromptPickItems(options, cts.token);
|
|
207
|
-
const activeItem = options.resource && fileOptions.find(
|
|
208
|
-
f => f.type === "item" && extUri.isEqual(f.promptFileUri, options.resource)
|
|
209
|
-
);
|
|
210
|
-
if (activeItem) {
|
|
211
|
-
quickPick.activeItems = [activeItem];
|
|
212
|
-
}
|
|
213
|
-
quickPick.placeholder = options.placeholder;
|
|
214
|
-
quickPick.matchOnDescription = true;
|
|
215
|
-
quickPick.items = fileOptions;
|
|
216
|
-
} finally {
|
|
217
|
-
quickPick.busy = false;
|
|
218
|
-
}
|
|
219
|
-
return ( new Promise(resolve => {
|
|
220
|
-
const disposables = ( new DisposableStore());
|
|
221
|
-
let isResolved = false;
|
|
222
|
-
let isClosed = false;
|
|
223
|
-
disposables.add(quickPick);
|
|
224
|
-
disposables.add(cts);
|
|
225
|
-
const refreshItems = async () => {
|
|
226
|
-
const active = quickPick.activeItems;
|
|
227
|
-
const newItems = await this._createPromptPickItems(options, CancellationToken.None);
|
|
228
|
-
quickPick.items = newItems;
|
|
229
|
-
quickPick.activeItems = active;
|
|
230
|
-
};
|
|
231
|
-
disposables.add(quickPick.onDidAccept(async () => {
|
|
232
|
-
const {
|
|
233
|
-
selectedItems
|
|
234
|
-
} = quickPick;
|
|
235
|
-
const {
|
|
236
|
-
keyMods
|
|
237
|
-
} = quickPick;
|
|
238
|
-
const selectedItem = selectedItems[0];
|
|
239
|
-
if (isPromptFileItem(selectedItem)) {
|
|
240
|
-
resolve({
|
|
241
|
-
promptFile: selectedItem.promptFileUri,
|
|
242
|
-
keyMods: {
|
|
243
|
-
...keyMods
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
isResolved = true;
|
|
247
|
-
} else {
|
|
248
|
-
if (selectedItem.commandId) {
|
|
249
|
-
await this._commandService.executeCommand(selectedItem.commandId);
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
quickPick.hide();
|
|
254
|
-
}));
|
|
255
|
-
disposables.add(quickPick.onDidTriggerItemButton(async e => {
|
|
256
|
-
const shouldRefresh = await this._handleButtonClick(quickPick, e, options);
|
|
257
|
-
if (!isClosed && shouldRefresh) {
|
|
258
|
-
await refreshItems();
|
|
259
|
-
}
|
|
260
|
-
}));
|
|
261
|
-
disposables.add(quickPick.onDidHide(() => {
|
|
262
|
-
if (!quickPick.ignoreFocusOut) {
|
|
263
|
-
disposables.dispose();
|
|
264
|
-
isClosed = true;
|
|
265
|
-
if (!isResolved) {
|
|
266
|
-
resolve(undefined);
|
|
267
|
-
isResolved = true;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}));
|
|
271
|
-
quickPick.show();
|
|
272
|
-
}));
|
|
273
|
-
}
|
|
274
|
-
async _createPromptPickItems(options, token) {
|
|
275
|
-
const buttons = [];
|
|
276
|
-
if (options.type === PromptsType.prompt && options.optionRun !== false) {
|
|
277
|
-
buttons.push(RUN_IN_CHAT_BUTTON);
|
|
278
|
-
}
|
|
279
|
-
if (options.optionEdit !== false) {
|
|
280
|
-
buttons.push(EDIT_BUTTON);
|
|
281
|
-
}
|
|
282
|
-
if (options.optionCopy !== false) {
|
|
283
|
-
buttons.push(COPY_BUTTON);
|
|
284
|
-
}
|
|
285
|
-
if (options.optionRename !== false) {
|
|
286
|
-
buttons.push(RENAME_BUTTON);
|
|
287
|
-
}
|
|
288
|
-
if (options.optionDelete !== false) {
|
|
289
|
-
buttons.push(DELETE_BUTTON);
|
|
290
|
-
}
|
|
291
|
-
const result = [];
|
|
292
|
-
if (options.optionNew !== false) {
|
|
293
|
-
result.push(...this._getNewItems(options.type));
|
|
294
|
-
}
|
|
295
|
-
let getVisibility = () => undefined;
|
|
296
|
-
if (options.optionVisibility) {
|
|
297
|
-
const disabled = this._promptsService.getDisabledPromptFiles(options.type);
|
|
298
|
-
getVisibility = p => !( disabled.has(p.uri));
|
|
299
|
-
}
|
|
300
|
-
const sortByLabel = items => items.sort((a, b) => a.label.localeCompare(b.label));
|
|
301
|
-
const locals = await this._promptsService.listPromptFilesForStorage(options.type, PromptsStorage.local, token);
|
|
302
|
-
if (locals.length) {
|
|
303
|
-
result.push({
|
|
304
|
-
type: "separator",
|
|
305
|
-
label: ( localize(8967, "Workspace"))
|
|
306
|
-
});
|
|
307
|
-
result.push(...sortByLabel(await Promise.all(( locals.map(l => this._createPromptPickItem(l, buttons, getVisibility(l), token))))));
|
|
308
|
-
}
|
|
309
|
-
let agentInstructionFiles = [];
|
|
310
|
-
if (options.type === PromptsType.instructions) {
|
|
311
|
-
const agentInstructionUris = await this._promptsService.listAgentInstructions(token);
|
|
312
|
-
agentInstructionFiles = ( agentInstructionUris.map(agentInstructionFile => {
|
|
313
|
-
const folderName = this._labelService.getUriLabel(dirname(agentInstructionFile.uri), {
|
|
314
|
-
relative: true
|
|
315
|
-
});
|
|
316
|
-
return {
|
|
317
|
-
uri: agentInstructionFile.uri,
|
|
318
|
-
description: agentInstructionFile.type !== AgentInstructionFileType.copilotInstructionsMd ? folderName : undefined,
|
|
319
|
-
storage: PromptsStorage.local,
|
|
320
|
-
type: options.type
|
|
321
|
-
};
|
|
322
|
-
}));
|
|
323
|
-
}
|
|
324
|
-
if (agentInstructionFiles.length) {
|
|
325
|
-
const agentButtons = buttons.filter(b => b !== RENAME_BUTTON);
|
|
326
|
-
result.push({
|
|
327
|
-
type: "separator",
|
|
328
|
-
label: ( localize(8968, "Agent Instructions"))
|
|
329
|
-
});
|
|
330
|
-
result.push(...sortByLabel(await Promise.all(( agentInstructionFiles.map(l => this._createPromptPickItem(l, agentButtons, getVisibility(l), token))))));
|
|
331
|
-
}
|
|
332
|
-
const exts = (await this._promptsService.listPromptFilesForStorage(options.type, PromptsStorage.extension, token)).filter(isExtensionPromptPath);
|
|
333
|
-
if (exts.length) {
|
|
334
|
-
const extButtons = [];
|
|
335
|
-
if (options.type === PromptsType.prompt && options.optionRun !== false) {
|
|
336
|
-
extButtons.push(RUN_IN_CHAT_BUTTON);
|
|
337
|
-
}
|
|
338
|
-
if (options.optionEdit !== false) {
|
|
339
|
-
extButtons.push(EDIT_BUTTON);
|
|
340
|
-
}
|
|
341
|
-
if (options.optionCopy !== false) {
|
|
342
|
-
extButtons.push(COPY_BUTTON);
|
|
343
|
-
}
|
|
344
|
-
const groupedExts = ( new Map());
|
|
345
|
-
for (const ext of exts) {
|
|
346
|
-
const groupLabel = this._getExtensionGroupLabel(ext);
|
|
347
|
-
if (!( groupedExts.has(groupLabel))) {
|
|
348
|
-
groupedExts.set(groupLabel, []);
|
|
349
|
-
}
|
|
350
|
-
groupedExts.get(groupLabel).push(ext);
|
|
351
|
-
}
|
|
352
|
-
const sortedGroupedExts = Array.from(groupedExts.entries()).sort((a, b) => a[0].localeCompare(b[0]));
|
|
353
|
-
for (const [groupLabel, groupExts] of sortedGroupedExts) {
|
|
354
|
-
result.push({
|
|
355
|
-
type: "separator",
|
|
356
|
-
label: groupLabel
|
|
357
|
-
});
|
|
358
|
-
result.push(...sortByLabel(await Promise.all(( groupExts.map(e => this._createPromptPickItem(e, extButtons, getVisibility(e), token))))));
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
const users = await this._promptsService.listPromptFilesForStorage(options.type, PromptsStorage.user, token);
|
|
362
|
-
if (users.length) {
|
|
363
|
-
result.push({
|
|
364
|
-
type: "separator",
|
|
365
|
-
label: ( localize(8969, "User Data"))
|
|
366
|
-
});
|
|
367
|
-
result.push(...sortByLabel(await Promise.all(( users.map(u => this._createPromptPickItem(u, buttons, getVisibility(u), token))))));
|
|
368
|
-
}
|
|
369
|
-
const plugins = await this._promptsService.listPromptFilesForStorage(options.type, PromptsStorage.plugin, token);
|
|
370
|
-
if (plugins.length) {
|
|
371
|
-
const pluginButtons = [];
|
|
372
|
-
if (options.optionCopy !== false) {
|
|
373
|
-
pluginButtons.push(COPY_BUTTON);
|
|
374
|
-
}
|
|
375
|
-
result.push({
|
|
376
|
-
type: "separator",
|
|
377
|
-
label: ( localize(8970, "Plugins"))
|
|
378
|
-
});
|
|
379
|
-
result.push(...sortByLabel(await Promise.all(( plugins.map(p => this._createPromptPickItem(p, pluginButtons, getVisibility(p), token))))));
|
|
380
|
-
}
|
|
381
|
-
return result;
|
|
382
|
-
}
|
|
383
|
-
_getExtensionGroupLabel(extPath) {
|
|
384
|
-
if (isOrganizationPromptFile(extPath.uri, extPath.extension.identifier, this._productService)) {
|
|
385
|
-
return localize(8971, "Organization");
|
|
386
|
-
}
|
|
387
|
-
return localize(8972, "Extensions");
|
|
388
|
-
}
|
|
389
|
-
_getNewItems(type) {
|
|
390
|
-
switch (type) {
|
|
391
|
-
case PromptsType.prompt:
|
|
392
|
-
return [NEW_PROMPT_FILE_OPTION, GENERATE_PROMPT_OPTION];
|
|
393
|
-
case PromptsType.instructions:
|
|
394
|
-
return [
|
|
395
|
-
NEW_INSTRUCTIONS_FILE_OPTION,
|
|
396
|
-
GENERATE_ON_DEMAND_INSTRUCTIONS_OPTION,
|
|
397
|
-
GENERATE_AGENT_INSTRUCTIONS_OPTION
|
|
398
|
-
];
|
|
399
|
-
case PromptsType.agent:
|
|
400
|
-
return [NEW_AGENT_FILE_OPTION, GENERATE_AGENT_OPTION];
|
|
401
|
-
case PromptsType.skill:
|
|
402
|
-
return [NEW_SKILL_FILE_OPTION, GENERATE_SKILL_OPTION];
|
|
403
|
-
default:
|
|
404
|
-
throw ( new Error(`Unknown prompt type '${type}'.`));
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
async _createPromptPickItem(promptFile, buttons, visibility, token) {
|
|
408
|
-
const parsedPromptFile = await this._promptsService.parseNew(promptFile.uri, token).catch(() => undefined);
|
|
409
|
-
let promptName = (parsedPromptFile?.header?.name ?? promptFile.name) || (promptFile.type === PromptsType.skill ? getSkillFolderName(promptFile.uri) : getCleanPromptName(promptFile.uri));
|
|
410
|
-
const promptDescription = parsedPromptFile?.header?.description ?? promptFile.description;
|
|
411
|
-
let tooltip;
|
|
412
|
-
switch (promptFile.storage) {
|
|
413
|
-
case PromptsStorage.extension:
|
|
414
|
-
tooltip = promptFile.extension.displayName ?? promptFile.extension.id;
|
|
415
|
-
break;
|
|
416
|
-
case PromptsStorage.local:
|
|
417
|
-
tooltip = this._labelService.getUriLabel(dirname(promptFile.uri), {
|
|
418
|
-
relative: true
|
|
419
|
-
});
|
|
420
|
-
break;
|
|
421
|
-
case PromptsStorage.user:
|
|
422
|
-
tooltip = undefined;
|
|
423
|
-
break;
|
|
424
|
-
case PromptsStorage.plugin:
|
|
425
|
-
tooltip = promptFile.name;
|
|
426
|
-
break;
|
|
427
|
-
case PromptsStorage.builtIn:
|
|
428
|
-
tooltip = undefined;
|
|
429
|
-
break;
|
|
430
|
-
default:
|
|
431
|
-
assertNever();
|
|
432
|
-
}
|
|
433
|
-
let iconClass;
|
|
434
|
-
if (visibility === false) {
|
|
435
|
-
buttons = (buttons ?? []).concat(MAKE_VISIBLE_BUTTON);
|
|
436
|
-
promptName = ( localize(8973, "{0} (hidden)", promptName));
|
|
437
|
-
tooltip = ( localize(8974, "Hidden from chat view agent picker"));
|
|
438
|
-
} else if (visibility === true) {
|
|
439
|
-
buttons = (buttons ?? []).concat(MAKE_INVISIBLE_BUTTON);
|
|
440
|
-
}
|
|
441
|
-
return {
|
|
442
|
-
id: ( promptFile.uri.toString()),
|
|
443
|
-
type: "item",
|
|
444
|
-
label: promptName,
|
|
445
|
-
description: promptDescription,
|
|
446
|
-
iconClass,
|
|
447
|
-
tooltip,
|
|
448
|
-
promptFileUri: promptFile.uri,
|
|
449
|
-
buttons
|
|
450
|
-
};
|
|
451
|
-
}
|
|
452
|
-
async keepQuickPickOpen(quickPick, work) {
|
|
453
|
-
const previousIgnoreFocusOut = quickPick.ignoreFocusOut;
|
|
454
|
-
quickPick.ignoreFocusOut = true;
|
|
455
|
-
try {
|
|
456
|
-
return await work();
|
|
457
|
-
} finally {
|
|
458
|
-
quickPick.ignoreFocusOut = previousIgnoreFocusOut;
|
|
459
|
-
quickPick.show();
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
async _handleButtonClick(quickPick, context, options) {
|
|
463
|
-
const {
|
|
464
|
-
item,
|
|
465
|
-
button
|
|
466
|
-
} = context;
|
|
467
|
-
if (!isPromptFileItem(item)) {
|
|
468
|
-
if (isHelpButton(button)) {
|
|
469
|
-
await this._openerService.open(button.helpURI);
|
|
470
|
-
return false;
|
|
471
|
-
}
|
|
472
|
-
throw ( new Error(`Unknown button '${JSON.stringify(button)}'.`));
|
|
473
|
-
}
|
|
474
|
-
const value = item.promptFileUri;
|
|
475
|
-
if (button === RUN_IN_CHAT_BUTTON) {
|
|
476
|
-
const commandId = quickPick.keyMods.ctrlCmd === true ? "workbench.action.chat.run-in-new-chat.prompt.current" : "workbench.action.chat.run.prompt.current";
|
|
477
|
-
await this._commandService.executeCommand(commandId, value);
|
|
478
|
-
quickPick.hide();
|
|
479
|
-
return false;
|
|
480
|
-
}
|
|
481
|
-
if (button === EDIT_BUTTON) {
|
|
482
|
-
await this._openerService.open(value);
|
|
483
|
-
return false;
|
|
484
|
-
}
|
|
485
|
-
if (button === RENAME_BUTTON || button === COPY_BUTTON) {
|
|
486
|
-
return await this.keepQuickPickOpen(quickPick, async () => {
|
|
487
|
-
const currentFolder = dirname(value);
|
|
488
|
-
const isMove = button === RENAME_BUTTON && quickPick.keyMods.ctrlCmd;
|
|
489
|
-
const newFolder = await this._instaService.invokeFunction(askForPromptSourceFolder, options.type, currentFolder, isMove);
|
|
490
|
-
if (!newFolder) {
|
|
491
|
-
return false;
|
|
492
|
-
}
|
|
493
|
-
const newName = await this._instaService.invokeFunction(askForPromptFileName, options.type, newFolder.uri, item.label);
|
|
494
|
-
if (!newName) {
|
|
495
|
-
return false;
|
|
496
|
-
}
|
|
497
|
-
const newFile = joinPath(newFolder.uri, newName);
|
|
498
|
-
if (isMove) {
|
|
499
|
-
await this._fileService.move(value, newFile);
|
|
500
|
-
} else {
|
|
501
|
-
await this._fileService.copy(value, newFile);
|
|
502
|
-
}
|
|
503
|
-
await this._openerService.open(newFile);
|
|
504
|
-
await this._instaService.createInstance(PromptFileRewriter).openAndRewriteName(newFile, getCleanPromptName(newFile), CancellationToken.None);
|
|
505
|
-
return true;
|
|
506
|
-
});
|
|
507
|
-
}
|
|
508
|
-
if (button === DELETE_BUTTON) {
|
|
509
|
-
return await this.keepQuickPickOpen(quickPick, async () => {
|
|
510
|
-
const isSkill = options.type === PromptsType.skill;
|
|
511
|
-
const filename = isSkill ? basename(dirname(value)) : item.label;
|
|
512
|
-
const message = isSkill ? ( localize(
|
|
513
|
-
8975,
|
|
514
|
-
"Are you sure you want to delete skill '{0}' and its folder?",
|
|
515
|
-
filename
|
|
516
|
-
)) : ( localize(8976, "Are you sure you want to delete '{0}'?", filename));
|
|
517
|
-
const {
|
|
518
|
-
confirmed
|
|
519
|
-
} = await this._dialogService.confirm({
|
|
520
|
-
message
|
|
521
|
-
});
|
|
522
|
-
if (!confirmed) {
|
|
523
|
-
return false;
|
|
524
|
-
}
|
|
525
|
-
const deleteTarget = isSkill ? dirname(value) : value;
|
|
526
|
-
await this._fileService.del(deleteTarget, {
|
|
527
|
-
recursive: isSkill,
|
|
528
|
-
useTrash: true
|
|
529
|
-
});
|
|
530
|
-
return true;
|
|
531
|
-
});
|
|
532
|
-
}
|
|
533
|
-
if (button === MAKE_VISIBLE_BUTTON || button === MAKE_INVISIBLE_BUTTON) {
|
|
534
|
-
const disabled = this._promptsService.getDisabledPromptFiles(options.type);
|
|
535
|
-
if (button === MAKE_VISIBLE_BUTTON) {
|
|
536
|
-
disabled.delete(value);
|
|
537
|
-
} else {
|
|
538
|
-
disabled.add(value);
|
|
539
|
-
}
|
|
540
|
-
this._promptsService.setDisabledPromptFiles(options.type, disabled);
|
|
541
|
-
return true;
|
|
542
|
-
}
|
|
543
|
-
throw ( new Error(`Unknown button '${JSON.stringify(button)}'.`));
|
|
544
|
-
}
|
|
545
|
-
async managePromptFiles(type, placeholder) {
|
|
546
|
-
const cts = ( new CancellationTokenSource());
|
|
547
|
-
const quickPick = this._quickInputService.createQuickPick({
|
|
548
|
-
useSeparators: true
|
|
549
|
-
});
|
|
550
|
-
quickPick.placeholder = placeholder;
|
|
551
|
-
quickPick.canSelectMany = true;
|
|
552
|
-
quickPick.matchOnDescription = true;
|
|
553
|
-
quickPick.sortByLabel = false;
|
|
554
|
-
quickPick.busy = true;
|
|
555
|
-
const options = {
|
|
556
|
-
placeholder: "",
|
|
557
|
-
type,
|
|
558
|
-
optionNew: true,
|
|
559
|
-
optionEdit: true,
|
|
560
|
-
optionDelete: true,
|
|
561
|
-
optionRename: true,
|
|
562
|
-
optionCopy: true,
|
|
563
|
-
optionVisibility: false,
|
|
564
|
-
optionRun: false
|
|
565
|
-
};
|
|
566
|
-
try {
|
|
567
|
-
const items = await this._createPromptPickItems(options, cts.token);
|
|
568
|
-
quickPick.items = items;
|
|
569
|
-
} finally {
|
|
570
|
-
quickPick.busy = false;
|
|
571
|
-
}
|
|
572
|
-
return ( new Promise(resolve => {
|
|
573
|
-
const disposables = ( new DisposableStore());
|
|
574
|
-
disposables.add(quickPick);
|
|
575
|
-
disposables.add(cts);
|
|
576
|
-
let isClosed = false;
|
|
577
|
-
let isResolved = false;
|
|
578
|
-
const refreshItems = async () => {
|
|
579
|
-
const active = quickPick.activeItems;
|
|
580
|
-
const newItems = await this._createPromptPickItems(options, CancellationToken.None);
|
|
581
|
-
quickPick.items = newItems;
|
|
582
|
-
quickPick.activeItems = active;
|
|
583
|
-
};
|
|
584
|
-
disposables.add(quickPick.onDidAccept(async () => {
|
|
585
|
-
const clickedItem = quickPick.activeItems;
|
|
586
|
-
if (clickedItem.length === 1 && clickedItem[0].commandId) {
|
|
587
|
-
const commandId = clickedItem[0].commandId;
|
|
588
|
-
await this.keepQuickPickOpen(quickPick, async () => {
|
|
589
|
-
await this._commandService.executeCommand(commandId);
|
|
590
|
-
});
|
|
591
|
-
if (!isClosed) {
|
|
592
|
-
await refreshItems();
|
|
593
|
-
}
|
|
594
|
-
return;
|
|
595
|
-
}
|
|
596
|
-
isResolved = true;
|
|
597
|
-
resolve(true);
|
|
598
|
-
quickPick.hide();
|
|
599
|
-
}));
|
|
600
|
-
disposables.add(quickPick.onDidTriggerItemButton(async e => {
|
|
601
|
-
const shouldRefresh = await this._handleButtonClick(quickPick, e, options);
|
|
602
|
-
if (!isClosed && shouldRefresh) {
|
|
603
|
-
await refreshItems();
|
|
604
|
-
}
|
|
605
|
-
}));
|
|
606
|
-
disposables.add(quickPick.onDidHide(() => {
|
|
607
|
-
if (!quickPick.ignoreFocusOut) {
|
|
608
|
-
disposables.dispose();
|
|
609
|
-
isClosed = true;
|
|
610
|
-
if (!isResolved) {
|
|
611
|
-
resolve(false);
|
|
612
|
-
isResolved = true;
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
}));
|
|
616
|
-
quickPick.show();
|
|
617
|
-
}));
|
|
618
|
-
}
|
|
619
|
-
};
|
|
620
|
-
PromptFilePickers = ( __decorate([( __param(0, IQuickInputService)), ( __param(1, IOpenerService)), ( __param(2, IFileService)), ( __param(3, IDialogService)), ( __param(4, ICommandService)), ( __param(5, IInstantiationService)), ( __param(6, IPromptsService)), ( __param(7, ILabelService)), ( __param(8, IProductService))], PromptFilePickers));
|
|
621
|
-
|
|
622
|
-
export { PromptFilePickers };
|