@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.
Files changed (26) hide show
  1. package/empty.js +1 -0
  2. package/package.json +51 -0
  3. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContext.d.ts +25 -0
  4. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContext.js +315 -0
  5. package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.d.ts +49 -0
  6. package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +379 -0
  7. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/attachInstructionsAction.d.ts +17 -0
  8. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/attachInstructionsAction.js +101 -0
  9. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/newPromptFileActions.d.ts +4 -0
  10. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/newPromptFileActions.js +201 -0
  11. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptName.d.ts +7 -0
  12. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptName.js +79 -0
  13. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptSourceFolder.d.ts +8 -0
  14. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptSourceFolder.js +145 -0
  15. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.d.ts +73 -0
  16. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.js +468 -0
  17. package/vscode/src/vs/workbench/contrib/terminal/browser/terminalUri.d.ts +18 -0
  18. package/vscode/src/vs/workbench/contrib/terminal/browser/terminalUri.js +48 -0
  19. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.d.ts +80 -0
  20. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.js +583 -0
  21. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/markNavigationAddon.d.ts +64 -0
  22. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/markNavigationAddon.js +582 -0
  23. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermAddonImporter.d.ts +25 -0
  24. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermAddonImporter.js +43 -0
  25. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.d.ts +187 -0
  26. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.js +867 -0
