@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.
Files changed (29) hide show
  1. package/package.json +2 -2
  2. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.d.ts +1 -1
  3. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.js +3 -3
  4. package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/terminalStickyScrollOverlay.d.ts +58 -0
  5. package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/terminalStickyScrollOverlay.js +462 -0
  6. package/vscode/src/vs/base/browser/htmlToMarkdown.d.ts +0 -1
  7. package/vscode/src/vs/base/browser/htmlToMarkdown.js +0 -144
  8. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContext.d.ts +0 -59
  9. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContext.js +0 -482
  10. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/attachInstructionsAction.d.ts +0 -25
  11. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/attachInstructionsAction.js +0 -95
  12. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/newPromptFileActions.d.ts +0 -24
  13. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/newPromptFileActions.js +0 -355
  14. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptName.d.ts +0 -7
  15. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptName.js +0 -81
  16. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptSourceFolder.d.ts +0 -15
  17. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptSourceFolder.js +0 -181
  18. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.d.ts +0 -75
  19. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.js +0 -622
  20. package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/editor/chatPasteProviders.d.ts +0 -71
  21. package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/editor/chatPasteProviders.js +0 -800
  22. package/vscode/src/vs/workbench/contrib/git/common/utils.d.ts +0 -8
  23. package/vscode/src/vs/workbench/contrib/git/common/utils.js +0 -105
  24. package/vscode/src/vs/workbench/contrib/terminal/browser/terminalUri.d.ts +0 -18
  25. package/vscode/src/vs/workbench/contrib/terminal/browser/terminalUri.js +0 -51
  26. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.d.ts +0 -79
  27. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.js +0 -652
  28. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/markNavigationAddon.d.ts +0 -64
  29. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/markNavigationAddon.js +0 -564
