Solving Heterogeneous-Agent Models by Projection and Perturbation