How would I automate repetitive tasks in Android? There are many tasks I do repetitively, like connect a Bluetooth headset or connect to a hotspot.  How do I typically "code" this?  How do I execute?
Is there a consistent library or package manager, or do I have to collect from everywhere?

Any community projects?
Anything that works consistently over several platforms?
Is there some framework to execute over several devices?
(In the Bluetooth example I might want to disconnect other devices at the same time)
A great app for that is Automate. I've used it with great success. There are a few plugins that exist; you may or may not need them

The main app is here

Based on your use case, you may want this,  this and maybe this extensions but it all depends on how you use the main app