Prefer the declared package manager during upgrades (#99471)
### Why?
Running a codemod through `npx` can select npm even when the app
declares Yarn, pnpm, or Bun, causing dependency installation to fail.
### How?
Read `package.json#packageManager` before `npm_config_user_agent`. Keep
the existing user-agent, lockfile, and npm fallbacks unchanged.
Add shared checks for installation and recovery after an interrupted
upgrade.