const fs = require('fs');
const file = 'src/prompts/coder.ts';
let code = fs.readFileSync(file, 'utf8');

const oldStopping = `A turn ends when you have fully completed the task AND shipped the code.
- **For build/edit tasks:** The natural stopping point is starting the dev server via \\\`dev_server_start\\\`, verifying it works via \\\`browser_console\\\`, and calling the \\\`ship\\\` tool to deploy to production.
- If you run into a fatal error that you cannot fix after two attempts, write a brief summary of the blocker and stop.`;

const newStopping = `A turn ends when you have fully completed the task AND shipped the code.
- **For build/edit tasks:** The natural stopping point is starting the dev server via \\\`dev_server_start\\\`, verifying it works via \\\`browser_console\\\`, and calling the \\\`ship\\\` tool to deploy to production.
- **CRITICAL:** When you successfully finish a task from the Execution Plan, you MUST call \\\`plan_task_complete { taskId }\\\` to check it off the list before moving to the next task.
- If you run into a fatal error that you cannot fix after two attempts, write a brief summary of the blocker and stop.`;

code = code.replace(oldStopping, newStopping);
fs.writeFileSync(file, code);
console.log("Patched Delegate Prompt to enforce plan_task_complete");
