Put squash, tomatoes, sugar, basil, thyme, ½ teaspoon salt and ¼ teaspoon pepper into a medium saucepan.
If using fresh squash, first microwave until fork tender, 4 minutes.
Simmer over low heat, stirring often, until squash is fork tender and sauce is thick, about 20 minutes.
Remove from heat and cool.
Meanwhile, heat a large nonstick skillet over medium heat until hot.
Add 2 tablespoon oil and the onions.
Cook, stirring often, until onions are golden and soft, about 10 minutes.
Add mushrooms and garlic; cook, stirring often, until mushrooms are golden, about 5 minutes.
Season with ¼ teaspoon each of salt and pepper; cool.
Stir in fresh basil and chives.
Use the large holes on a 4-sided grater to shred the mozzarella onto a plate.
Mix ricotta, half of the Parmesan, remaining 1 tablespoon olive oil, egg, ½ teaspoon salt and ¼ teaspoon pepper in medium bowl.