Skip to content

Commit 45e90b9

Browse files
aeschlilszomoru
authored andcommitted
Merge pull request #252797 from microsoft/aeschli/rational-eel-863
prompt files: avoid using snippets
2 parents 2601f92 + d8b8dbc commit 45e90b9

File tree

5 files changed

+32
-64
lines changed

5 files changed

+32
-64
lines changed

extensions/prompt-basics/package.json

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -112,21 +112,7 @@
112112
"other": "off"
113113
}
114114
}
115-
},
116-
"snippets": [
117-
{
118-
"language": "prompt",
119-
"path": "./snippets/prompt.code-snippets"
120-
},
121-
{
122-
"language": "instructions",
123-
"path": "./snippets/instructions.code-snippets"
124-
},
125-
{
126-
"language": "chatmode",
127-
"path": "./snippets/chatmode.code-snippets"
128-
}
129-
]
115+
}
130116
},
131117
"scripts": {},
132118
"repository": {

extensions/prompt-basics/snippets/chatmode.code-snippets

Lines changed: 0 additions & 13 deletions
This file was deleted.

extensions/prompt-basics/snippets/instructions.code-snippets

Lines changed: 0 additions & 13 deletions
This file was deleted.

extensions/prompt-basics/snippets/prompt.code-snippets

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/vs/workbench/contrib/chat/browser/promptSyntax/newPromptFileActions.ts

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ class AbstractNewPromptFileAction extends Action2 {
5454
const commandService = accessor.get(ICommandService);
5555
const notificationService = accessor.get(INotificationService);
5656
const userDataSyncEnablementService = accessor.get(IUserDataSyncEnablementService);
57-
const snippetService = accessor.get(ISnippetsService);
5857
const editorService = accessor.get(IEditorService);
5958
const fileService = accessor.get(IFileService);
6059
const instaService = accessor.get(IInstantiationService);
@@ -80,15 +79,10 @@ class AbstractNewPromptFileAction extends Action2 {
8079

8180
const editor = getCodeEditor(editorService.activeTextEditorControl);
8281
if (editor && editor.hasModel() && isEqual(editor.getModel().uri, promptUri)) {
83-
const languageId = getLanguageIdForPromptsType(this.type);
84-
85-
const snippets = await snippetService.getSnippets(languageId, { fileTemplateSnippets: true, noRecencySort: true, includeNoPrefixSnippets: true });
86-
if (snippets.length > 0) {
87-
SnippetController2.get(editor)?.apply([{
88-
range: editor.getModel().getFullModelRange(),
89-
template: snippets[0].body
90-
}]);
91-
}
82+
SnippetController2.get(editor)?.apply([{
83+
range: editor.getModel().getFullModelRange(),
84+
template: getDefaultContentSnippet(this.type),
85+
}]);
9286
}
9387

9488
if (selectedFolder.storage !== 'user') {
@@ -145,6 +139,33 @@ class AbstractNewPromptFileAction extends Action2 {
145139
}
146140
}
147141

142+
function getDefaultContentSnippet(promptType: PromptsType): string {
143+
switch (promptType) {
144+
case PromptsType.prompt:
145+
return [
146+
`---`,
147+
`mode: \${1|ask,edit,agent|}`,
148+
`---`,
149+
`\${2:Expected output and any relevant constraints for this task.}`,
150+
].join('\n');
151+
case PromptsType.instructions:
152+
return [
153+
`---`,
154+
`applyTo: '\${1|**,**/*.ts|}'`,
155+
`---`,
156+
`\${2:Coding standards, domain knowledge, and preferences that AI should follow.}`,
157+
].join('\n');
158+
case PromptsType.mode:
159+
return [
160+
`---`,
161+
`description: '\${1:Description of the custom chat mode.}'`,
162+
`tools: [ '\${2:tool1}', '\${3:tool2}' ]`,
163+
`---`,
164+
].join('\n');
165+
default:
166+
throw new Error(`Unknown prompt type: ${promptType}`);
167+
}
168+
}
148169

149170
export const NEW_PROMPT_COMMAND_ID = 'workbench.command.new.prompt';
150171
export const NEW_INSTRUCTIONS_COMMAND_ID = 'workbench.command.new.instructions';

0 commit comments

Comments
 (0)