Joan Kennedy was riding the roller coaster of spring primary victories and defeats. She stressed, as she had so many times in the campaign, positive thinking: "Whether we win or lose, I win. This campaign has been wonderful to me, the best thing in the world, next to getting sober. It's been terrific for my self-esteem."

Then she added -- flying in the face of cynics and skeptics who saw her presence in her husband's doomed presidential quest as a crass campaign charade -- "and it's been terrific for our marriage. We're doing something together."

On Tuesday, the Kennedys had breakfast together, and went to the swearing-in of President Ronald Reagan. Yesterday, they announced plans to divorce.

The Kennedy marriage of 22 years was a political marriage to the 10th power -- with every staggering reality played out on the nightly news: Chappaquiddick, alcoholism, their son's bone cancer, her three miscarriages, the numbing tragedy of two assassinations, constant tabloid reports of other women, her move to Boston, her return to the campaign trail. For Joan, who was more defenseless than Jackie, less the team player than Ethel, the competitive Kennedy world was often too much. Her escape into alcoholism was followed by her escape to Boston, where she studied music. All along, she talked of some day maybe getting the marriage back together.

But now the statement is short and clear: "With regret, yet with respect and consideration for each other, we have agreed to terminate our marriage." Friends of the senator -- ever aware of the view of Joan Kennedy, 44, as a highly exploited campaign commodity -- stress that the decision was mutual. Persistent critics of the senator saw Joan Kennedy as an exploited woman, felled by tragedies and an unhappy marraige and dragged back into the political scene by an insensitive husband who needed her to shore up the public image of his moral character.

Her husband -- forever viewed in the minds of many as a philanderer -- got a new image as Joan spoke during the campaign: "Perhaps the best result of my absence has been how close my husband, Ted, has grown to Patrick" (their youngest son). Joan the defender on Chappaquiddick: "After that, a lesser man might have abandoned public life, saying, 'I can't stand all this.' He stayed in the Senate. That takes fortitude. He told the truth. It's over.There is nothing he can do about Chappaquiddick now." Joan, the praiser, when the senator faced defeat after defeat: "When the going got rough Ted had wonderful grace in adversity." Her voice shook with anger. "The equanimity he had about those s.o.b.'s, those people who wouldn't come out for him." Joan, the proselytizer: "Ted has telephonitis and he's on the phone every night. I would in fact say that our problems have brought us much closer together."

But, the press wanted to know, did all this constitute love? The senator was ever awkward on the subject of his marriage. "Yes," Joan once said, "even if, after all these years, we don't hold hands."

Nevertheless, her presence became the "Joan Factor" as many speculated that, no matter how hard she tried, her presence was a detriment -- a constant reminder of their separation, of Chappaquiddick, of other women.

"Vote for Jimmy Carter, Free Joan Kennedy," was the blunt message of one bumper sticker. She was subject to the most painful personal questioning. oShe always referred to stories about him womanizing as "gossip and innuendo." And always said she believed his version of Chappaquiddick. Her answers on those subjects often moved people, even when as was often the case, they did not believe her.

Why was she sticking it out? became the constant question as even seasoned political reporters played Rona Barrett and speculated on the fragility of the marriage, and perhaps the White House would be one way to hold it together.

When Joan Kennedy first joined her husband's presidential campaign in December 1979, they were painfully awkward together. The senator did not touch her, look at her,, even talk to her as they stood woodenly side by side on platforms. As the campaign wore on, a certain treansformation took place. There was more ease, more genuine praise of each other, and more respect. "They have a helluva lot more respect for each other after going through that campaign than they did for the past three years," said one friend.

None of that was evident when the Kennedys, on her first campaign trip, staged a visit to her mother's Florida farm for maximum family exposure. Kennedy was living up to his Secret Service code name of "Sunburn." His face was red as he sat under an oak dripping with Spanish moss, eating barbecued ribs, looking embarrassed by the whole procedure, not talking to his wife for even one second as the cameras rolled. He spoke awkwardly of his wife handling "her" problem of alcholism, not "our" problem. Joan defended him. "I could have never gotten well without his support. He has been wonderful."

