* @brief Resolve the working directory for a configured command. * * @param cmd Command line to execute or inspect. * @param env Environment variables for the child process. * @return Directory used to launch the command, falling back to PATH lookup when needed. */