Poor little boy with such tummy problems
I can understand your concern but it sounds like he is getting a reasonable variety of foods - it's only really in our modern society we have an expectation for there to be huge variety, such a big variety isn't needed really so long as the food groups are covered.
but what should I give him, to be sure that is save for his stomake and age..
For his age there is not much you need to avoid, like I said, salt, sugar, whole nuts are the main things.
For his stomach though it really depends on what his true allergies are and what he can tolerate. As he grows and develops his gut will cope better with foods which might have previously given a tummy ache or gas but which were not a true allergy. So for example if you tried something when he was 6 or 8 months old which made him have stomach pain or gas it will not necessarily do so now - he is bigger and moving around more now so he can get gas out more easily.
It's great that you've worked out that he can have certain foods at lunch time but not dinner time
Even offering different foods at breakfast time can be helpful as it gives all day to digest and get gas out without disturbing night sleep.
It is important that LOs don't become badly constipated but at the same time they do need to learn to push the poo, I remember one of the nurses I spoke with when my DS was little telling me that there are times LOs need medication to help with constipation but if it can be avoided it is better as they need to learn to push hard which is a new thing for them after being on a milk heavy diet.
Perhaps if you offer finger foods (things like pasta and meat which you mentioned but also other finger foods such as veggies and fruits) and this is causing him some difficulty to poo, you can at the same meal give the apple puree/mashed which you have discovered helps keep things moving. To be honest quite a few LOs need a bit of a balancing act with their solids meals. I used to give mine soft prunes when he ate carrots because carrots made him a bit constipated but prunes kept it moving.
Where I live (UK) it is advised for ALL LOs to take a daily vitamin - do you have vitamin supplement for him? Here we can get vitamin drops for young children.
We also have certain foods which are fortified, for example some cereals are fortified with vitamins and minerals - not sure where you are or if something like this might be an option for you? As example, my DS ate baby muesli for a long time (long after he was a baby) which was mainly oats with some fruits and fortified.
It really looks like you are covering the food groups so I don't really think there is anything I could say is missing. I would try to offer more finger foods, I'm not sure if you are giving those veg and meat as finger foods or puree/mashed. At this point I would try to move away from all his food being mashed. You can also give LOs beans, fish and eggs so long as he has no allergy.
Don't worry about finding bits of food in his poo - this happens to all LOs. It will eventually stop happening.
Here are the links I found:
https://babywhispererforums.com/index.php?topic=251239.0 (a pdf file is linked in here)
https://babywhispererforums.com/index.php?topic=233269.0 (first link in here)
Honestly they both differ from the portions I found and jotted down when mine was younger but you shouldn't feel you have to stick to any of them rigidly, they are guides only and even from one guide to another they vary which just shows LOs are all different.