Bring a large pot of salted water to a boil and add in the pasta shells. Cook for about 10 minutes until the texture is al dente. Drain and set aside.
While the pasta boils, heat a skillet on medium heat and add in two tbsp of olive oil. Add in the diced yellow onion and saute for about 10-15 minutes on medium/low heat until browned and caramelized. Make sure to stir every couple of minutes.
In a large bowl, add the tofu and mash it well with a fork or your hands. You can also blend it if you prefer a creamier filling.
Add in the tsp of garlic powder, 1/2 tsp black pepper and generous pinch of salt. Mix in the sauteed onion, corn, and shredded mozzarella and combine using your hands or a rubber spatula. Taste and adjust salt as needed.
Preheat the oven to 375 F
Layer about 1 1/2 cups of the marinara sauce on the bottom of a 9 x 13 baking dish or 12u0022 round dish.
Stuff the pasta shells with about 2 tbsp of the filling and place the stuffed shells on top of the layer of sauce. Repeat with remaining shells.
Once the shells are filled and lined up, pour the remaining marinara over the top, spoon the pesto around the dish and sprinkle the parmesan and crushed pistachios over the top.
Cover the pan and bake for 20 minutes, then finish baking uncovered on the top rack for 10 minutes. If you wanted to prepare this dish ahead of time, you can hold off on baking until 30-40 minutes before serving.
Garnish with fresh basil when serving.