Elffuss BraidHub

kikocis/continue public

main · 1010 BRawPermalink
1import * as YAML from "yaml";
2
3export interface PromptFrontmatter {
4 name?: string;
5 description?: string;
6 invokable?: boolean;
7}
8
9/**
10 * Creates markdown content with YAML frontmatter for prompts
11 */
12export function createMarkdownWithPromptFrontmatter(
13 frontmatter: PromptFrontmatter,
14 prompt: string,
15): string {
16 const frontmatterStr = YAML.stringify(frontmatter).trim();
17 return `---\n${frontmatterStr}\n---\n\n${prompt}`;
18}
19
20/**
21 * Creates a prompt markdown file content from prompt components
22 */
23export function createPromptMarkdown(
24 name: string,
25 promptContent: string,
26 options: {
27 description?: string;
28 invokable?: boolean;
29 } = {},
30): string {
31 const frontmatter: PromptFrontmatter = {
32 name: name.trim(),
33 };
34
35 if (options.description) {
36 frontmatter.description = options.description.trim();
37 }
38
39 if (options.invokable !== undefined) {
40 frontmatter.invokable = options.invokable;
41 }
42
43 return createMarkdownWithPromptFrontmatter(frontmatter, promptContent);
44}