Elon Musk’s rocket company has agreed to buy Cursor, which uses AI to automate the process of writing code.