{"version":3,"sources":["../../src/core/prompt-generator.ts"],"names":["getSystemPrompt","projectId","preferredStrategy","patchConfig","intro","syntaxAuto","syntaxReplace","syntaxStandardDiff","syntaxSearchReplace","sectionStandardDiff","sectionSearchReplace","otherOps","finalSteps_rules","finalSteps_list","finalSteps","item","index","strategyInfo","preferred","syntax","strategyDetails"],"mappings":"uCAEO,MAAMA,CAAAA,CAAkB,CAC7BC,CAAAA,CACAC,CAAAA,CACAC,IACW,CACX,MAAMC,EAAQ,+GAAA,CAERC,CAAAA,CAAa,meAgBbC,CAAAA,CAAgB,qWAAA,CAQhBC,EAAqB,yQAAA,CAQrBC,CAAAA,CAAsB,4QAQtBC,CAAAA,CAAsB,CAAA;;AAAA;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,CA6BtBC,CAAAA,CAAuB,CAAA;;AAAA;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,CAiBvBC,CAAAA,CAAW,kgBAqBXC,CAAAA,CAAmB,GACrBT,CAAAA,CAAY,cAAA,CAAiB,GAC/BS,CAAAA,CAAiB,IAAA,CAAK,4BAA4BT,CAAAA,CAAY,cAAc,+BAA+B,CAAA,CAEzGA,CAAAA,CAAY,gBACdS,CAAAA,CAAiB,IAAA,CAAK,CAAA,8BAAA,EAAiCT,CAAAA,CAAY,cAAc,CAAA,6BAAA,CAA+B,EAGlH,MAAMU,CAAAA,CAAkB,CACtB,uEACF,CAAA,CACID,EAAiB,MAAA,CAAS,CAAA,EAC5BC,EAAgB,IAAA,CAAK,CAAA,uBAAA,EAA0BD,EAAiB,IAAA,CAAK,GAAG,CAAC,CAAA,CAAE,CAAA,CAE7EC,EAAgB,IAAA,CAAK,yJAAyJ,CAAA,CAI9K,MAAMC,CAAAA,CAAa,CAAA;;AAAA;;AAAA,EAFYD,CAAAA,CAAgB,GAAA,CAAI,CAACE,CAAAA,CAAMC,CAAAA,GAAU,CAAA,EAAGA,CAAAA,CAAQ,CAAC,CAAA,GAAA,EAAMD,CAAI,CAAA,CAAE,CAAA,CAAE,IAAA,CAAK;AAAA,CAAI,CAMjF;;AAAA;AAAA,eAAA,EAGPd,CAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA,CAAA,CAclBgB,CAAAA,CAAe,CACnB,IAAA,CAAM,CAAE,OAAQZ,CAAAA,CAAY,OAAA,CAAS,GAAGI,CAAmB;AAAA,EAAKC,CAAoB,EAAG,CAAA,CACvF,OAAA,CAAS,CAAE,MAAA,CAAQJ,CAAAA,CAAe,OAAA,CAAS,EAAG,CAAA,CAC9C,eAAA,CAAiB,CAAE,MAAA,CAAQC,CAAAA,CAAoB,QAASE,CAAoB,CAAA,CAC5E,iBAAkB,CAAE,MAAA,CAAQD,CAAAA,CAAqB,OAAA,CAASE,CAAqB,CACjF,EAEMQ,CAAAA,CAAYD,CAAAA,CAAaf,CAAiB,CAAA,EAAKe,CAAAA,CAAa,KAC5DE,CAAAA,CAASD,CAAAA,CAAU,MAAA,CACnBE,CAAAA,CAAkBF,CAAAA,CAAU,OAAA,CAGlC,OADoB,CAACd,CAAAA,CAAOe,EAAQC,CAAAA,CAAiBT,CAAAA,CAAUG,CAAU,CAAA,CACtD,MAAA,CAAO,OAAO,CAAA,CAAE,IAAA,CAAK;AAAA,CAAI,CAC9C","file":"prompt-generator.cjs","sourcesContent":["import { type Config } from 'relaycode-core';\n\nexport const getSystemPrompt = (\n  projectId: string,\n  preferredStrategy: Config['watcher']['preferredStrategy'],\n  patchConfig: Config['patch'],\n): string => {\n  const intro = `You are an expert AI programmer. To modify a file, you MUST use a code block with a specified patch strategy.`;\n\n  const syntaxAuto = `\n**Syntax:**\n\\`\\`\\`typescript // filePath {patchStrategy}\n... content ...\n\\`\\`\\`\n- \\`filePath\\`: The path to the file. **If the path contains spaces, it MUST be enclosed in double quotes.**\n- \\`patchStrategy\\`: (Optional) One of \\`standard-diff\\`, \\`search-replace\\`. If omitted, the entire file is replaced (this is the \\`replace\\` strategy).\n\n**Examples:**\n\\`\\`\\`typescript // src/components/Button.tsx\n...\n\\`\\`\\`\n\\`\\`\\`typescript // \"src/components/My Component.tsx\" standard-diff\n...\n\\`\\`\\``;\n\n  const syntaxReplace = `\n**Syntax:**\n\\`\\`\\`typescript // filePath\n... content ...\n\\`\\`\\`\n- \\`filePath\\`: The path to the file. **If the path contains spaces, it MUST be enclosed in double quotes.**\n- Only the \\`replace\\` strategy is enabled. This means you must provide the ENTIRE file content for any change. This is suitable for creating new files or making changes to small files.`;\n\n  const syntaxStandardDiff = `\n**Syntax:**\n\\`\\`\\`typescript // filePath standard-diff\n... diff content ...\n\\`\\`\\`\n- \\`filePath\\`: The path to the file. **If the path contains spaces, it MUST be enclosed in double quotes.**\n- You must use the \\`standard-diff\\` patch strategy for all modifications.`;\n\n  const syntaxSearchReplace = `\n**Syntax:**\n\\`\\`\\`typescript // filePath search-replace\n... diff content ...\n\\`\\`\\`\n- \\`filePath\\`: The path to the file. **If the path contains spaces, it MUST be enclosed in double quotes.**\n- You must use the \\`search-replace\\` patch strategy for all modifications.`;\n\n  const sectionStandardDiff = `---\n\n### Strategy 1: Advanced Unified Diff (\\`standard-diff\\`) - RECOMMENDED\n\nUse for most changes, like refactoring, adding features, and fixing bugs. It's resilient to minor changes in the source file.\n\n**Diff Format:**\n1.  **File Headers**: Start with \\`--- {filePath}\\` and \\`+++ {filePath}\\`.\n2.  **Hunk Header**: Use \\`@@ ... @@\\`. Exact line numbers are not needed.\n3.  **Context Lines**: Include 2-3 unchanged lines before and after your change for context.\n4.  **Changes**: Mark additions with \\`+\\` and removals with \\`-\\`. Maintain indentation.\n\n**Example:**\n\\`\\`\\`diff\n--- src/utils.ts\n+++ src/utils.ts\n@@ ... @@\n    function calculateTotal(items: number[]): number {\n-      return items.reduce((sum, item) => {\n-        return sum + item;\n-      }, 0);\n+      const total = items.reduce((sum, item) => {\n+        return sum + item * 1.1;  // Add 10% markup\n+      }, 0);\n+      return Math.round(total * 100) / 100;  // Round to 2 decimal places\n+    }\n\\`\\`\\`\n`;\n\n  const sectionSearchReplace = `---\n\n### Strategy 2: Search-Replace (\\`search-replace\\`)\n\nUse for precise, surgical replacements. The \\`SEARCH\\` block must be an exact match of the content in the file.\n\n**Diff Format:**\nRepeat this block for each replacement.\n\\`\\`\\`diff\n<<<<<<< SEARCH\n[exact content to find including whitespace]\n=======\n[new content to replace with]\n>>>>>>> REPLACE\n\\`\\`\\`\n`;\n\n  const otherOps = `---\n\n### Other Operations\n\n-   **Creating a file**: Use the default \\`replace\\` strategy (omit the strategy name) and provide the full file content.\n-   **Deleting a file**:\n    \\`\\`\\`typescript // path/to/file.ts\n    //TODO: delete this file\n    \\`\\`\\`\n    \\`\\`\\`typescript // \"path/to/My Old Component.ts\"\n    //TODO: delete this file\n    \\`\\`\\`\n-   **Renaming/Moving a file**:\n    \\`\\`\\`json // rename-file\n    {\n      \"from\": \"src/old/path/to/file.ts\",\n      \"to\": \"src/new/path/to/file.ts\"\n    }\n    \\`\\`\\`\n`;\n\n  const finalSteps_rules = [];\n  if (patchConfig.minFileChanges > 0) {\n    finalSteps_rules.push(`You must modify at least ${patchConfig.minFileChanges} file(s) in this transaction.`);\n  }\n  if (patchConfig.maxFileChanges) {\n    finalSteps_rules.push(`You must not modify more than ${patchConfig.maxFileChanges} file(s) in this transaction.`);\n  }\n\n  const finalSteps_list = [\n    'Add your step-by-step reasoning in plain text before each code block.',\n  ];\n  if (finalSteps_rules.length > 0) {\n    finalSteps_list.push(`Adhere to file limits: ${finalSteps_rules.join(' ')}`);\n  }\n  finalSteps_list.push('ALWAYS add the following YAML block at the very end of your response. Use the exact projectId shown here. Generate a new random uuid for each response.');\n\n  const finalSteps_list_string = finalSteps_list.map((item, index) => `${index + 1}.  ${item}`).join('\\n');\n\n  const finalSteps = `---\n\n### Final Steps\n\n${finalSteps_list_string}\n\n    \\`\\`\\`yaml\n    projectId: ${projectId}\n    uuid: (generate a random uuid)\n    changeSummary: # A list of key-value pairs for changes\n      - edit: src/main.ts\n      - new: src/components/Button.tsx\n      - delete: src/utils/old-helper.ts\n    promptSummary: A brief summary of my request.\n    gitCommitMsg: >-\n      feat: A concise, imperative git commit message.\n\n      Optionally, provide a longer description here.\n    \\`\\`\\`\n`;\n\n  const strategyInfo = {\n    auto: { syntax: syntaxAuto, details: `${sectionStandardDiff}\\n${sectionSearchReplace}` },\n    replace: { syntax: syntaxReplace, details: '' },\n    'standard-diff': { syntax: syntaxStandardDiff, details: sectionStandardDiff },\n    'search-replace': { syntax: syntaxSearchReplace, details: sectionSearchReplace },\n  };\n\n  const preferred = strategyInfo[preferredStrategy] ?? strategyInfo.auto;\n  const syntax = preferred.syntax;\n  const strategyDetails = preferred.details;\n\n  const promptParts = [intro, syntax, strategyDetails, otherOps, finalSteps];\n  return promptParts.filter(Boolean).join('\\n');\n};"]}