Yeah, I was the one advising to try and see to split this. But it might be a starting point that is too rough. I still believe that would be desirable in the long term, but that an intermediate move can indeed be to introduce a brand new component that will offer that high level API to the "outside" world.
I think starting small by introducing this and use it from install-plugins.sh might be a smaller scope and achievable task.
Really sorry for the wrong advice that might have turned more stressful than anticipated.