Preheat the oven to 200°C.
Blend pine nuts and garlic in a food processor until smooth, then incorporate basil, pecorino, and olive oil.
Season the pesto with salt and pepper and set aside.
Fry the onion and garlic in a pan with oil for 5-8 minutes until soft.
Beat together the ricotta, goats' cheese, and egg in a bowl.
Cover the base of a baking dish with the onion mixture, roasted squash, and tomatoes.
Layer with the cheese mixture and spoon over some pesto.
Repeat the layering and top with grated pecorino.
Bake in the oven for 15 minutes until golden-brown and bubbling.
Serve warm with chutney.