Making the AI handle healers like players do is probably going to be somewhat difficult. It might get it right the first time it leaves base with Monks, but having it decide when to split them (i.e. to not split them off when it's being wailed on, is resummoning its dead healers, and its ally is nowhere nearby) and which other general to mutually share them with is probably a more complex change than the mod needs right at this moment, given that Nightmare AIs will already have a fairly significant healer advantage in the form of being able to buy high priests or bishops (or monks along with a full set of starter equipment) right out the door.
Edit: I see you're already handing them out to assassins. That's ok, but make sure you check being damaged / demigod health when deciding whether or not to split the healers off. AI summon healers in combat often, and having them send one away when they desperately need it isn't going to help AI difficulty much at all.
Let's focus on the basics until they're really, really solid, and then start adding in advanced tactics. Something like group ganking near a friendly tower would probably be much easier to implement than healer sharing, anyway, so starting with that would be a much better idea.
I haven't had time to test this out yet, but it sounds like you've made strides with the early citadel upgrade priorities vs item priorities, and in deciding which flag to capture, both of which are a big deal.
I did quickly browse some of the updated code (that I'm aware of), and noticed a few things:
1) Capture actions are looking at both flags and portals and checking distances to find out which flags go with which portals - this is unnecessary, as flags automatically set a FlagUnit class variable on any unit that they own. This means you can just use captureFlags[1].FlagUnit to get a definitive handle to that portal's flag, no matter how far it is from the portal.
2) There seem to be two copies of all of the AIGlobals citadel upgrade utility functions, one at the top, and one just above the cit upgrades. Harmless, but it had me confused for a second.
Had a few thoughts on retreating as well (which file are the retreat actions in? I can't find them):
1) If the AI in question is extremely far away from base, and has a teleport scroll, and has enough health to absorb 3 seconds of damage (in theory; I think there are already functions that estimate this?), it should really, really be teleporting out instead of trying to run back to base. The early running creates waaaaaaay too many easy kills for UB and DA. I imagine it should be possible to make it decide this based on (at least) distance to the health stone, if not other factors like incoming damage rate. Edit: Also consider distance to friendly towers, and when close enough, re-engage. I think it already does this, but other times it runs straight down an open lane instead of heading to the nearest tower.
2) In keeping with this, does the AI look at enemy demigod health and/or evaluate its health loss against enemy demigod health loss when deciding to retreat? And do potions in inventory affect its decision? What about remaining mana and cooldowns? I've had the .24 AI run from me many, many times when it probably could have won the fight, and definitely could have won the fight with one potion use (even small) or one more ability. Combined with the problem mentioned above, it creates easy kills that the AI shouldn't be giving up.