Elffuss BraidHub

kikocis/continue public

fix: fix prompt creation to use new markdown format (#7920)

* Fix prompt creation to use new markdown format instead of YAML

- Added createPromptMarkdown function to generate markdown prompts with frontmatter
- Updated workspaceBlocks to use .md extension and markdown format for prompts
- Changed prompt creation from old YAML format to new markdown format with name, description, and invokable properties
- Updated tests to reflect the new markdown format expectations
- Prompts now generate with proper frontmatter: name, description, invokable: true

Generated with [Continue](https://continue.dev)

Co-Authored-By: Continue <noreply@continue.dev>

* fix: use jest

---------

Co-authored-by: Continue Agent <agent@continue.dev>
Co-authored-by: Continue <noreply@continue.dev>
Co-authored-by: Dallin Romney <dallinromney@gmail.com>
Changesetacb803bca942ec7b5d57b94b093862951673bc0e7868006a343f1302354bc942
Authorcontinue[bot] <230936708+continue[bot]@users.noreply.github.com> · 2025-09-26 16:41 -07:00
CommitterGitHub <noreply@github.com> · 2025-09-26 16:41 -07:00
Parents4d8ba150996e

Browse the files at this changeset

5 files changed

modified core/config/workspace/workspaceBlocks.ts +14 −1
@@ -2,6 +2,7 @@
22 BlockType,
33 ConfigYaml,
44 createRuleMarkdown,
5+ createPromptMarkdown,
56 RULE_FILE_EXTENSION,
67 } from "@continuedev/config-yaml";
78 import * as YAML from "yaml";
@@ -83,7 +84,10 @@
8384 }
8485
8586 function getFileExtension(blockType: BlockType): string {
86- return blockType === "rules" ? RULE_FILE_EXTENSION : "yaml";
87+ if (blockType === "rules" || blockType === "prompts") {
88+ return "md";
89+ }
90+ return "yaml";
8791 }
8892
8993 export function getFileContent(blockType: BlockType): string {
@@ -91,6 +95,15 @@
9195 return createRuleMarkdown("New Rule", "Your rule content", {
9296 description: "A description of your rule",
9397 });
98+ } else if (blockType === "prompts") {
99+ return createPromptMarkdown(
100+ "New prompt",
101+ "Please write a thorough suite of unit tests for this code, making sure to cover all relevant edge cases",
102+ {
103+ description: "New prompt",
104+ invokable: true,
105+ },
106+ );
94107 } else {
95108 return YAML.stringify(getContentsForNewBlock(blockType));
96109 }
modified core/config/workspace/workspaceBlocks.vitest.ts +8 −6
@@ -18,7 +18,7 @@
1818 expect(result).toContain("provider: anthropic");
1919 });
2020
21- test("generates correct YAML for different block types", () => {
21+ test("generates correct content for different block types", () => {
2222 const contextResult = getFileContent("context");
2323 expect(contextResult).toContain("name: New context");
2424 expect(contextResult).toContain("context:");
@@ -31,8 +31,10 @@
3131
3232 const promptsResult = getFileContent("prompts");
3333 expect(promptsResult).toContain("name: New prompt");
34- expect(promptsResult).toContain("prompts:");
34+ expect(promptsResult).toContain("description: New prompt");
35+ expect(promptsResult).toContain("invokable: true");
3536 expect(promptsResult).toContain("thorough suite of unit tests");
37+ expect(promptsResult).toContain("---"); // Should be markdown with frontmatter
3638
3739 const mcpResult = getFileContent("mcpServers");
3840 expect(mcpResult).toContain("name: New MCP server");
@@ -96,7 +98,7 @@
9698 { blockType: "context", expected: "/test/new-context.yaml" },
9799 { blockType: "rules", expected: `/test/new-rule.${RULE_FILE_EXTENSION}` },
98100 { blockType: "docs", expected: "/test/new-doc.yaml" },
99- { blockType: "prompts", expected: "/test/new-prompt.yaml" },
101+ { blockType: "prompts", expected: "/test/new-prompt.md" },
100102 { blockType: "mcpServers", expected: "/test/new-mcp-server.yaml" },
101103 ];
102104
@@ -148,8 +150,8 @@
148150 const existingFiles = new Set(
149151 Array.from({ length: 100 }, (_, i) =>
150152 i === 0
151- ? "/workspace/.continue/prompts/new-prompt.yaml"
152- : `/workspace/.continue/prompts/new-prompt-${i}.yaml`,
153+ ? "/workspace/.continue/prompts/new-prompt.md"
154+ : `/workspace/.continue/prompts/new-prompt-${i}.md`,
153155 ),
154156 );
155157
@@ -163,6 +165,6 @@
163165 mockFileExists,
164166 );
165167
166- expect(result).toBe("/workspace/.continue/prompts/new-prompt-100.yaml");
168+ expect(result).toBe("/workspace/.continue/prompts/new-prompt-100.md");
167169 });
168170 });
added packages/config-yaml/src/markdown/createMarkdownPrompt.test.ts +108 −0
@@ -0,0 +1,108 @@
1+import {
2+ createMarkdownWithPromptFrontmatter,
3+ createPromptMarkdown,
4+} from "./createMarkdownPrompt.js";
5+
6+describe("createMarkdownWithPromptFrontmatter", () => {
7+ test("should create properly formatted markdown with frontmatter", () => {
8+ const frontmatter = {
9+ name: "Test Prompt",
10+ description: "A test prompt",
11+ invokable: true,
12+ };
13+ const prompt = "This is the prompt content";
14+
15+ const result = createMarkdownWithPromptFrontmatter(frontmatter, prompt);
16+
17+ expect(result).toBe(`---
18+name: Test Prompt
19+description: A test prompt
20+invokable: true
21+---
22+
23+This is the prompt content`);
24+ });
25+
26+ test("should handle empty frontmatter", () => {
27+ const frontmatter = {};
28+ const prompt = "Simple prompt content";
29+
30+ const result = createMarkdownWithPromptFrontmatter(frontmatter, prompt);
31+
32+ expect(result).toBe(`---
33+{}
34+---
35+
36+Simple prompt content`);
37+ });
38+});
39+
40+describe("createPromptMarkdown", () => {
41+ test("should create properly formatted markdown with all options", () => {
42+ const result = createPromptMarkdown(
43+ "Test Prompt",
44+ "This is the prompt content",
45+ {
46+ description: "A test prompt",
47+ invokable: true,
48+ },
49+ );
50+
51+ expect(result).toBe(`---
52+name: Test Prompt
53+description: A test prompt
54+invokable: true
55+---
56+
57+This is the prompt content`);
58+ });
59+
60+ test("should handle minimal configuration", () => {
61+ const result = createPromptMarkdown("Simple Prompt", "Simple content");
62+
63+ expect(result).toBe(`---
64+name: Simple Prompt
65+---
66+
67+Simple content`);
68+ });
69+
70+ test("should handle description only", () => {
71+ const result = createPromptMarkdown("Prompt with Description", "Content", {
72+ description: "Test description",
73+ });
74+
75+ expect(result).toBe(`---
76+name: Prompt with Description
77+description: Test description
78+---
79+
80+Content`);
81+ });
82+
83+ test("should trim name and description", () => {
84+ const result = createPromptMarkdown(" Trim Test ", "Content", {
85+ description: " Trimmed Description ",
86+ });
87+
88+ expect(result).toBe(`---
89+name: Trim Test
90+description: Trimmed Description
91+---
92+
93+Content`);
94+ });
95+
96+ test("should handle invokable false", () => {
97+ const result = createPromptMarkdown("Invokable False", "Content", {
98+ invokable: false,
99+ });
100+
101+ expect(result).toBe(`---
102+name: Invokable False
103+invokable: false
104+---
105+
106+Content`);
107+ });
108+});
added packages/config-yaml/src/markdown/createMarkdownPrompt.ts +44 −0
@@ -0,0 +1,44 @@
1+import * as YAML from "yaml";
2+
3+export interface PromptFrontmatter {
4+ name?: string;
5+ description?: string;
6+ invokable?: boolean;
7+}
8+
9+/**
10+ * Creates markdown content with YAML frontmatter for prompts
11+ */
12+export 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+ */
23+export 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+}
modified packages/config-yaml/src/markdown/index.ts +1 −0
@@ -1,3 +1,4 @@
11 export * from "./createMarkdownRule.js";
2+export * from "./createMarkdownPrompt.js";
23 export * from "./getRuleType.js";
34 export * from "./markdownToRule.js";