Improved terminal theme detection for light/dark and truecolor handling.

Source: pi/packages/coding-agent/CHANGELOG.md at main