So it looks like you have a 3.9 final drive.
This is mostly from memory so check elsewhere before acting on any of this advice.
A 6MT swap out of an STI wouldn't be too bad. Make sure to get one with 1:1 rear transfer gears to work with your 3.9 final drive. The crossmember/mount is different but not a lot. You would probably need a shorter driveshaft. Front axles fit I think. I have read about some people using their five speed push type clutch but I'm not sure how that would work, you might need a 6MT STI flywheel/clutch/pressure plate/release bearing/starter. You'd want the 6MT shifter. The earlier (pre 2004) 6MTs from Japan are cheaper but weaker since they have a viscous center diff.
I haven't looked into them too closely, but the late model 6MT (Crosstrek, etc) looks like it uses a different shifter than the 5MT, doesn't have a VSS, and I think they're all 4.44 final drive.
If the original trans lasted a quarter million miles and you just want something similar but fresh and you're not doing anything abusive to the car, I'd stick with the 5MT. I don't know if that trans has a cable speedo or a speed sensor (VSS) but I think they are interchangeable without splitting the trans. Regardless you'd need a trans with a VSS or you'll probably piss off the ECU. So that means before 2009, depends on the model. After that they not only didn't machine the case for the VSS, they didn't machine third/fourth gear to drive it. I think in about 2000 or 2005, again depending on model, they went to the front CV axles with male splines at the trans. If you get one of those transmissions, which would likely have less wear and tear than an older trans, you'd either have to get the later model CV axles to go with it which probably use different ABS sensors or get transmission stubs from a 4EAT or STI 6MT (fairly cheap from the dealer). If you go with the stubs you'll either need to swap in smaller seals or get bearing sleeves (that's what mine did but I think they leak a little).
I got lucky with the last trans I bought, it had been sitting at a junkyard for a decade. It was out of a crash test car so it only had 52 miles on it. You can sort by mileage on car-part.com.
JDM should work too as far as I know, haven't looked into that for 5MT.
Your easiest and safest bet would be to figure out what 5MTs have 3.9 final drive. Secondary concern would be the other ratios but check on those. You can find some info on cars101.com. jdmfsm.info has factory service manuals, those should have ratios. You can also look up individual models/years on subarupartwholesale.com. One convenient thing about that is you can pick a complete trans or just the ring and pinion gear and find other models/years with the same trans or R&P. For instance looking up the 3.90 front R&P:
https://www.subarupartwholesale.com/p/Subaru_1995_Legacy-22L-MT-4WD-Brighton-Wagon/GEAR-SET-HYPOID/49247774/38100AB310.html
(click on what this fits)
Once you narrow it down a bit start looking on car-part.com for a local low mileage trans. Again if the original trans lasted 25 years you can probably get one from a junkyard with 100-150k miles on it for $500 or less that will last you a decade or so.