Smelly compost has several causes
1-Too many greens
With all other conditions right, the C:N balance of the heap is tilted to N. You'll get a rank odor and the bugs will love it. Being late summer, the bugs have gone through several reproductive cycles and will usually have their highest population of the year. Give em optimal conditions, they'll take over.
Solution: add lots of browns, toss the heap. Mixing in the browns will bring balance back into the heap and absorb odors. The bugs will run their
course and contribute greatly to decomposing the heap.
2-Too many greens, soggy mess
Lots of grass clippings and food scraps bring lots of moisture along and need to be balanced with browns to absorb the moisture. It is that moisture that promotes microbial activity, but it also prevents oxygen flow which limits the microbial activity to anaerobic in nature. Your heap is fermenting rather than composting. Since you have lots of bugs, there is plenty of oxygen.
Solution: add dry browns in no small amount, toss the pile. The browns will absorb the excess moisture and add oxygen-containing air pockets. Tossing the pile brings in oxygen.
3-Too much protein
Meat, cheese,
dairy, dead worms and bugs bring lots of protein to the heap. Protein decay involves a process known as putrefaction. It's smelly and can attract vermin. This is the chief reason compost instructions tell you not to add these items even though they'll rot just fine.
Solution: add browns, toss the pile. In this instance the browns serve to absorb the volatile aromatic compounds as well as fluids and excess moisture which enables the process.
4-Too much moisture
Perhaps your mix of greens and browns is right but the moisture is too high. The heap is packed and the water prevents airflow. Same situation as #2, but more of a musty, earthy odor which is not offensive.
Solution: add greens and browns in the right proportions, toss the pile. This adds material to absorb the excess water. You can also spread out the pile to let it dry out.
5-Not enough air flow
All conditions are right but the pile is not breathing. All the oxygen is used up.
Solution: Toss the heap. Adding ventilation to enclosed bins would alleviate further troubles.
As for the bugs...
It's the odor that has attracted the egg laying adults. Every bug in range will find the heap and add eggs. If you
feed greens to the heap, the bugs will keep on populating to the point of overshoot. Once the food source is depleted they will die off en mass. From what you describe you have problem #1 and will move into problem #3. Hay, dry grass, leaves, shredded newspaper, sawdust,
wood chips, bark, should be added in good volume. If getting rid of the bugs is the objective, dump the heap onto the ground, spread it out, let the birds get to it. They'll feast on the bugs in preparation for migration.