This reduces the surface area of our `Kernel` monkeypatch and removes
the need to `include Kernel` in a bunch of modules.
While we're here, also move `Kernel#require?` to `Homebrew` and fully
scope the calls to it.
In https://github.com/Homebrew/brew/pull/19602 we changed
`launchctl list` to pass the domain target. Sadly, this is not valid
syntax. Instead, restore passing the `service_name` to `launchctl list`
and instead use `launchctl print` first to query the more specific
domain target before we fall back to the less specific service name.
The `brew services list` command was not correctly handling services
that had an error code status.
While the `#zero?` method returns a boolean, the `#nonzero?` method
confusingly returns self or nil. Hence a negated `#zero?` call to check
for a non-zero exit code fixes the error.
While here, `#pid?` method uses a negated `#zero?`, which is not
accurate, as a negative PID value would not be a valid PID. Hence I
changed it to use `#positive?` instead.
The tests for the `#error?` method were marked as needing systemd, but I
saw no obvious reason for that due to how they all use mocked values, so
I removed the systemd requirement.
Some of the typing/`T.must` usage when moving the
Homebrew/homebrew-services code to Homebrew/brew was not quite correct.
Rather than trying to make everything `strict` and import at the same
time: let's mostly loosen the typing to fix a few bugs and allow us to
add more later.