Months later Kennedy spoke enthusiasticalaly and easily of his wife as a limousine moved him through the streets of New York before that primary. "She is superb -- simply superb." By then, the saga of the evolution of Joan Kennedy from a vulnerable alcoholic to a woman in her own right was an unmistakable bit on the campaign trail. She used cue cards, made jokes when she couldn't find her place and was interrupted by applause so many times it astonished her.This is not to say her performance was artless. Women staffers briefed her on women's issues. The painful reality of her estrangement was glossed over, ignored or billed as "growth experience." Her struggle toward health was described as "finding herself."

Last spring, as hopes for the White House dimmed for even the most ardent supporter, both Kennedys kept saying she would move to the White House if the senator were elected. When asked if she would move back to Washington if her husband lost, Joan Kennedy would answer "sure." He was far less positive. "Well, that's something we'll talk about," was all he would say. "Right now we're not thinking about losing."

But lose he did. Joan continued to live in Boston, but made frequent trips to Washington. They took the children to Aspen on a Christmas ski trip. But the long attempt at making some sort of a go of it was over.

Father James English, a close friend as well as their priest, said yesterday, "They have been in a long and serious discussion about their lives with one another. There have been great strains in the marriage, but Joan campaigned very strenuously, genuinely, and would have continued on had be become president. But given the fact the children are pretty much grown up and given the divergent ways their lives have gone, both mutually felt they would probably be better friends if they no longer lived together."

Father English continued, "Two people can marry when they're very very young and Joan and Ted did that -- and can become in the course of their lives different people. They just don't match that well anymore. Joan is a quiet, private person and Ted has become this monumental public figure."

Father English said that "they are both good Catholics and to enter into a divorce was a very difficult decision to come to. That divorce is not recognized in the church. They will not be able to remarry in the Catholic church and both understand that." At this time, according to a Kennedy aide, neither of them has plans to remarry.

Long before Joan became a Kennedy, there were patterns of upbringing that shaped her sense of repression. "I was always supposed to be the 'sweet good girl' all the time. Not allowed to cry or be grumpy. Do you realize the terrible strain that is?" she said last spring, looking through her past. "You were told, 'Don't let your emotions out. Ladies don't do that.'" Since then, Joan Kennedy has known "incredible pain -- not only the pain of hangovers," she said with a laugh, "but emotional pain."

This was not evident on that Sunday in November 1958, when Joan, the golden girl, married the son of Joseph P. Kennedy, the founding father. A future president of the United States was best man. The New York Times wrote of her credentials: a June graduate of Manhattanville College, presented at the 1954 Gotham Ball and the Debutante Cotillion and Christmas Ball. Her indulgent and overprotective parents seemed bent all along on making sure Joan made a "good catch" and her businessman fathered urged her to meet Candy Jones, head of one of the most important modeling agencies. Joan, the model, made several thousand dollars before she graduated and soon married Ted Kennedy. That marriage, according to Lester David in his book, "Joan Kennedy," was well orchestrated by Joan's father, who arranged to have St. Joseph's Roman Catholic church lit up with floodlights and recorded the wedding on film.

When Joan first came to Washington, everyone was struck by her pristine beauty. Years later when talking of her extensive psychiatric visits she revealed her feelings of inadequacy as she struggled for a niche in the Kennedy lineup. Once asked how she would define herself, she answered with one-word clarity: "Vulnerable."

She was there at the graveside in the anthracite hills of northern Pennsylvania, beside her husband, at the funeral of Mary Jo Kopechne in July of 1969.

A year later she was campaigning for her husband's Senate race. She took off her shoes and bowled with a group of women who had their hair in pink crulers and giggled a lot and said, "Isn't she cute?" She plowed through an exhausting schedule that included a pat little speech and a "home movie" that looked as if it had been produced by MGM.

"Since Ted couldn't be here and neither could the children, I brought a home movie film taken on Cape Cod. I thought it would help you to get to know us." A sailboat shot: "There's my sister-in-law, Ethel." Louder claps. The boat was awash with children. "Most of the passengers belong to her." Laughter. Artful shots of the handsome family on the beach, accompanied by the roar of the waves, totally enthralled the unquestioning pro-Kennedy people of Massachusetts. It took an outsider to dub it the "Chappaquiddick antidote film."

