You can use scriptListener to record changing a path to a shape to get the code. Unfortunately, there is a bug with the current version of PS, and this fails. It creates the shape layer, but there is nothing in that shape layer. I have notified Adobe regarding this. PS 2019 still works for doing this.