Programmatic way to rewrite a query with the view definitions as sub query?
I've never heard of or seen anything of this ilk.
You're most likely better served rethinking how you utilize views and refactoring them in a way that isn't an impediment to development, instead of building a tool to do this.
Several layers of nested views are (to me) an anti-pattern and make it harder for developers and SQL Server alike. They're also very likely to hide bad code and obscure issues.
Also see:

The Seven Sins Against TSQL: Indulging in Nested Views