Port __main__.py functionality from uv
#993
+30
−3
Draft