32 lines
1.5 KiB
Python
32 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Fix the broken reviewCode template literal."""
|
|
|
|
fp = '/home/uroma/promptarch/components/AIAssist.tsx'
|
|
with open(fp, 'r') as f:
|
|
content = f.read()
|
|
|
|
# Find and replace the broken reviewPrompt line
|
|
# The problem: backticks inside template literal need to be escaped with \`
|
|
old_line = ' const reviewPrompt = `Please review this generated code for bugs, security issues, performance problems, and best practices. Provide specific improvements:\\n\\n\\\\`\\\\`\\\\`${previewData.language || "code"}\\n${previewData.data}\\n\\\\`\\\\`\\\\`';'
|
|
|
|
new_line = ' const reviewPrompt = "Please review this generated code for bugs, security issues, performance problems, and best practices. Provide specific improvements:\\n\\n\`\`\`" + (previewData.language || "code") + "\\n" + previewData.data + "\\n\`\`\`";'
|
|
|
|
if old_line in content:
|
|
content = content.replace(old_line, new_line, 1)
|
|
print("Fixed reviewCode template literal")
|
|
else:
|
|
# Try with the actual escaped content
|
|
# Let's just find it by the function start and replace the whole function
|
|
print("Trying line-by-line approach...")
|
|
lines = content.split('\n')
|
|
for i, line in enumerate(lines):
|
|
if 'const reviewPrompt' in line and 'review this generated code' in line:
|
|
print(f"Found at line {i+1}: {line[:80]}...")
|
|
lines[i] = new_line
|
|
print("Fixed")
|
|
break
|
|
content = '\n'.join(lines)
|
|
|
|
with open(fp, 'w') as f:
|
|
f.write(content)
|