This is such utter dogshite. That's all. It's transparently obvious why.
This is what you say when you don't have an answer.
They were an "ally" of the ruling party,
It wasn't the Soviet-Khalqist Friendship Treaty. The treaty was signed between the Soviets and Afghanistan as represented by the PDPA, not any particular faction of the PDPA.
until their betrayal and purge, at which point they were an "ally" of one faction of the ruling party, acting as its installed puppet. They were not an "ally" of Afghanistan itself as they massacred its civilian populace, looted and occupied it for a decade.
Just leaving out that Amin betrayed and purged various people among the leadership of Afghanistan. After the treaty. While the Afghan government was asking for troops from the Soviet Union. To respond to aggression that was backed by the United States; not just armed by the United States, but also recruited from other countries alongside Afghanistan and trained in Pakistan. But
that is somehow not an invasion
The Soviets had a relationship with Taraki and Amin-- principally Taraki-- and then Amin killed Taraki. Reacting to that jarring state of affairs with anything more than a shrug is "imperialism".
And nobody else agrees that their primary purpose was solely defending the Afghan state against that insurgency
That's why US intelligence estimates and diplomatic cables at the time favored arming Islamic extremists to increase the probability of a Soviet intervention. Because they thought the Soviets were going to do it anyway-- because they thought it was in the Soviet interest regardless. Oh wait, precisely the opposite was the case.
any more than I believe the US motivation for their 20 year occupation was solely the defeat of terrorist groups.
The American ruling class
profited mightily from the war in Afghanistan; the Soviet Union did not profit or gain from its intervention in Afghanistan nor did it seem like they expected to. The looting that you've referred to was battlefield and museum looting by Red Army commanders for souvenirs, not the sort of providing the entire world with opium that the United States pulled-- both during the Soviet Afghan intervention and during the US occupation. The former is frustrated asshole behavior (which, to be sure, the US has
also engaged in), the latter is actual imperialism. You're comparing apples and oranges.
The difference here is that you reject wholesale the flimsy excuses of the US military and government, while swallowing and regurgitating the flimsy excuses of the Soviet military and government.
The difference here is that you reflexively regurgitate the anti-communist sewage that we all swim in with the pretension that this makes you principled.
edit:
Of interest, here is a third perspective which disagrees with both of us in crucial respects.
Barack Obama is on record as advocating a military escalation in Afghanistan. Before sinking any deeper into that quagmire, we might do well to learn something about recent Afghani history and the role played by the United States.
www.commondreams.org