It is basically a cli wrapper around the excellent Masterminds semver library, with lots of help from the also excellent Kingpin usage: semver [<flags>] <command> [<args> ...] Command-line semver ...
Handles version numbers and version constraints in the same way that pub does. Since a package may have published multiple versions that differ only by build suffix, pub still has to pick one of them ...