open-interpreter
open-interpreter copied to clipboard
Added an edit magic command
Added %edit to allow the user to edit the last code submitted by OI.
The code is saved in a temp file with its extension matching the language. When the user is done editing it, the code gets saved in interpreter.messages.
Pre-Submission Checklist :
- [ ] I have included relevant documentation updates (stored in /docs)
- [x] I have read
docs/CONTRIBUTING.md - [x] I have read
docs/ROADMAP.md
OS Tests :
- [x] Tested on Windows
- [ ] Tested on MacOS
- [ ] Tested on Linux
@KillianLucas Can you please give an update on this.
Hi @Eliaskhal! Thanks for updating the PR, I think a magic command is a fantastic addition to OI.
From first glance I'm not sure if this would work, it looks like it appends the new code block to interpreter.messages. I think the edit command will need to:
- Retrieve the file extension from
self.computer.terminal.get_language("language").file_extension— instead of a custom map at the top. This makes it work with custom languages too. - Insert the code into the code block that it's editing, not append it as a new code block.
- Display the code to the user and prompt if they want to run it (y/n).
- Use
self.computer.run("language", "code")to run the code.
I'm happy to merge once this becomes a higher priority, then make those changes. If you can make those changes @Eliaskhal, I can credit you fully for the %edit command and get it into the update coming out this weekend! Great work either way, this is seriously such an awesome feature.
Hey @KillianLucas, thank you for your reply. I will work on adding the features you mentioned. Thank you
Hey @Eliaskhal! Let me know if you want to move make those changes, otherwise I'm happy to take a crack at it. Great work again.