I can vouch for Hammerspoon, it is an excellent scriptable Lua environment with built-in hooks for probably every native OS X feature you've ever wanted to script. Great project, I highly recommend it.
Another Hammerspoon user chiming in. Discovered it one day and got hooked by how easy it is to get things done. This is coming from someone who never wrote any Lua before.
I love that you can create URI scheme triggers. It makes it so trivial to automate stuff in Hammerspoon from other tools.