How Newborn Stars Prepare for the Birth of Planets