We decided not to go with Python/JS to make executing safe and simple.
The data structure is a recursive list of simple objects that form a table of content.
DSL uses Python syntax though. For example:
swap_section(a, b)
create_section(after=2)
delete_section(2)
This proved to safe a ton of explanatory prompts that would be needed if every command was a tool instead. And it’s faster and more reliable.