@shawneric started a project along these lines a couple of years ago, but I’m not sure if he got to the point of complexity that you’ve described.