@@ -3,13 +3,19 @@ import path from "path";
3
3
import Handlebars from "handlebars" ;
4
4
import * as YAML from "yaml" ;
5
5
6
- import { BaseContextProvider } from "../context" ;
7
6
import { walkDir } from "../indexing/walkDir" ;
8
7
import { stripImages } from "../llm/images" ;
9
8
import { renderTemplatedString } from "../promptFiles/v1/renderTemplatedString" ;
10
9
import { getBasename } from "../util/index" ;
11
10
12
- import type { ChatHistory , ChatHistoryItem , ChatMessage , ContextItem , ContinueSDK , IContextProvider , IDE , SlashCommand } from ".." ;
11
+ import type {
12
+ ChatMessage ,
13
+ ContextItem ,
14
+ ContinueSDK ,
15
+ IContextProvider ,
16
+ IDE ,
17
+ SlashCommand ,
18
+ } from ".." ;
13
19
14
20
export const DEFAULT_PROMPTS_FOLDER = ".prompts" ;
15
21
@@ -93,12 +99,16 @@ export async function createNewPromptFile(
93
99
export function slashCommandFromPromptFile (
94
100
path : string ,
95
101
content : string ,
96
- ) : SlashCommand {
97
- const { name, description, systemMessage, prompt } = parsePromptFile (
102
+ ) : SlashCommand | null {
103
+ const { name, description, systemMessage, prompt, version } = parsePromptFile (
98
104
path ,
99
105
content ,
100
106
) ;
101
107
108
+ if ( version !== 1 ) {
109
+ return null ;
110
+ }
111
+
102
112
return {
103
113
name,
104
114
description,
@@ -134,14 +144,15 @@ function parsePromptFile(path: string, content: string) {
134
144
const preamble = YAML . parse ( preambleRaw ) ?? { } ;
135
145
const name = preamble . name ?? getBasename ( path ) . split ( ".prompt" ) [ 0 ] ;
136
146
const description = preamble . description ?? name ;
147
+ const version = preamble . version ?? 2 ;
137
148
138
149
let systemMessage : string | undefined = undefined ;
139
150
if ( prompt . includes ( "<system>" ) ) {
140
151
systemMessage = prompt . split ( "<system>" ) [ 1 ] . split ( "</system>" ) [ 0 ] . trim ( ) ;
141
152
prompt = prompt . split ( "</system>" ) [ 1 ] . trim ( ) ;
142
153
}
143
154
144
- return { name, description, systemMessage, prompt } ;
155
+ return { name, description, systemMessage, prompt, version } ;
145
156
}
146
157
147
158
function extractUserInput ( input : string , commandName : string ) : string {
@@ -151,7 +162,11 @@ function extractUserInput(input: string, commandName: string): string {
151
162
return input ;
152
163
}
153
164
154
- async function renderPrompt ( prompt : string , context : ContinueSDK , userInput : string ) {
165
+ async function renderPrompt (
166
+ prompt : string ,
167
+ context : ContinueSDK ,
168
+ userInput : string ,
169
+ ) {
155
170
const helpers = getContextProviderHelpers ( context ) ;
156
171
157
172
// A few context providers that don't need to be in config.json to work in .prompt files
0 commit comments