The little starts you buy at the grocery store have recently undergone a huge amount of stress, and wilting after being brought home is relatively common. They are usually grown fast in a greenhouse, sometimes with supplementary CO2 to promote fast growth. They are then packed and shipped (ground or air and ground) for hours, sometimes over a day. This causes a huge amount of stress, and they are often kept metabolically slowed by refrigeration. Once they finally are through shipping, they are watered and placed in the store, where the lighting is lower than ideal, and often they are damaged somewhat by the output of ethylene from ripening fruits nearby. As a whole, the entire process is extremely stressful. The plants usually have to be replaced in less than 5 days.
The above is to explain part of why the chives are not adapting well. But to answer your question: When you are adapting any plant to a new environment, it is best done in a number of progressing steps, over a short period of time. This is called hardening off. For the new rosemary plant, I'd put it in a new pot, only slightly larger than what it's in now, with fresh potting mix without fertilizer. Keep it moist, and put it in a shady, protected area outdoors to start out. If you are expecting a big temperature drop, you can move it into the coolest part of your house or garage for a short time.
Each day, sit it in the area where you want it to stay later, in a fully sunny location, and leave it for a couple hours. Sit it out a little longer each day so that in a week or week and a half, the plant will be used to the sun and can stay there permanently. Once you see any new growth showing at the apex, you can begin fertilizing with a half strength soluble balanced fertilizer every other week, for a few weeks. The plant will eventually have to go dormant for winter, and you shouldn't promote new growth at that time. The goal is to have the plant grow some roots and become adapted before winter. If the plant puts on a good bit of growth, plant it in a garden bed or large pot before winter. Planting directly in the ground is preferable, as it's more natural, and in a large pot you must be much more careful about watering, etc, as large planters that aren't populated with plant roots tend to retain water longer, and there are other issues involved.
As for the chives, Now that they're repotted, I'd keep the mix moist and wait it out. It may be that they are already going dormant for the winter (mine have been over the past couple weeks), and there is nothing to worry about. Don't cut them unless they go entirely yellow, a sign of going dormant.
About overwintering indoors, these are temperate perennials, and will do very poorly indoors, especially overwinter. I would keep them in the ground, or large planters outdoors.