( docContents: string, docPath: string, docTitle: string, instructions?: string, )
| 96 | * Build the Magic Docs update prompt with variable substitution |
| 97 | */ |
| 98 | export async function buildMagicDocsUpdatePrompt( |
| 99 | docContents: string, |
| 100 | docPath: string, |
| 101 | docTitle: string, |
| 102 | instructions?: string, |
| 103 | ): Promise<string> { |
| 104 | const promptTemplate = await loadMagicDocsPrompt() |
| 105 | |
| 106 | // Build custom instructions section if provided |
| 107 | const customInstructions = instructions |
| 108 | ? ` |
| 109 | |
| 110 | DOCUMENT-SPECIFIC UPDATE INSTRUCTIONS: |
| 111 | The document author has provided specific instructions for how this file should be updated. Pay extra attention to these instructions and follow them carefully: |
| 112 | |
| 113 | "${instructions}" |
| 114 | |
| 115 | These instructions take priority over the general rules below. Make sure your updates align with these specific guidelines.` |
| 116 | : '' |
| 117 | |
| 118 | // Substitute variables in the prompt |
| 119 | const variables = { |
| 120 | docContents, |
| 121 | docPath, |
| 122 | docTitle, |
| 123 | customInstructions, |
| 124 | } |
| 125 | |
| 126 | return substituteVariables(promptTemplate, variables) |
| 127 | } |
| 128 |
no test coverage detected