I don't know where you got CDI from.....................................
That looks to be an original loom, with a points ignition system. Separate coils, (4th pic), a separate rectifier, (last 2 pics) but it is serious work getting that sorted.
Any new to you bike, especially and old one like our XS650's, need to have every bullet connector, coupling, switches and earth's/grounds taken apart cleaned and reassembled, before trying to start it. I'm no electrical genius, or intermediate for that mater, but when i done my bike i used a continuity or Om meter on the loom before i took the connections apart and again after i cleaned and resembled them, and traced every wire as a part and through any switch and as a whole. An Om meter or continuity testing doesn't use any power it reads the resistance between point A and B, resistance is anything that will stop or reduce power along that line or circuit, could be corrosion on a connector, some wires broken in a connector. If this is done properly there should be no problems when hooking up the battery and running power.
A good Volt meter will have an Om's setting. Some say you can buy a cheap vault meter but the downfall of those are that the test leads are undersized and can give bad readings, need to buy a better set of leads or buy a meter with good leads, that usually means spending more for quality.
Working out a loom and relating it to a diagram was really difficult because i knew nothing but doing the connections and using the Om meter i learned what went where, and knew i had no resistance, (broken wires, shorts, corrosion and switches), through the loom.
You can still do that with the mess your looking at, From the pics i can't see a lot but it seems the PO has just removed the loom cover and made some alterations. Need to sort those out.
My philosophy is............. if i pay some one $100 to do a job i can spend up to $100 on the tools needed to do that job..............Then i can save a lot more money because i have the tools to do the things i would have to pay on another job