I think programming companions to flank may be difficult. I usually just break contact and flank myself, a much simpler option. I like where your going with potion use though, I wonder if it would be easier to accomplish by adding a quick use slot for potions in your companions inventory page. For ranged companions (like Adoan) it might also be nice to place a melee weapon in a quick use slot and have them be able to automatically swap weapons if locked in melee combat.