Here is a post from a guy who sounds like he nailed it on I Love Jeeps forum.
Have you modified your grounding and charging circuits? The OEM wires are inadequate to support the full output of the alternator, and there's next to nothing for body grounds (though the vehicle seems to wanna run off of em !)... Net result is that your alternator isn't getting all that it's driving back into the battery or the systems it's supposed to be supporting... What you're describing is the "late stage" failure where the alternator spends a lot of time at full field and heats up causing all kinds of erratic behaviors.
Look at the alternator's output wire. ask yourself if you'd run an audio amp that may draw 30Amps peak on that tiny of a wire -- then try to figure out why Jeep tries to 'charge' from an alternator that can maintain steady output at 2-3 times the current (61 - 105 amp alternators are stock) that through that same wire? (Double it at least - add a larger gauge wire in parallel with the existing crappy wire...)
Dude - seriously -- look at a 100Amp (1200Watt) stereo wiring kit from "WalMart"... and then at the tiny factory charging and grounding stuff in the XJ, and try not to cry...
While you're there look for grounds. In the first couple of years of the 4.0 XJ, the battery wasn't provided with much of a serious body ground and the charging ground (back to the engine) wasn't much to talk about either... Look at where your headlamps ground (and the fan and the stereo and t rear defrost and the computers and ...)... ADD a strap from the battery to a good body point - and also from the battery to the block near the alternator (mounting bolt is top-flight for this)...
Typically, you'll see 1-2 volt improvement in charging (alternator is actually working less and delivering more usable power instead of heating-up crappy little or too long of wires) - the 1-2 volt improvement will be usable throughout your vehicle as well (path's back OUT of the battery are improved , alternator to body is improved, etc)...
If you've NOT modified this charging stuff in your XJ, then get that done before you try to chase ANY gremlins... I've seen XJs of this vintage come in with "electrical issues" to find that they're charging only through the head-strap and the OEM 8awg line. (alternator output reading at 14V with a batter charging voltage of 11.5 then only 8 or so at the headlamps!) Others were chargin only through broken motor mounts (I don't know how those started - the starter draw must'a been interesting!) Anyway -- I'll look for a write-up link on the "how to", but this is the #1 electrical issue for the early 4.0s and it acts EXACTLY like what you're talking about (and dim lights and plenty of other strange issues, including auto-tranny shifting issues)
Yep I have the shifting issues too. You must of nailed it !
I'll keep looking for the link if you can find it. While I'm waiting and hoping you can find it I'll check the stuff you mentioned. I have did the ground things already. The charging wire will probably be a good start.
Thanks a bunch !