You are right. The CIA was in Afghanistan, mostly just supplying weapons, with the native Afghanis, different warlords, and the group that became Al-Qaeda.
I have read Ghost Wars, which is about as deep as I ever want to get into the history of Afghanistan.