Were there any intentions from the USSR to invade Germany before Operation Barbarossa? Did the USSR intelligence services know that Hitler had intentions to invade them?
There were many intelligence reports indicating that the Germans will invade Soviet Union in summer 1941. However the information was ambiguous, and Soviet government did not believe these reports. Neither they knew the date of the invasion with certainty. Nowadays, after the events, we can tell that some of these reports were exact. But there was no way to tell correct reports from incorrect ones before the invasion happened.
The plans of invasion of Germany in 1941 existed. There is a wide discussion of these plans in the Russian literature. However many documents of that time are still not available, they are still classified, so this discussion is not conclusive.
There are historians who argue that an invasion was planned on July 1941 (Victor Suvorov, Mark Solonin and others), and other historians who object this, and claim that no invasion was planned on summer 1941. There is no unambiguous evidence. There is no document ordering an invasion on a specified date.
But there seems to be a consensus that EVENTUALLY (perhaps in 1942) Stalin planned to join the war. In fact he and other Soviet government officials are on record saying this openly. None of them stated the date, of course.
EDIT. This discussion started with publication of Suvorov's book Icebreaker in 1987. Suvorov was a Soviet spy who defected to the West and was sentenced to death in absentia. He could use only openly published evidence in his book. His main argument was based on the configuration of Soviet troops in early summer 1941, which can be interpreted in two ways: a) planned invasion, or b) extreme stupidity. Since then, a lot of such secondary evidence has been collected, and some documents were published supporting his point of view, however there is no document which states a date of a planned invasion.
EDIT 2. Suvorov and Solonin are not professional historians. (Suvorov has military education, Solonin is an airspace engineer). Of Russian professional historians who generally share their point of view I can name Mikhail Meltyukhov. When we say "professional historian" we mean someone who has an academic degree in history. However it is difficult in Russia to obtain a degree if you agree with Suvorov in anything.
Speaking on Western historians, they prefer just not to discuss the subject. (At least I have never seen any serious discussion of this question by a non-Russian professional historian). And this also has a simple explanation. If your views strongly contradict the Russian official view on the subject which is considered "sacred" in Russia, you will be denied travel to Russia, access to archives etc. This would certainly be a very serious handicap for your career as a professional historian. So Western academic historians prefer to ignore the subject.
Myself, I am not claiming that Suvorov, Solonin and Meltyukhov are right. I am not a professional historian. And I would like very much some impartial Western historian write a book on the subject.
For comparison: how many Western (non Polish) historians dared to analyse the story of Katyn massacres, before the Russian government officially recognized it? How many Western historians dared to write about Gulag before this kind of literature was permitted in Soviet union? How much did Western media write about Holocaust when it was happening?
Regarding knowledge of the German invasion:
There was intelligence that an invasion would happen. There was also intelligence that an invasion would not happen. A heavily politicized intelligence apparatus failed to draw the right conclusions and to present them to the political leadership (i.e. Stalin).
Hindsight like the 2006 files makes it easy to highlight all the correct clues, and to dismiss those which pointed to an earlier date (when an invasion failed to materialize) or to no invasion.
Militaries have all sorts of war plans on file. Guess in which year the US considered war against the UK before you click this link.
So the relevant question becomes did Stalin have concrete intentions to invade in the early 1940s? The answer to that is probably not as the geopolitcs stood in 1941, but the Soviet Union was laying the groundwork to exploit opportunities in the future, e.g. by organizing German exiles.