Hey, I am not sure if you know it, but there is a fully client-side webapp https://www.Photopea.com, that can open, edit and save PSD files. You can also write scripts, which will process a PSD document and e.g. export necessary layers.
I am the creator of Photopea. It is not fully open-source. What do you mean by running a webapp from a command line? I never heard of it (I also don't use a command line).
https://www.photopea.com/learn/scripts