MCPcopy Index your code
hub / github.com/continuedev/continue / parsePromptFile

Function parsePromptFile

core/promptFiles/parsePromptFile.ts:5–24  ·  view source on GitHub ↗
(path: string, content: string)

Source from the content-addressed store, hash-verified

3import { getLastNPathParts } from "../util/uri";
4
5export function parsePromptFile(path: string, content: string) {
6 let [preambleRaw, prompt] = content.split("\n---\n");
7 if (prompt === undefined) {
8 prompt = preambleRaw;
9 preambleRaw = "";
10 }
11
12 const preamble = YAML.parse(preambleRaw) ?? {};
13 const name = preamble.name ?? getLastNPathParts(path, 1).split(".prompt")[0];
14 const description = preamble.description ?? name;
15 const version = preamble.version ?? 2;
16
17 let systemMessage: string | undefined = undefined;
18 if (prompt.includes("<system>")) {
19 systemMessage = prompt.split("<system>")[1].split("</system>")[0].trim();
20 prompt = prompt.split("</system>")[1].trim();
21 }
22
23 return { name, description, systemMessage, prompt, version };
24}

Callers 1

Calls 1

getLastNPathPartsFunction · 0.90

Tested by

no test coverage detected