The easiest fix is to obtain a bunch of rolls of appropriate wire in guages that are at least as heavy as the OEM. Multiple colors will help, as will a wiring diagram for your model year.
Do this one at a time:
1. Cut out the burnt/melted wire at each end of the damaged area.
2. Using a wire of gauge the same or maybe one size larger, splice in a replacement wire to replace the cut section.
3. DO NOT use butt splice crimp connectors. I have seen too many of those wind up creating high resistance connections that causes further wiring melting.
4. Either use solder-type butt splices that use low temperature solder (that can be activated by a heat gun) or do the old fashioned solder and heat shrink tubing to restore each connection.
I know this sounds like a PITA, but early XJ/MJ wiring was sorta marginal, and fixing wires that were flakey with improved current carrying capacity (and reduced chances of heat damage) is a good thing.
My fuel injector harness on my XJ HO engine developed this issue due to engine heat, and after I discovered how pervasive the damage was, I bit the bullet and fixed all the suspect wires. Underhood (or under dash) wiring fires are no joke.