Thats dangerous terratory because you dont want AI to always be better than players, youl always want players (despite some are worse than AI).
So making AI not be able to do some things is, well alright. The game was designed for Players anyway.
you say that but I intentionally put flaws in the script.
e.g. chems won't be maintained as buffs take priority when buffs wear off.
plus chems won't happen unless parts are on fire or the ship is in perfect health.
As for pie.
The AIs script routines are fine. Its the order of priority that's screwed up.
All it needs is an extra line of code where, parts with less than 50% hp take priority over higher priority parts with over 50%.
E.g. hull is the highest priority by default. But engines tend to die since AI are slow to tap a mallet at them since it is 3rd or 4th in its priority list.
This 50% rule also applies to part broken too. So the hull might be hurt (like 95% or even 60%), but the AI will rebuild a destroyed engine first b4 it top off the hull.
do that tiny tweak and AI will work fine. Not perfectly but much better than before.