@@ -1,355 +0,0 @@
1
-
2
- import { isEqual } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
3
- import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
4
- import { getCodeEditor } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorBrowser';
5
- import { SnippetController2 } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/snippet/browser/snippetController2';
6
- import { localize, localize2 } from '@codingame/monaco-vscode-api/vscode/vs/nls';
7
- import { Action2, MenuId, registerAction2 } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
8
- import { ICommandService } from '@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands.service';
9
- import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
10
- import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
11
- import { KeybindingWeight } from '@codingame/monaco-vscode-api/vscode/vs/platform/keybinding/common/keybindingsRegistry';
12
- import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
13
- import { NeverShowAgainScope } from '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification';
14
- import { INotificationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification.service';
15
- import { IOpenerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/opener/common/opener.service';
16
- import { PromptsType, Target, getLanguageIdForPromptsType } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/promptTypes';
17
- import { SyncResource } from '@codingame/monaco-vscode-api/vscode/vs/platform/userDataSync/common/userDataSync';
18
- import { IUserDataSyncEnablementService } from '@codingame/monaco-vscode-api/vscode/vs/platform/userDataSync/common/userDataSync.service';
19
- import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
20
- import { CONFIGURE_SYNC_COMMAND_ID } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/userDataSync/common/userDataSync';
21
- import { ChatContextKeys } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/actions/chatContextKeys';
22
- import { CHAT_CATEGORY } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
23
- import { askForPromptFileName } from './pickers/askForPromptName.js';
24
- import { askForPromptSourceFolder } from './pickers/askForPromptSourceFolder.js';
25
- import { IQuickInputService } from '@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput.service';
26
- import { getCleanPromptName, VALID_SKILL_NAME_REGEX, SKILL_FILENAME } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/config/promptFileLocations';
27
- import { PromptsStorage } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService';
28
- import { getTarget } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptFileAttributes';
29
- import Severity from '@codingame/monaco-vscode-api/vscode/vs/base/common/severity';
30
-
31
- class AbstractNewPromptFileAction extends Action2 {
32
- constructor(id, title, type) {
33
- super({
34
- id,
35
- title,
36
- f1: false,
37
- precondition: ChatContextKeys.enabled,
38
- category: CHAT_CATEGORY,
39
- keybinding: {
40
- weight: KeybindingWeight.WorkbenchContrib
41
- },
42
- menu: {
43
- id: MenuId.CommandPalette,
44
- when: ChatContextKeys.enabled
45
- }
46
- });
47
- this.type = type;
48
- }
49
- async run(accessor, options) {
50
- const logService = accessor.get(ILogService);
51
- const openerService = accessor.get(IOpenerService);
52
- const commandService = accessor.get(ICommandService);
53
- const notificationService = accessor.get(INotificationService);
54
- const userDataSyncEnablementService = accessor.get(IUserDataSyncEnablementService);
55
- const editorService = accessor.get(IEditorService);
56
- const fileService = accessor.get(IFileService);
57
- const instaService = accessor.get(IInstantiationService);
58
- let folderUri;
59
- let storage;
60
- if (options?.targetFolder) {
61
- folderUri = options.targetFolder;
62
- storage = options.targetStorage ?? PromptsStorage.local;
63
- } else {
64
- const selectedFolder = await instaService.invokeFunction(askForPromptSourceFolder, this.type);
65
- if (!selectedFolder) {
66
- return;
67
- }
68
- folderUri = selectedFolder.uri;
69
- storage = selectedFolder.storage;
70
- }
71
- const fileName = await instaService.invokeFunction(
72
- askForPromptFileName,
73
- this.type,
74
- folderUri,
75
- undefined,
76
- options?.fileExtension
77
- );
78
- if (!fileName) {
79
- return;
80
- }
81
- await fileService.createFolder(folderUri);
82
- const promptUri = URI.joinPath(folderUri, fileName);
83
- await fileService.createFile(promptUri);
84
- const cleanName = getCleanPromptName(promptUri);
85
- let editor;
86
- if (options?.openFile) {
87
- editor = await options.openFile(promptUri);
88
- } else {
89
- await openerService.open(promptUri);
90
- editor = getCodeEditor(editorService.activeTextEditorControl);
91
- }
92
- if (editor && editor.hasModel() && isEqual(editor.getModel().uri, promptUri)) {
93
- SnippetController2.get(editor)?.apply([{
94
- range: editor.getModel().getFullModelRange(),
95
- template: getDefaultContentSnippet(this.type, cleanName, getTarget(this.type, promptUri))
96
- }]);
97
- }
98
- if (storage !== "user") {
99
- return;
100
- }
101
- const isConfigured = userDataSyncEnablementService.isResourceEnablementConfigured(SyncResource.Prompts);
102
- const isSettingsSyncEnabled = userDataSyncEnablementService.isEnabled();
103
- if ((isConfigured === true) || (isSettingsSyncEnabled === false)) {
104
- return;
105
- }
106
- notificationService.prompt(Severity.Info, ( localize(
107
- 8896,
108
- "Do you want to backup and sync your user prompt, instruction and custom agent files with Setting Sync?'"
109
- )), [{
110
- label: ( localize(8897, "Enable")),
111
- run: () => {
112
- commandService.executeCommand(CONFIGURE_SYNC_COMMAND_ID).catch(error => {
113
- logService.error(`Failed to run '${CONFIGURE_SYNC_COMMAND_ID}' command: ${error}.`);
114
- });
115
- }
116
- }, {
117
- label: ( localize(8898, "Learn More")),
118
- run: () => {
119
- openerService.open(( URI.parse("https://aka.ms/vscode-settings-sync-help")));
120
- }
121
- }], {
122
- neverShowAgain: {
123
- id: "workbench.command.prompts.create.user.enable-sync-notification",
124
- scope: NeverShowAgainScope.PROFILE
125
- }
126
- });
127
- }
128
- }
129
- function getDefaultContentSnippet(promptType, name, target) {
130
- switch (promptType) {
131
- case PromptsType.prompt:
132
- return [
133
- `---`,
134
- `name: ${name ?? "${1:prompt-name}"}`,
135
- `description: \${2:Describe when to use this prompt}`,
136
- `---`,
137
- ``,
138
- `<!-- Tip: Use /create-prompt in chat to generate content with agent assistance -->`,
139
- ``,
140
- `\${3:Define the prompt content here. You can include instructions, examples, and any other relevant information to guide the AI's responses.}`
141
- ].join("\n");
142
- case PromptsType.instructions:
143
- if (target === Target.Claude) {
144
- return [
145
- `---`,
146
- `description: \${1:Describe when these instructions should be loaded}`,
147
- `paths:`,
148
- `. - "src/**/*.ts"`,
149
- `---`,
150
- ``,
151
- `<!-- Tip: Use /create-instructions in chat to generate content with agent assistance -->`,
152
- ``,
153
- `\${2:Provide coding guidelines that AI should follow when generating code, answering questions, or reviewing changes.}`
154
- ].join("\n");
155
- } else {
156
- return [
157
- `---`,
158
- `description: \${1:Describe when these instructions should be loaded by the agent based on task context}`,
159
- `# applyTo: '\${1|**,**/*.ts|}' # when provided, instructions will automatically be added to the request context when the pattern matches an attached file`,
160
- `---`,
161
- ``,
162
- `<!-- Tip: Use /create-instructions in chat to generate content with agent assistance -->`,
163
- ``,
164
- `\${2:Provide project context and coding guidelines that AI should follow when generating code, answering questions, or reviewing changes.}`
165
- ].join("\n");
166
- }
167
- case PromptsType.agent:
168
- if (target === Target.Claude) {
169
- return [
170
- `---`,
171
- `name: ${name ?? "${1:agent-name}"}`,
172
- `description: \${2:Describe what this custom agent does and when to use it.}`,
173
- `tools: Read, Grep, Glob, Bash # specify the tools this agent can use. If not set, all enabled tools are allowed.`,
174
- `---`,
175
- ``,
176
- `<!-- Tip: Use /create-agent in chat to generate content with agent assistance -->`,
177
- ``,
178
- `\${4:Define what this custom agent does, including its behavior, capabilities, and any specific instructions for its operation.}`
179
- ].join("\n");
180
- } else {
181
- return [
182
- `---`,
183
- `name: ${name ?? "${1:agent-name}"}`,
184
- `description: \${2:Describe what this custom agent does and when to use it.}`,
185
- `argument-hint: \${3:The inputs this agent expects, e.g., "a task to implement" or "a question to answer".}`,
186
- `# tools: ['vscode', 'execute', 'read', 'agent', 'edit', 'search', 'web', 'todo'] # specify the tools this agent can use. If not set, all enabled tools are allowed.`,
187
- `---`,
188
- ``,
189
- `<!-- Tip: Use /create-agent in chat to generate content with agent assistance -->`,
190
- ``,
191
- `\${4:Define what this custom agent does, including its behavior, capabilities, and any specific instructions for its operation.}`
192
- ].join("\n");
193
- }
194
- case PromptsType.skill:
195
- return [
196
- `---`,
197
- `name: ${name ?? "${1:skill-name}"}`,
198
- `description: \${2:Describe what this skill does and when to use it. Include keywords that help agents identify relevant tasks.}`,
199
- `---`,
200
- ``,
201
- `<!-- Tip: Use /create-skill in chat to generate content with agent assistance -->`,
202
- ``,
203
- `\${3:Define the functionality provided by this skill, including detailed instructions and examples}`
204
- ].join("\n");
205
- default:
206
- throw ( new Error(`Unsupported prompt type: ${promptType}`));
207
- }
208
- }
209
- const NEW_PROMPT_COMMAND_ID = "workbench.command.new.prompt";
210
- const NEW_INSTRUCTIONS_COMMAND_ID = "workbench.command.new.instructions";
211
- const NEW_AGENT_COMMAND_ID = "workbench.command.new.agent";
212
- const NEW_SKILL_COMMAND_ID = "workbench.command.new.skill";
213
- class NewPromptFileAction extends AbstractNewPromptFileAction {
214
- constructor() {
215
- super(NEW_PROMPT_COMMAND_ID, ( localize(8899, "New Prompt File...")), PromptsType.prompt);
216
- }
217
- }
218
- class NewInstructionsFileAction extends AbstractNewPromptFileAction {
219
- constructor() {
220
- super(NEW_INSTRUCTIONS_COMMAND_ID, ( localize(8900, "New Instructions File...")), PromptsType.instructions);
221
- }
222
- }
223
- class NewAgentFileAction extends AbstractNewPromptFileAction {
224
- constructor() {
225
- super(NEW_AGENT_COMMAND_ID, ( localize(8901, "New Custom Agent...")), PromptsType.agent);
226
- }
227
- }
228
- class NewSkillFileAction extends Action2 {
229
- constructor() {
230
- super({
231
- id: NEW_SKILL_COMMAND_ID,
232
- title: ( localize(8902, "New Skill File...")),
233
- f1: false,
234
- precondition: ChatContextKeys.enabled,
235
- category: CHAT_CATEGORY,
236
- keybinding: {
237
- weight: KeybindingWeight.WorkbenchContrib
238
- },
239
- menu: {
240
- id: MenuId.CommandPalette,
241
- when: ChatContextKeys.enabled
242
- }
243
- });
244
- }
245
- async run(accessor, options) {
246
- const openerService = accessor.get(IOpenerService);
247
- const editorService = accessor.get(IEditorService);
248
- const fileService = accessor.get(IFileService);
249
- const instaService = accessor.get(IInstantiationService);
250
- const quickInputService = accessor.get(IQuickInputService);
251
- let folderUri;
252
- if (options?.targetFolder) {
253
- folderUri = options.targetFolder;
254
- } else {
255
- const selectedFolder = await instaService.invokeFunction(askForPromptSourceFolder, PromptsType.skill);
256
- if (!selectedFolder) {
257
- return;
258
- }
259
- folderUri = selectedFolder.uri;
260
- }
261
- const skillName = await quickInputService.input({
262
- prompt: ( localize(
263
- 8903,
264
- "Enter a name for the skill (lowercase letters, numbers, and hyphens only)"
265
- )),
266
- placeHolder: ( localize(8904, "e.g., pdf-processing, data-analysis")),
267
- validateInput: async value => {
268
- if (!value || !value.trim()) {
269
- return localize(8905, "Skill name is required");
270
- }
271
- const name = value.trim();
272
- if (name.length > 64) {
273
- return localize(8906, "Skill name must be 64 characters or less");
274
- }
275
- if (!VALID_SKILL_NAME_REGEX.test(name)) {
276
- return localize(
277
- 8907,
278
- "Skill name may only contain lowercase letters, numbers, and hyphens"
279
- );
280
- }
281
- if (name.startsWith("-") || name.endsWith("-")) {
282
- return localize(8908, "Skill name must not start or end with a hyphen");
283
- }
284
- if (name.includes("--")) {
285
- return localize(8909, "Skill name must not contain consecutive hyphens");
286
- }
287
- return undefined;
288
- }
289
- });
290
- if (!skillName) {
291
- return;
292
- }
293
- const trimmedName = skillName.trim();
294
- const skillFolder = URI.joinPath(folderUri, trimmedName);
295
- await fileService.createFolder(skillFolder);
296
- const skillFileUri = URI.joinPath(skillFolder, SKILL_FILENAME);
297
- await fileService.createFile(skillFileUri);
298
- let editor;
299
- if (options?.openFile) {
300
- editor = await options.openFile(skillFileUri);
301
- } else {
302
- await openerService.open(skillFileUri);
303
- editor = getCodeEditor(editorService.activeTextEditorControl);
304
- }
305
- if (editor && editor.hasModel() && isEqual(editor.getModel().uri, skillFileUri)) {
306
- SnippetController2.get(editor)?.apply([{
307
- range: editor.getModel().getFullModelRange(),
308
- template: getDefaultContentSnippet(PromptsType.skill, trimmedName, Target.Undefined)
309
- }]);
310
- }
311
- }
312
- }
313
- class NewUntitledPromptFileAction extends Action2 {
314
- constructor() {
315
- super({
316
- id: "workbench.command.new.untitled.prompt",
317
- title: ( localize2(8910, "New Untitled Prompt File")),
318
- f1: true,
319
- precondition: ChatContextKeys.enabled,
320
- category: CHAT_CATEGORY,
321
- keybinding: {
322
- weight: KeybindingWeight.WorkbenchContrib
323
- }
324
- });
325
- }
326
- async run(accessor) {
327
- const editorService = accessor.get(IEditorService);
328
- const languageId = getLanguageIdForPromptsType(PromptsType.prompt);
329
- const input = await editorService.openEditor({
330
- resource: undefined,
331
- languageId,
332
- options: {
333
- pinned: true
334
- }
335
- });
336
- const type = PromptsType.prompt;
337
- const editor = getCodeEditor(editorService.activeTextEditorControl);
338
- if (editor && editor.hasModel()) {
339
- SnippetController2.get(editor)?.apply([{
340
- range: editor.getModel().getFullModelRange(),
341
- template: getDefaultContentSnippet(type, undefined, Target.Undefined)
342
- }]);
343
- }
344
- return input;
345
- }
346
- }
347
- function registerNewPromptFileActions() {
348
- registerAction2(NewPromptFileAction);
349
- registerAction2(NewInstructionsFileAction);
350
- registerAction2(NewAgentFileAction);
351
- registerAction2(NewSkillFileAction);
352
- registerAction2(NewUntitledPromptFileAction);
353
- }
354
-
355
- export { NEW_AGENT_COMMAND_ID, NEW_INSTRUCTIONS_COMMAND_ID, NEW_PROMPT_COMMAND_ID, NEW_SKILL_COMMAND_ID, registerNewPromptFileActions };
@@ -1,7 +0,0 @@
1
- import { PromptsType } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/promptTypes";
2
- import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
3
- import { ServicesAccessor } from "@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorExtensions";
4
- /**
5
- * Asks the user for a file name.
6
- */
7
- export declare function askForPromptFileName(accessor: ServicesAccessor, type: PromptsType, selectedFolder: URI, existingFileName?: string, fileExtensionOverride?: string): Promise<string | undefined>;
@@ -1,81 +0,0 @@
1
-
2
- import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
3
- import { getPromptFileExtension } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/config/promptFileLocations';
4
- import { PromptsType } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/promptTypes';
5
- import { IQuickInputService } from '@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput.service';
6
- import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
7
- import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
8
- import Severity from '@codingame/monaco-vscode-api/vscode/vs/base/common/severity';
9
- import { isValidBasename } from '@codingame/monaco-vscode-api/vscode/vs/base/common/extpath';
10
-
11
- async function askForPromptFileName(accessor, type, selectedFolder, existingFileName, fileExtensionOverride) {
12
- const quickInputService = accessor.get(IQuickInputService);
13
- const fileService = accessor.get(IFileService);
14
- const sanitizeInput = input => {
15
- const trimmedName = input.trim();
16
- if (!trimmedName) {
17
- return undefined;
18
- }
19
- const fileExtension = fileExtensionOverride ?? getPromptFileExtension(type);
20
- return (trimmedName.endsWith(fileExtension)) ? trimmedName : `${trimmedName}${fileExtension}`;
21
- };
22
- const validateInput = async value => {
23
- const fileName = sanitizeInput(value);
24
- if (!fileName) {
25
- return {
26
- content: ( localize(8911, "Please enter a name.")),
27
- severity: Severity.Warning
28
- };
29
- }
30
- if (!isValidBasename(fileName)) {
31
- return {
32
- content: ( localize(8912, "The name contains invalid characters.")),
33
- severity: Severity.Error
34
- };
35
- }
36
- const fileUri = URI.joinPath(selectedFolder, fileName);
37
- if (await fileService.exists(fileUri)) {
38
- return {
39
- content: ( localize(8913, "A file for the given name already exists.")),
40
- severity: Severity.Error
41
- };
42
- }
43
- return undefined;
44
- };
45
- const placeHolder = existingFileName ? getPlaceholderStringForRename(type) : getPlaceholderStringForNew(type);
46
- const result = await quickInputService.input({
47
- placeHolder,
48
- validateInput,
49
- value: existingFileName
50
- });
51
- if (!result) {
52
- return undefined;
53
- }
54
- return sanitizeInput(result);
55
- }
56
- function getPlaceholderStringForNew(type) {
57
- switch (type) {
58
- case PromptsType.instructions:
59
- return localize(8914, "Enter the name of the instructions file");
60
- case PromptsType.prompt:
61
- return localize(8915, "Enter the name of the prompt file");
62
- case PromptsType.agent:
63
- return localize(8916, "Enter the name of the agent file");
64
- default:
65
- throw ( new Error("Unknown prompt type"));
66
- }
67
- }
68
- function getPlaceholderStringForRename(type) {
69
- switch (type) {
70
- case PromptsType.instructions:
71
- return localize(8917, "Enter a new name of the instructions file");
72
- case PromptsType.prompt:
73
- return localize(8918, "Enter a new name of the prompt file");
74
- case PromptsType.agent:
75
- return localize(8919, "Enter a new name of the agent file");
76
- default:
77
- throw ( new Error("Unknown prompt type"));
78
- }
79
- }
80
-
81
- export { askForPromptFileName };
@@ -1,15 +0,0 @@
1
- import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
2
- import { ServicesAccessor } from "@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorExtensions";
3
- import { PromptsType } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/promptTypes";
4
- import { IPromptPath } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService";
5
- /**
6
- * Asks the user for a specific prompt folder, if multiple folders provided.
7
- */
8
- export declare function askForPromptSourceFolder(accessor: ServicesAccessor, type: PromptsType, existingFolder?: URI | undefined, isMove?: boolean): Promise<IPromptPath | undefined>;
9
- /**
10
- * Shows a dialog to the user when no prompt source folders are found.
11
- *
12
- * Note! this is a temporary solution and must be replaced with a dialog to select
13
- * a custom folder path, or switch to a different prompt type
14
- */
15
- export declare function showNoFoldersDialog(accessor: ServicesAccessor, type: PromptsType): Promise<void>;
@@ -1,181 +0,0 @@
1
-
2
- import { isEqual } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
3
- import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
4
- import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
5
- import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
6
- import { ILabelService } from '@codingame/monaco-vscode-api/vscode/vs/platform/label/common/label.service';
7
- import { IOpenerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/opener/common/opener.service';
8
- import { getSourceDescription, PromptsType, getDocumentationUrl } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/promptTypes';
9
- import { IQuickInputService } from '@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput.service';
10
- import { PromptsStorage } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService';
11
- import { IPromptsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.service';
12
- import { IWorkspaceContextService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service';
13
-
14
- async function askForPromptSourceFolder(accessor, type, existingFolder, isMove = false) {
15
- const instantiationService = accessor.get(IInstantiationService);
16
- const quickInputService = accessor.get(IQuickInputService);
17
- const promptsService = accessor.get(IPromptsService);
18
- const labelService = accessor.get(ILabelService);
19
- const workspaceService = accessor.get(IWorkspaceContextService);
20
- const resolvedFolders = await promptsService.getResolvedSourceFolders(type);
21
- if (resolvedFolders.length === 0) {
22
- await instantiationService.invokeFunction(accessor => showNoFoldersDialog(accessor, type));
23
- return;
24
- }
25
- const pickOptions = {
26
- placeHolder: existingFolder ? getPlaceholderStringforMove(type, isMove) : getPlaceholderStringforNew(type),
27
- canPickMany: false,
28
- matchOnDescription: true
29
- };
30
- const defaultFolder = !existingFolder ? resolvedFolders[0] : undefined;
31
- const {
32
- folders: workspaceFolders
33
- } = workspaceService.getWorkspace();
34
- const isMultiRoot = workspaceFolders.length > 1;
35
- const foldersList = ( resolvedFolders.map(resolved => {
36
- const folderUri = resolved.searchRoot;
37
- const isDefault = defaultFolder && isEqual(folderUri, defaultFolder.searchRoot);
38
- const sourceDescription = getSourceDescription(resolved.source);
39
- const detail = (existingFolder && isEqual(folderUri, existingFolder)) ? ( localize(8920, "Current Location")) : undefined;
40
- const basePath = (isMultiRoot && resolved.storage === PromptsStorage.local) ? labelService.getUriLabel(folderUri, {
41
- relative: true
42
- }) : resolved.displayPath ?? labelService.getUriLabel(folderUri, {
43
- relative: resolved.storage === PromptsStorage.local
44
- });
45
- const label = isDefault ? ( localize(8921, "{0} (default)", basePath)) : basePath;
46
- const folder = {
47
- uri: folderUri,
48
- storage: resolved.storage,
49
- type
50
- };
51
- return {
52
- type: "item",
53
- label,
54
- description: sourceDescription,
55
- detail,
56
- tooltip: labelService.getUriLabel(folderUri),
57
- picked: isDefault,
58
- folder
59
- };
60
- }));
61
- if (isMultiRoot) {
62
- const getWorkspaceFolderIndex = (uri, storage) => {
63
- if (storage !== PromptsStorage.local) {
64
- return workspaceFolders.length;
65
- }
66
- const wsFolder = workspaceService.getWorkspaceFolder(uri);
67
- return wsFolder?.index ?? workspaceFolders.length;
68
- };
69
- foldersList.sort((a, b) => {
70
- const aIndex = getWorkspaceFolderIndex(a.folder.uri, a.folder.storage);
71
- const bIndex = getWorkspaceFolderIndex(b.folder.uri, b.folder.storage);
72
- return aIndex - bIndex;
73
- });
74
- }
75
- const answer = await quickInputService.pick(foldersList, pickOptions);
76
- if (!answer) {
77
- return;
78
- }
79
- return answer.folder;
80
- }
81
- function getPlaceholderStringforNew(type) {
82
- switch (type) {
83
- case PromptsType.instructions:
84
- return localize(8922, "Select a location to create the instructions file");
85
- case PromptsType.prompt:
86
- return localize(8923, "Select a location to create the prompt file");
87
- case PromptsType.agent:
88
- return localize(8924, "Select a location to create the agent file");
89
- case PromptsType.skill:
90
- return localize(8925, "Select a location to create the skill");
91
- case PromptsType.hook:
92
- return localize(8926, "Select a location to create the hook file");
93
- default:
94
- throw ( new Error("Unknown prompt type"));
95
- }
96
- }
97
- function getPlaceholderStringforMove(type, isMove) {
98
- if (isMove) {
99
- switch (type) {
100
- case PromptsType.instructions:
101
- return localize(8927, "Select a location to move the instructions file to");
102
- case PromptsType.prompt:
103
- return localize(8928, "Select a location to move the prompt file to");
104
- case PromptsType.agent:
105
- return localize(8929, "Select a location to move the agent file to");
106
- case PromptsType.skill:
107
- return localize(8930, "Select a location to move the skill to");
108
- case PromptsType.hook:
109
- throw ( new Error("Hooks cannot be moved"));
110
- default:
111
- throw ( new Error("Unknown prompt type"));
112
- }
113
- }
114
- switch (type) {
115
- case PromptsType.instructions:
116
- return localize(8931, "Select a location to copy the instructions file to");
117
- case PromptsType.prompt:
118
- return localize(8932, "Select a location to copy the prompt file to");
119
- case PromptsType.agent:
120
- return localize(8933, "Select a location to copy the agent file to");
121
- case PromptsType.skill:
122
- return localize(8934, "Select a location to copy the skill to");
123
- case PromptsType.hook:
124
- throw ( new Error("Hooks cannot be copied"));
125
- default:
126
- throw ( new Error("Unknown prompt type"));
127
- }
128
- }
129
- async function showNoFoldersDialog(accessor, type) {
130
- const quickInputService = accessor.get(IQuickInputService);
131
- const openerService = accessor.get(IOpenerService);
132
- const documentationUrl = getDocumentationUrl(type);
133
- const docsQuickPick = {
134
- type: "item",
135
- label: getLearnLabel(type),
136
- description: documentationUrl,
137
- tooltip: documentationUrl,
138
- value: ( URI.parse(documentationUrl))
139
- };
140
- const result = await quickInputService.pick([docsQuickPick], {
141
- placeHolder: getMissingSourceFolderString(type),
142
- canPickMany: false
143
- });
144
- if (result) {
145
- await openerService.open(result.value);
146
- }
147
- }
148
- function getLearnLabel(type) {
149
- switch (type) {
150
- case PromptsType.prompt:
151
- return localize(8935, "Learn how to configure reusable prompts");
152
- case PromptsType.instructions:
153
- return localize(8936, "Learn how to configure reusable instructions");
154
- case PromptsType.agent:
155
- return localize(8937, "Learn how to configure custom agents");
156
- case PromptsType.skill:
157
- return localize(8938, "Learn how to configure skills");
158
- case PromptsType.hook:
159
- return localize(8939, "Learn how to configure hooks");
160
- default:
161
- throw ( new Error("Unknown prompt type"));
162
- }
163
- }
164
- function getMissingSourceFolderString(type) {
165
- switch (type) {
166
- case PromptsType.instructions:
167
- return localize(8940, "No instruction source folders found.");
168
- case PromptsType.prompt:
169
- return localize(8941, "No prompt source folders found.");
170
- case PromptsType.agent:
171
- return localize(8942, "No agent source folders found.");
172
- case PromptsType.skill:
173
- return localize(8943, "No skill source folders found.");
174
- case PromptsType.hook:
175
- return localize(8944, "No hook source folders found.");
176
- default:
177
- throw ( new Error("Unknown prompt type"));
178
- }
179
- }
180
-
181
- export { askForPromptSourceFolder, showNoFoldersDialog };