Sorry, you're right, I cited the wrong case. in Cramer vs. USA (1945) there was never a question about whether Germany was an enemy. The focus was on whether Cramer provided aid or comfort, and the conclusion was that he didn't.
The definition of an "enemy" as a foreign power engaged in war with the USA comes from cases connected to the US Civil War, and English common-law sources used by the US Constitution framers.
Prosecutors face an enormous hurdle to charge someone with treason. Part of that hurdle is the fact that an enemy must be formally declared to be in a war with the USA before any charges of treason can be contemplated. This is as it should be: treason is a serious crime that demands serious conditions be met.
There are crimes other than treason that prosecutors can charge someone with for hostile acts against the USA. For example, the Rosenbergs were not charged with treason, but conspiracy to commit espionage, because at the time the USA was not at war with the Soviet Union, even though they were considered to be hostile adversaries.