What's so hard about giving the AI the ability to 'see' those range circles you see when you hit alt? Then, each circle is weighted based off the strength of the object. So a starbase has a heavy weight, and a mine has a light weight. It only has to do this for static defenses, such as mines, turrets and starbases, right? If the fleet > than the weight, then go ahead and fly on through, otherwise the AI would be forbidden from intentionally going there. Will allow unintentional movement as we humans have those problems as well.
It wouldnt even be computationally expensive. you just precompute the weights for each defensive structure and add it into the game (heck, you could let these be moddable. They would be constants read from a file). When a ship phases in, it builds up the fleet's 'weight' to compare it to (this should be the only real thing done on the fly [Also note that an 'AIweight' variable could be added to each ship, thus allowing modding]). If the autocast/autotarget (which is really what the AI is) trys to target something that is in a bad weight zone, it's an invalid target and has to choose another. The key here is that the weight is bad anywhere in that range circle, not just for the object causing the bad weight.
This will help with the suicide-against-your-defenses style of the AI and your own AI. For ship to ship AI, that comes down to autotargeting priorities. There may be a few ways to improve this in a simple manner, but I'm thinking the AI will need to be given some kind of autotarget override occasionally to 'seem smart'. For example, I believe autotarget prioritizes a LF to attack another LF. Even if theres LRFs as well. If you have no counter for the LRFs to take them out, you and I know that you've got to make up for that deficiency somehow. The AI doesnt. So I would say the AI player should be granted the ability to override the autotarget to 'focus fire' on the ship class that is causing the most damage. Not sure how to code that, but that seems like a good idea to me.
The circles idea could also be extended to planets, with a slight change. The AI builds up a list of overall weight (as last seen by it) for the planets around it. it picks the planet with the lowest weight to attack. If all planets within range are of a higher weight than the fleet, it should recognize this and try to build up a bigger fleet first.
Or, simpler: when exploring/expanding, it builds up a list of next available targets (the ring of planets not owned by it along it's empire. uncolonizable are counted as owned). It adds new items to this list based off the amount of ships and defenses it saw there. When it attacks a planet and is forced to retreat, it moves this planet to the bottom of the list.