[lit] Move discovery code into its own module.