French political commentators said today that the "Greenpeace affair" is likely to damage Socialist President Francois Mitterrand's chances of striking a bargain with a new right-wing legislature that is expected to emerge from crucial parliamentary elections next March.

The sabotage of a protest ship belonging to the environmentalist organization Greenpeace has already provoked the resignation of defense minister Charles Hernu, a close friend of Mitterrand. Hernu said yesterday that his senior military aides had failed to tell him the full truth about the sinking of the ship in New Zealand, where it had stopped en route to the South Pacific to protest French nuclear tests.

The Greenpeace scandal has erupted at a time when French politics is dominated by the question of whether a right-wing National Assembly would agree to "cohabit" with a left-wing president who still has two years of his mandate to run. The issue of "cohabitation," as it is known here, has shaped the behavior of government and opposition alike.

While Socialist Party leaders clearly hoped that the departure of Hernu and the head of the secret service would defuse a political time bomb that has been ticking away ever since the July 10 sinking, other commentators warned that the scandal may merely have entered a new phase with unpredictable consequences.

"The government remains vulnerable to the slightest piece of information that could resolve the mystery" of who ordered the sinking, said the right-wing Le Quotidien de Paris. "If it comes under suspicion itself, the result could be fatal."

French officials said Hernu's replacement as defense minister, Paul Quiles, had been told by the prime minister to produce a report on the Greenpeace affair within a week. Establishing the truth is likely to be a difficult task in view of the reluctance of senior secret service officials to divulge what they consider to be operational secrets.

Hernu's acknowledgment of a cover-up was interpreted widely today as implicit recognition by the Socialist government that the French secret services were involved in the sinking of the Greenpeace ship Rainbow Warrior. Two French agents are awaiting trial in New Zealand on charges of arson, conspiracy and murder of a Portuguese-born photographer who was killed in the attack.

Serge July, an influential political commentator, said Hernu's resignation played havoc with Mitterrand's plans for striking a deal with the right after next year's parliamentary elections. Hernu, who stressed the importance of maintaining a national consensus on defense policy, was the one Socialist minister who was considered to have had a chance of keeping his post in a new government dominated by the right.

"By sacrificing Hernu, Mitterrand has taken the risk of upsetting his entire political strategy. It must be assumed that he had no choice," wrote July in the independent leftist paper Liberation.

Under the Fifth Republic, the political system put into effect by the late Gen. Charles de Gaulle, a strong president elected to a seven-year term names a prime minister and Cabinet. The National Assembly has the power to force the dissolution of the government.

The prospect of "cohabitation" raises much greater uncertainty in France than it does in the United States, where the powers of the legislature and the executive are more clearly defined. The stability of Fifth Republic institutions has depended until now on the ability of the president to impose his choice of government and prime minister on the National Assembly.

During the past few months, Mitterrand has attempted to avert a constitutional crisis by marking out separate fields of activity for himself as president and a future government answerable to a right-wing assembly. Citing the constitution, he has suggested that the head of state be responsible for foreign and defense policies while the government look after the economy and domestic affairs.

The real danger of the Greenpeace scandal for Mitterrand, in the view of many political analysts, is that it undermines his reputation for competence and skill in the handling of national security issues. The upheavals at the Defense Ministry were a major setback to the president's attempts to turn the affair to his advantage by posing as the stubborn defender of France's nuclear deterrent.

French commentators pointed out that, by their handling of the Greenpeace affair, the Socialists have laid themselves open to renewed opposition charges that they are "amateurs" in the art of running a country. In the French political context, this is almost as damaging as allegations that they ordered the sinking of the Greenpeace ship.

The traditional mistrust between the Socialists and the military was highlighted by the refusal of the head of the secret services, Adm. Pierre Lacoste, to divulge the names of French agents who allegedly sunk the Rainbow Warrior to Hernu, his direct superior. In a letter explaining his refusal, which was published today, Lacoste said that publication of the names could have endangered the lives of French officers.

Lacoste's gesture was denounced by Socialist Party leaders as "political provocation," but defended by some right-wing spokesmen and former secret service officials.

"He refused to reveal the names of his soldiers because he did not want the government to treat them as scapegoats," remarked Jean Rochet, the former head of the internal counterespionag