The general idea in the answer above is correct, but some of the details need to be looked at more closely.
The first step is as drawn in the original post. Deprotonation of the ketone, followed by nucleophilic addition to the alkyne gives an allene-type intermediate. Note that the anionic intermediate only has one geometry, it doesn't have cis and trans forms as the other answer suggests. Reprotonation gives us an enone with unspecified double bond geometry (likely a mix).
The final cyclisation involves forming the enolate of the ketone and then a nucleophilic acyl substitution on the ester. But to get there, we first need to make sure of the double bond geometry: the nucleophile (enolate) and the electrophile (ester) have to be cis to one another.
The way to do this is through tautomerisation of the enone. This converts the original double bond to a single bond, which can rotate freely. (There is some barrier to rotation because it is part of a conjugated diene; but the barrier is not that high, certainly nowhere near as high as a double bond, and can be overcome under usual reaction conditions.)
In general, if there were no other considerations at play, we would likely get an equilibrium mixture of isomers. However, only the correct geometry can go on to react here: so the 'correct geometry' will be continually depleted by forward reaction, and the equilibrium will shift; and eventually, all of it will be converted to the 'correct geometry'.
Once we've gotten there, it's just a matter of forming the enolate and kicking out the ethoxide.
Why does the enolate attack via oxygen rather than carbon? A simple explanation is that attack via oxygen forms a six-membered ring, whereas attack via carbon forms a four-membered ring, which is heavily disfavoured. Stereoelectronics also probably play a role: for the attack via carbon to proceed, the C=C π orbitals need to overlap with the C=O π* orbitals. This is almost impossible given the small ring size that would be formed, plus the extra double bond in the ring which makes the geometry of the entire molecule more rigid. On the other hand, the oxygen has lone pairs which point in all directions, so cyclisation is much easier.
NB: When drawing mechanisms, I would always suggest to use the resonance form of an enolate with the negative charge on oxygen. This is more representative of the actual electronic structure. For example, enolate geometry is an important consideration in organic chemistry; also, the stereoelectronic considerations above would be harder to pick out if we just thought it was a plain old lone pair on carbon. From an arrow-pushing point of view it's entirely equivalent, so there are no real excuses to draw a negative charge on carbon.