Some time after that 1970 campaign she began to consult a psychiatrist regularly. "I had really lost my self-confidence. The only thing I knew that I was sure of was that I was a very attractive young woman and that I had a pretty good figure," she later said. She said of the Kennedys, "They're so good at everything, and I'm a flop."

She went through a period of dressing with inappropriate exhibitionism by Washington standards -- silver minis to the White House. The usually unbending Pat Nixon was photographed with her face almost slackjawed and her eyes on Joan Kennedy's hem. Then it was a leather skirt and boots and a see-through blouse. Another time gaucho pants. Joan was signaling that she needed help, not attention.

Throughout this year's campaign, Joan professed equanimity about reports of her husband and other women. She was not always so forgiving. "They went to the core of my self-esteem," she once said. "I began thinking, well, maybe I'm just not attractive enough, and it was awfully easy to say . . . if that's the way it is, I might as well have a drink."

After extensive therapy, diligent weekly visits to Alcoholics Anonymous, Joan Kennedy seems intent on retracting not what she is quoted as saying, but the truthfulness of her own feelings at the time. "All that old news," she commented last spring. "'I'm vulnerable and I don't like Washington and I really don't like Teddy.' If I've read it once, I've read it a million times. Alcoholics are so embarrassed they'll make up excuses, and I would run around making up reasons for how unhappy I was. I would grasp at anthing as an excuse for why I drank. I couldn't accept the fact I drank because I drank. Look at me now. I campaign six days a week. I have exams, and none of that stress bothers me now."

Joan Kennedy has grown with the times. A product of the '50s, her early life's fulfilment meant wifehood and motherhood, period. Her mail today is from women who admire her struggle and are trying to shape their individual needs to their roles as mothers and wives. The voice was hushed as she recalled the differences between her drinking days and now. "The last couple of years I never read the newspapers, never read magazines. I just really. . . " She paused. "I just couldn't keep up. Now there aren't enought hours in the day to study, to learn to grow ." Gone are most of the shadows of sorrow and puffiness of face that for the past few years had altered her once striking good looks. In her drinking days, photographers would catch her in strangely frumpy outfits with long, teased hair. During the campaign she wore a neat, shorter pageboy, designer clothes. Even at the end of the trail, after the Democratic Convention, Joan and Ted welcomed the press into their McLean home, and, as servants poured tea, joined easily in the jokes and laughter as everyone recalled bungled campaign stops. The couple did not look or sound like people devastated by defeat.

It is said, in fact, that the senator has an eye on running again in 1984. Cynics feel the divorce may well be a prelude to clear the air of a long tangled private life in preparation for such a venture four years from now. The senator and his wife are not explaining anything beyond their divorce statement at this time. The going word of the day is "friendship." "We intend to resolve as friends all matters relating to the dissolution of our marriage."

Joan will live in Boston, where she has kept an apartment overlooking the Charles River for two years. She spoke last spring of getting her master's degree in education by last summer, but she has not yet completed her studies at Lesley College. After she finishes, Joan Kennedy intends to work full-time in the field of music education with children, the divorce statement explained.

Patrick, 13, will live with his father in McLean, Kara, 20, and Edward M. Jr., 19, are in college.

Outsiders have persistently predicted another tailspin for Joan Kennedy, despite her protests that she has learned too much about self-preservation to be felled by alcohol or divorce or anything else. Once, talking about strength, she tapped her chest and said, "I have this inside me now." For one, Father English is quick to speculate that Joan Kennedy will do well on her own. "Very frankly, she has grown enormously in strength and as an independent person. I have every reason to believe she will do just fine."

No outsider can truly penetrate the private complexities and motives of any relationship. Father English said the Kennedys "just grew apart. There was a long percolation period, and all of a sudden, a click in the mind. One day you say, 'I can't keep trying. It isn't making sense any more.' For any couple that can be frightening -- but it can also bring great peace. I think they have that peace."

Yesterday aternoon, after the divorce statement reverberated from Kennedy's office, after it made the hourly news, after he refused many times to talk of it on television, saying that it was a private matter, a hugh basket of tulips and poppies arrived in the senator's office.

The flowers were from Joan Kennedy.