Capture result from each (major) phase as trees in API

It provides some syntax sugar for doing this, something like `.json` or `.toJson`, which will require the encoding implicit.