Changesets · Branches · Tags · Compare
| Changeset | acb803bca942ec7b5d57b94b093862951673bc0e7868006a343f1302354bc942 |
|---|---|
| Author | continue[bot] <230936708+continue[bot]@users.noreply.github.com> · 2025-09-26 16:41 -07:00 |
| Committer | GitHub <noreply@github.com> · 2025-09-26 16:41 -07:00 |
| Parents | 4d8ba150996e |
5 files changed
modified core/config/workspace/workspaceBlocks.ts +14 −1
| @@ -2,6 +2,7 @@ | ||
| 2 | 2 | BlockType, |
| 3 | 3 | ConfigYaml, |
| 4 | 4 | createRuleMarkdown, |
| 5 | + createPromptMarkdown, | |
| 5 | 6 | RULE_FILE_EXTENSION, |
| 6 | 7 | } from "@continuedev/config-yaml"; |
| 7 | 8 | import * as YAML from "yaml"; |
| @@ -83,7 +84,10 @@ | ||
| 83 | 84 | } |
| 84 | 85 | |
| 85 | 86 | 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"; | |
| 87 | 91 | } |
| 88 | 92 | |
| 89 | 93 | export function getFileContent(blockType: BlockType): string { |
| @@ -91,6 +95,15 @@ | ||
| 91 | 95 | return createRuleMarkdown("New Rule", "Your rule content", { |
| 92 | 96 | description: "A description of your rule", |
| 93 | 97 | }); |
| 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 | + ); | |
| 94 | 107 | } else { |
| 95 | 108 | return YAML.stringify(getContentsForNewBlock(blockType)); |
| 96 | 109 | } |
modified core/config/workspace/workspaceBlocks.vitest.ts +8 −6
| @@ -18,7 +18,7 @@ | ||
| 18 | 18 | expect(result).toContain("provider: anthropic"); |
| 19 | 19 | }); |
| 20 | 20 | |
| 21 | - test("generates correct YAML for different block types", () => { | |
| 21 | + test("generates correct content for different block types", () => { | |
| 22 | 22 | const contextResult = getFileContent("context"); |
| 23 | 23 | expect(contextResult).toContain("name: New context"); |
| 24 | 24 | expect(contextResult).toContain("context:"); |
| @@ -31,8 +31,10 @@ | ||
| 31 | 31 | |
| 32 | 32 | const promptsResult = getFileContent("prompts"); |
| 33 | 33 | expect(promptsResult).toContain("name: New prompt"); |
| 34 | - expect(promptsResult).toContain("prompts:"); | |
| 34 | + expect(promptsResult).toContain("description: New prompt"); | |
| 35 | + expect(promptsResult).toContain("invokable: true"); | |
| 35 | 36 | expect(promptsResult).toContain("thorough suite of unit tests"); |
| 37 | + expect(promptsResult).toContain("---"); // Should be markdown with frontmatter | |
| 36 | 38 | |
| 37 | 39 | const mcpResult = getFileContent("mcpServers"); |
| 38 | 40 | expect(mcpResult).toContain("name: New MCP server"); |
| @@ -96,7 +98,7 @@ | ||
| 96 | 98 | { blockType: "context", expected: "/test/new-context.yaml" }, |
| 97 | 99 | { blockType: "rules", expected: `/test/new-rule.${RULE_FILE_EXTENSION}` }, |
| 98 | 100 | { blockType: "docs", expected: "/test/new-doc.yaml" }, |
| 99 | - { blockType: "prompts", expected: "/test/new-prompt.yaml" }, | |
| 101 | + { blockType: "prompts", expected: "/test/new-prompt.md" }, | |
| 100 | 102 | { blockType: "mcpServers", expected: "/test/new-mcp-server.yaml" }, |
| 101 | 103 | ]; |
| 102 | 104 | |
| @@ -148,8 +150,8 @@ | ||
| 148 | 150 | const existingFiles = new Set( |
| 149 | 151 | Array.from({ length: 100 }, (_, i) => |
| 150 | 152 | 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`, | |
| 153 | 155 | ), |
| 154 | 156 | ); |
| 155 | 157 | |
| @@ -163,6 +165,6 @@ | ||
| 163 | 165 | mockFileExists, |
| 164 | 166 | ); |
| 165 | 167 | |
| 166 | - expect(result).toBe("/workspace/.continue/prompts/new-prompt-100.yaml"); | |
| 168 | + expect(result).toBe("/workspace/.continue/prompts/new-prompt-100.md"); | |
| 167 | 169 | }); |
| 168 | 170 | }); |
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 @@ | ||
| 1 | 1 | export * from "./createMarkdownRule.js"; |
| 2 | +export * from "./createMarkdownPrompt.js"; | |
| 2 | 3 | export * from "./getRuleType.js"; |
| 3 | 4 | export * from "./markdownToRule.js"; |