You definitely need to be treating the leaky gut if you are passing undigested food. Read the post about treat ing leaky gut, link below.
If I had leaky gut, I wouldn’t add any grains at all. Buckwheat isn’t a grain, so you might try making some bake goods using it. You’ll probably find some recipes on forum. You can also substitute buckwheat for the coconut flour in bread.
I see you’ve added coconut oil; how much are you taking at this time? Also how are you incresing the amounts? The oil can definitely help you gain weight or at least stop your weight loss.