import os

with open("core/urls.py", "r") as f:
    content = f.read()

content = content.replace(
    'from .views import home, project_list, project_detail, create_project, signup, regenerate_mindmap',
    'from .views import home, project_list, project_detail, create_project, signup, regenerate_mindmap, edit_node'
)

new_path = "    path('projects/<int:pk>/node/<int:node_id>/edit/', edit_node, name='edit_node'),\n"
content = content.replace(
    '    path("projects/<int:pk>/ai/", ai_chat, name="ai_chat"),',
    '    path("projects/<int:pk>/ai/", ai_chat, name="ai_chat"),\n' + new_path
)

with open("core/urls.py", "w") as f:
    f.write(content)

