For the Sauce. You can make extra and store the remainder in the fridge.
Heat up the oil and gently sauté the onions and garlic until translucent.
Add the vegetables and sauté further. Cover and let the vegetables cook for a couple of minutes. If using chilies, add them here.
If adding the mushrooms, add the salt at the end and make the sauce just before the pasta is cooked. The mushrooms release a lot of water and if the sauce is made too early, th pasta will become watery and the mushrooms will lose their crunchiness. Another method is to add the tomatoes soon after the mushrooms are sautéed. The tomatoes arrest further cooking of the mushrooms.
Add the pesto and the other seasonings, mix well. The wine and basil can be added at this stage.
Add the puree and the tomatoes. Let the sauce simmer for a few minutes.
Always add the pasta just before serving so that the dish remains saucy and the pasta does not soak up all the liquid of the sauce.
Sprinkle the cheese for garnish and serve immediately,