The best one to check is "AbilityRepairDroids".
aiUseTime "Anytime"
aiUseTargetCondition "HullDamageExceedsAmount"
onlyAutoCastWhenTargetHullDamageExceedsAmount //Here's the key bit;
Level:0 150.000000 //The ability triggers when a target has lost at least 150 hps.
Level:1 0.000000
Level:2 0.000000
isAutoCastAvailable TRUE
isAutoCastOnByDefault TRUE
This makes it so it will autocast when a target has taken at least 150 hull damage in the AoE. (This is because the buff repairs about 200 over its span IIRC) What you want to do is give an ability with this condition to a star/planet that will target ships in the gravity well. Now, this will have major issues in line with ships with different HP totals, and there's one way to help solve those, if you look at the other section of the AbilityRepairDroids file:
targetFilter
numOwnerships 1
ownership "Friendly"
numObjects 3
object "CapitalShip" //You'll want to cut this part out, and then make a seperate version with Capital-scale HP loss.
object "Frigate" //And this one, of course, you'll keep for the one with Frigate-scale HP loss.
object "PlanetModule"
numConstraints 2
constraint "NotSelf"
constraint "HasHullDamage"
Unfortunately I have yet to get ship abilities to work for planets. But if someone on here has, then you can use their advice, and the information you can glean from these files, to get it working. If you already know, good luck.
(The only reason you can't tie this to the ships themselves is because then the player could just disable them at-will. So either it needs an incentive to use, or it needs to be attached to an outside source.)
Edit: That works. Use the AbilityRepairDroids as a basis(exchanging the effects), and if you can hide the icon so it cannot be disabled, you'll be set. Now you just have to steal an ability from the capital ships and give them each a version tailored to their HPs, and then do the same to the frigates.