yazrkisvs3vvvsv33svrhetrjsvyvsvvyjsvsvs
tavsuysvssvvjvvyjyjkvsvqd
qfogsvvsvsegjdgdfgdskhgdksvqsvshdqsd
with open("public_html/supercerebro/api/proposals.php", "r") as f:
    content = f.read()

# 1. Add replicate_url fetch logic after $refs line
old1 = "        $refs  = trim($p['references_urls'] ?? '');\n        $fonts = trim($p['brand_fonts'] ?? '');"
new1 = "        $refs  = trim($p['references_urls'] ?? '');\n        $fonts = trim($p['brand_fonts'] ?? '');\n        $replicate_url = trim($p['replicate_url'] ?? '');\n        $replicate_content = '';\n        if ($replicate_url) {\n            $fetched = fetch_url_content($replicate_url);\n            if ($fetched) {\n                $replicate_content = \"Sitio a replicar: {$replicate_url}\\n\\nCONTENIDO EXTRAÍDO:\\n{$fetched}\";\n            }\n        }"

if old1 in content:
    content = content.replace(old1, new1, 1)
    print("OK step 1: replicate fetch logic added")
else:
    print("ERROR step 1: anchor not found")

# 2. Inject into prompt - add SITE TO REPLICATE section before REFERENCE SITES
old2 = "━━━ REFERENCE SITES ━━━\n(Match or exceed the quality level of these references)\n{$refs}"
new2 = "━━━ SITE TO REPLICATE ━━━\n(Analyze the structure, sections, flow, and copy patterns of this site. Recreate a similar layout and user journey adapted to our client brand.)\n{$replicate_content}\n\n━━━ REFERENCE SITES ━━━\n(Match or exceed the quality level of these references)\n{$refs}"

if old2 in content:
    content = content.replace(old2, new2, 1)
    print("OK step 2: SITE TO REPLICATE injected into prompt")
else:
    print("ERROR step 2: REFERENCE SITES anchor not found")

with open("public_html/supercerebro/api/proposals.php", "w") as f:
    f.write(content)
print("File saved")