@@ -0,0 +1,201 @@
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, 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/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 { IChatModeService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatModes.service';
26
+ import Severity from '@codingame/monaco-vscode-api/vscode/vs/base/common/severity';
27
+
28
+ class AbstractNewPromptFileAction extends Action2 {
29
+ constructor(id, title, type) {
30
+ super({
31
+ id,
32
+ title,
33
+ f1: false,
34
+ precondition: ChatContextKeys.enabled,
35
+ category: CHAT_CATEGORY,
36
+ keybinding: {
37
+ weight: KeybindingWeight.WorkbenchContrib
38
+ },
39
+ menu: {
40
+ id: MenuId.CommandPalette,
41
+ when: ChatContextKeys.enabled
42
+ }
43
+ });
44
+ this.type = type;
45
+ }
46
+ async run(accessor) {
47
+ const logService = accessor.get(ILogService);
48
+ const openerService = accessor.get(IOpenerService);
49
+ const commandService = accessor.get(ICommandService);
50
+ const notificationService = accessor.get(INotificationService);
51
+ const userDataSyncEnablementService = accessor.get(IUserDataSyncEnablementService);
52
+ const editorService = accessor.get(IEditorService);
53
+ const fileService = accessor.get(IFileService);
54
+ const instaService = accessor.get(IInstantiationService);
55
+ const chatModeService = accessor.get(IChatModeService);
56
+ const selectedFolder = await instaService.invokeFunction(askForPromptSourceFolder, this.type);
57
+ if (!selectedFolder) {
58
+ return;
59
+ }
60
+ const fileName = await instaService.invokeFunction(askForPromptFileName, this.type, selectedFolder.uri);
61
+ if (!fileName) {
62
+ return;
63
+ }
64
+ await fileService.createFolder(selectedFolder.uri);
65
+ const promptUri = URI.joinPath(selectedFolder.uri, fileName);
66
+ await fileService.createFile(promptUri);
67
+ await openerService.open(promptUri);
68
+ const editor = getCodeEditor(editorService.activeTextEditorControl);
69
+ if (editor && editor.hasModel() && isEqual(editor.getModel().uri, promptUri)) {
70
+ SnippetController2.get(editor)?.apply([{
71
+ range: editor.getModel().getFullModelRange(),
72
+ template: getDefaultContentSnippet(this.type, chatModeService),
73
+ }]);
74
+ }
75
+ if (selectedFolder.storage !== 'user') {
76
+ return;
77
+ }
78
+ const isConfigured = userDataSyncEnablementService
79
+ .isResourceEnablementConfigured(SyncResource.Prompts);
80
+ const isSettingsSyncEnabled = userDataSyncEnablementService.isEnabled();
81
+ if ((isConfigured === true) || (isSettingsSyncEnabled === false)) {
82
+ return;
83
+ }
84
+ notificationService.prompt(Severity.Info, ( localize(
85
+ 5761,
86
+ "Do you want to backup and sync your user prompt, instruction and custom agent files with Setting Sync?'"
87
+ )), [
88
+ {
89
+ label: ( localize(5762, "Enable")),
90
+ run: () => {
91
+ commandService.executeCommand(CONFIGURE_SYNC_COMMAND_ID)
92
+ .catch((error) => {
93
+ logService.error(`Failed to run '${CONFIGURE_SYNC_COMMAND_ID}' command: ${error}.`);
94
+ });
95
+ },
96
+ },
97
+ {
98
+ label: ( localize(5763, "Learn More")),
99
+ run: () => {
100
+ openerService.open(( URI.parse('https://aka.ms/vscode-settings-sync-help')));
101
+ },
102
+ },
103
+ ], {
104
+ neverShowAgain: {
105
+ id: 'workbench.command.prompts.create.user.enable-sync-notification',
106
+ scope: NeverShowAgainScope.PROFILE,
107
+ },
108
+ });
109
+ }
110
+ }
111
+ function getDefaultContentSnippet(promptType, chatModeService) {
112
+ const agents = chatModeService.getModes();
113
+ const agentNames = ( agents.builtin.map(agent => agent.name.get())).join(',') + (agents.custom.length ? (',' + ( agents.custom.map(agent => agent.name.get())).join(',')) : '');
114
+ switch (promptType) {
115
+ case PromptsType.prompt:
116
+ return [
117
+ `---`,
118
+ `agent: \${1|${agentNames}|}`,
119
+ `---`,
120
+ `\${2:Define the task to achieve, including specific requirements, constraints, and success criteria.}`,
121
+ ].join('\n');
122
+ case PromptsType.instructions:
123
+ return [
124
+ `---`,
125
+ `applyTo: '\${1|**,**/*.ts|}'`,
126
+ `---`,
127
+ `\${2:Provide project context and coding guidelines that AI should follow when generating code, answering questions, or reviewing changes.}`,
128
+ ].join('\n');
129
+ case PromptsType.agent:
130
+ return [
131
+ `---`,
132
+ `description: '\${1:Describe what this custom agent does and when to use it.}'`,
133
+ `tools: []`,
134
+ `---`,
135
+ `\${2:Define what this custom agent accomplishes for the user, when to use it, and the edges it won't cross. Specify its ideal inputs/outputs, the tools it may call, and how it reports progress or asks for help.}`,
136
+ ].join('\n');
137
+ default:
138
+ throw ( new Error(`Unknown prompt type: ${promptType}`));
139
+ }
140
+ }
141
+ const NEW_PROMPT_COMMAND_ID = 'workbench.command.new.prompt';
142
+ const NEW_INSTRUCTIONS_COMMAND_ID = 'workbench.command.new.instructions';
143
+ const NEW_AGENT_COMMAND_ID = 'workbench.command.new.agent';
144
+ class NewPromptFileAction extends AbstractNewPromptFileAction {
145
+ constructor() {
146
+ super(NEW_PROMPT_COMMAND_ID, ( localize(5764, "New Prompt File...")), PromptsType.prompt);
147
+ }
148
+ }
149
+ class NewInstructionsFileAction extends AbstractNewPromptFileAction {
150
+ constructor() {
151
+ super(NEW_INSTRUCTIONS_COMMAND_ID, ( localize(5765, "New Instructions File...")), PromptsType.instructions);
152
+ }
153
+ }
154
+ class NewAgentFileAction extends AbstractNewPromptFileAction {
155
+ constructor() {
156
+ super(NEW_AGENT_COMMAND_ID, ( localize(5766, "New Custom Agent...")), PromptsType.agent);
157
+ }
158
+ }
159
+ class NewUntitledPromptFileAction extends Action2 {
160
+ constructor() {
161
+ super({
162
+ id: 'workbench.command.new.untitled.prompt',
163
+ title: ( localize2(5767, "New Untitled Prompt File")),
164
+ f1: true,
165
+ precondition: ChatContextKeys.enabled,
166
+ category: CHAT_CATEGORY,
167
+ keybinding: {
168
+ weight: KeybindingWeight.WorkbenchContrib
169
+ },
170
+ });
171
+ }
172
+ async run(accessor) {
173
+ const editorService = accessor.get(IEditorService);
174
+ const chatModeService = accessor.get(IChatModeService);
175
+ const languageId = getLanguageIdForPromptsType(PromptsType.prompt);
176
+ const input = await editorService.openEditor({
177
+ resource: undefined,
178
+ languageId,
179
+ options: {
180
+ pinned: true
181
+ }
182
+ });
183
+ const type = PromptsType.prompt;
184
+ const editor = getCodeEditor(editorService.activeTextEditorControl);
185
+ if (editor && editor.hasModel()) {
186
+ SnippetController2.get(editor)?.apply([{
187
+ range: editor.getModel().getFullModelRange(),
188
+ template: getDefaultContentSnippet(type, chatModeService),
189
+ }]);
190
+ }
191
+ return input;
192
+ }
193
+ }
194
+ function registerNewPromptFileActions() {
195
+ registerAction2(NewPromptFileAction);
196
+ registerAction2(NewInstructionsFileAction);
197
+ registerAction2(NewAgentFileAction);
198
+ registerAction2(NewUntitledPromptFileAction);
199
+ }
200
+
201
+ export { NEW_AGENT_COMMAND_ID, NEW_INSTRUCTIONS_COMMAND_ID, NEW_PROMPT_COMMAND_ID, registerNewPromptFileActions };
@@ -0,0 +1,7 @@
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): Promise<string | undefined>;
@@ -0,0 +1,79 @@
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) {
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 = getPromptFileExtension(type);
20
+ return (trimmedName.endsWith(fileExtension))
21
+ ? trimmedName
22
+ : `${trimmedName}${fileExtension}`;
23
+ };
24
+ const validateInput = async (value) => {
25
+ const fileName = sanitizeInput(value);
26
+ if (!fileName) {
27
+ return {
28
+ content: ( localize(5768, "Please enter a name.")),
29
+ severity: Severity.Warning
30
+ };
31
+ }
32
+ if (!isValidBasename(fileName)) {
33
+ return {
34
+ content: ( localize(5769, "The name contains invalid characters.")),
35
+ severity: Severity.Error
36
+ };
37
+ }
38
+ const fileUri = URI.joinPath(selectedFolder, fileName);
39
+ if (await fileService.exists(fileUri)) {
40
+ return {
41
+ content: ( localize(5770, "A file for the given name already exists.")),
42
+ severity: Severity.Error
43
+ };
44
+ }
45
+ return undefined;
46
+ };
47
+ const placeHolder = existingFileName ? getPlaceholderStringForRename(type) : getPlaceholderStringForNew(type);
48
+ const result = await quickInputService.input({ placeHolder, validateInput, value: existingFileName });
49
+ if (!result) {
50
+ return undefined;
51
+ }
52
+ return sanitizeInput(result);
53
+ }
54
+ function getPlaceholderStringForNew(type) {
55
+ switch (type) {
56
+ case PromptsType.instructions:
57
+ return localize(5771, "Enter the name of the instructions file");
58
+ case PromptsType.prompt:
59
+ return localize(5772, "Enter the name of the prompt file");
60
+ case PromptsType.agent:
61
+ return localize(5773, "Enter the name of the agent file");
62
+ default:
63
+ throw ( new Error('Unknown prompt type'));
64
+ }
65
+ }
66
+ function getPlaceholderStringForRename(type) {
67
+ switch (type) {
68
+ case PromptsType.instructions:
69
+ return localize(5774, "Enter a new name of the instructions file");
70
+ case PromptsType.prompt:
71
+ return localize(5775, "Enter a new name of the prompt file");
72
+ case PromptsType.agent:
73
+ return localize(5776, "Enter a new name of the agent file");
74
+ default:
75
+ throw ( new Error('Unknown prompt type'));
76
+ }
77
+ }
78
+
79
+ export { askForPromptFileName };
@@ -0,0 +1,8 @@
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>;
@@ -0,0 +1,145 @@
1
+
2
+ import { isEqual, extUri } 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 { ILabelService } from '@codingame/monaco-vscode-api/vscode/vs/platform/label/common/label.service';
6
+ import { IOpenerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/opener/common/opener.service';
7
+ import { PromptsType, PROMPT_DOCUMENTATION_URL } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/promptTypes';
8
+ import { IQuickInputService } from '@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput.service';
9
+ import { IWorkspaceContextService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.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
+
13
+ async function askForPromptSourceFolder(accessor, type, existingFolder, isMove = false) {
14
+ const quickInputService = accessor.get(IQuickInputService);
15
+ const promptsService = accessor.get(IPromptsService);
16
+ const labelService = accessor.get(ILabelService);
17
+ const workspaceService = accessor.get(IWorkspaceContextService);
18
+ const folders = promptsService.getSourceFolders(type);
19
+ if (folders.length === 0) {
20
+ await showNoFoldersDialog(accessor, type);
21
+ return;
22
+ }
23
+ const pickOptions = {
24
+ placeHolder: existingFolder ? getPlaceholderStringforMove(type, isMove) : getPlaceholderStringforNew(type),
25
+ canPickMany: false,
26
+ matchOnDescription: true,
27
+ };
28
+ const foldersList = ( folders.map(folder => {
29
+ const uri = folder.uri;
30
+ const detail = (existingFolder && isEqual(uri, existingFolder)) ? ( localize(5777, "Current Location")) : undefined;
31
+ if (folder.storage !== PromptsStorage.local) {
32
+ return {
33
+ type: 'item',
34
+ label: promptsService.getPromptLocationLabel(folder),
35
+ detail,
36
+ tooltip: labelService.getUriLabel(uri),
37
+ folder
38
+ };
39
+ }
40
+ const { folders } = workspaceService.getWorkspace();
41
+ const isMultirootWorkspace = (folders.length > 1);
42
+ const firstFolder = folders[0];
43
+ if (isMultirootWorkspace || !firstFolder || !extUri.isEqual(firstFolder.uri, uri)) {
44
+ return {
45
+ type: 'item',
46
+ label: labelService.getUriLabel(uri, { relative: true }),
47
+ detail,
48
+ tooltip: labelService.getUriLabel(uri),
49
+ folder,
50
+ };
51
+ }
52
+ return {
53
+ type: 'item',
54
+ label: ( localize(5778, "Current Workspace")),
55
+ detail,
56
+ tooltip: labelService.getUriLabel(uri),
57
+ folder,
58
+ };
59
+ }));
60
+ const answer = await quickInputService.pick(foldersList, pickOptions);
61
+ if (!answer) {
62
+ return;
63
+ }
64
+ return answer.folder;
65
+ }
66
+ function getPlaceholderStringforNew(type) {
67
+ switch (type) {
68
+ case PromptsType.instructions:
69
+ return localize(5779, "Select a location to create the instructions file in...");
70
+ case PromptsType.prompt:
71
+ return localize(5780, "Select a location to create the prompt file in...");
72
+ case PromptsType.agent:
73
+ return localize(5781, "Select a location to create the agent file in...");
74
+ default:
75
+ throw ( new Error('Unknown prompt type'));
76
+ }
77
+ }
78
+ function getPlaceholderStringforMove(type, isMove) {
79
+ if (isMove) {
80
+ switch (type) {
81
+ case PromptsType.instructions:
82
+ return localize(5782, "Select a location to move the instructions file to...");
83
+ case PromptsType.prompt:
84
+ return localize(5783, "Select a location to move the prompt file to...");
85
+ case PromptsType.agent:
86
+ return localize(5784, "Select a location to move the agent file to...");
87
+ default:
88
+ throw ( new Error('Unknown prompt type'));
89
+ }
90
+ }
91
+ switch (type) {
92
+ case PromptsType.instructions:
93
+ return localize(5785, "Select a location to copy the instructions file to...");
94
+ case PromptsType.prompt:
95
+ return localize(5786, "Select a location to copy the prompt file to...");
96
+ case PromptsType.agent:
97
+ return localize(5787, "Select a location to copy the agent file to...");
98
+ default:
99
+ throw ( new Error('Unknown prompt type'));
100
+ }
101
+ }
102
+ async function showNoFoldersDialog(accessor, type) {
103
+ const quickInputService = accessor.get(IQuickInputService);
104
+ const openerService = accessor.get(IOpenerService);
105
+ const docsQuickPick = {
106
+ type: 'item',
107
+ label: getLearnLabel(type),
108
+ description: PROMPT_DOCUMENTATION_URL,
109
+ tooltip: PROMPT_DOCUMENTATION_URL,
110
+ value: ( URI.parse(PROMPT_DOCUMENTATION_URL)),
111
+ };
112
+ const result = await quickInputService.pick([docsQuickPick], {
113
+ placeHolder: getMissingSourceFolderString(type),
114
+ canPickMany: false,
115
+ });
116
+ if (result) {
117
+ await openerService.open(result.value);
118
+ }
119
+ }
120
+ function getLearnLabel(type) {
121
+ switch (type) {
122
+ case PromptsType.prompt:
123
+ return localize(5788, 'Learn how to configure reusable prompts');
124
+ case PromptsType.instructions:
125
+ return localize(5789, 'Learn how to configure reusable instructions');
126
+ case PromptsType.agent:
127
+ return localize(5790, 'Learn how to configure custom agents');
128
+ default:
129
+ throw ( new Error('Unknown prompt type'));
130
+ }
131
+ }
132
+ function getMissingSourceFolderString(type) {
133
+ switch (type) {
134
+ case PromptsType.instructions:
135
+ return localize(5791, 'No instruction source folders found.');
136
+ case PromptsType.prompt:
137
+ return localize(5792, 'No prompt source folders found.');
138
+ case PromptsType.agent:
139
+ return localize(5793, 'No agent source folders found.');
140
+ default:
141
+ throw ( new Error('Unknown prompt type'));
142
+ }
143
+ }
144
+
145
+ export { askForPromptSourceFolder };
@@ -0,0 +1,73 @@
1
+ import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
2
+ import { IPromptsService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.service";
3
+ import { IFileService } from "@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service";
4
+ import { IOpenerService } from "@codingame/monaco-vscode-api/vscode/vs/platform/opener/common/opener.service";
5
+ import { IDialogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/dialogs/common/dialogs.service";
6
+ import { ICommandService } from "@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands.service";
7
+ import { PromptsType } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/promptTypes";
8
+ import { IKeyMods } from "@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput";
9
+ import { IQuickInputService } from "@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput.service";
10
+ import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
11
+ import { ILabelService } from "@codingame/monaco-vscode-api/vscode/vs/platform/label/common/label.service";
12
+ import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
13
+ /**
14
+ * Options for the {@link askToSelectInstructions} function.
15
+ */
16
+ export interface ISelectOptions {
17
+ /**
18
+ * The text shows as placeholder in the selection dialog.
19
+ */
20
+ readonly placeholder: string;
21
+ /**
22
+ * Prompt resource `URI` to attach to the chat input, if any.
23
+ * If provided the resource will be pre-selected in the prompt picker dialog,
24
+ * otherwise the dialog will show the prompts list without any pre-selection.
25
+ */
26
+ readonly resource?: URI;
27
+ readonly type: PromptsType;
28
+ readonly optionNew?: boolean;
29
+ readonly optionEdit?: boolean;
30
+ readonly optionDelete?: boolean;
31
+ readonly optionRename?: boolean;
32
+ readonly optionCopy?: boolean;
33
+ readonly optionVisibility?: boolean;
34
+ }
35
+ export interface ISelectPromptResult {
36
+ /**
37
+ * The selected prompt file.
38
+ */
39
+ readonly promptFile: URI;
40
+ /**
41
+ * The key modifiers that were pressed when the prompt was selected.
42
+ */
43
+ readonly keyMods: IKeyMods;
44
+ }
45
+ export declare class PromptFilePickers {
46
+ private readonly _quickInputService;
47
+ private readonly _openerService;
48
+ private readonly _fileService;
49
+ private readonly _dialogService;
50
+ private readonly _commandService;
51
+ private readonly _instaService;
52
+ private readonly _promptsService;
53
+ private readonly _labelService;
54
+ private readonly _configurationService;
55
+ constructor(_quickInputService: IQuickInputService, _openerService: IOpenerService, _fileService: IFileService, _dialogService: IDialogService, _commandService: ICommandService, _instaService: IInstantiationService, _promptsService: IPromptsService, _labelService: ILabelService, _configurationService: IConfigurationService);
56
+ /**
57
+ * Shows the prompt file selection dialog to the user that allows to run a prompt file(s).
58
+ *
59
+ * If {@link ISelectOptions.resource resource} is provided, the dialog will have
60
+ * the resource pre-selected in the prompts list.
61
+ */
62
+ selectPromptFile(options: ISelectOptions): Promise<ISelectPromptResult | undefined>;
63
+ private _createPromptPickItems;
64
+ private _getNewItems;
65
+ private _createPromptPickItem;
66
+ private keepQuickPickOpen;
67
+ private _handleButtonClick;
68
+ /**
69
+ * Shows a multi-select (checkbox) quick pick to configure which prompt files of the given
70
+ * type are enabled. Currently only used for agent prompt files.
71
+ */
72
+ managePromptFiles(type: PromptsType, placeholder: string): Promise<boolean>;
73
+ }