I will not answer directly to your question.
Here is what I do with pipelines and queries.
- I do not used the builders.
- I keep them in a resource file as a json document.
- I load them at run time.
- I use Document.parse() and then use the usual collection API.
This way
- I can change a pipeline or query without recompiling.
- I can debug the pipeline with the shell or compass.
- Store back the result in my resource file.