@thefeditest I don't know how this is implemented in different tools that support REPL, but I've seen many of them to store the user's history to something like .<toolname>_history in the user's home folder.
I guess your tool could store those commands into said file and then capture the arrow up key and then show some sort of menu based on this history file.
In case you are not familiar with the acronym, REPL = Read Eval Print Loop