I strongly support the above answers listed below. This is what I do and this is what other referees did with some of my papers:
fedja: I invariably do #1. Usually that is reciprocated with an offer of co-authorship, which I accept or decline based on the circumstances.
Nicholas Kuhn: Just do (1), and pat yourself on the back!
Yonatan Harpaz: Option (1) is definitely the professional course of action in this case.
However, sometimes an improvement is a jump from a 5 pages long paper to a 50 pages one. Let me say what happened to me once.
I refereed a paper of X. I liked the result and recommend it being published. But I also realized that the topic (not the method used in the paper) can lead to far better results. I asked Y (my student, postdoc or colleague) to work on it (the original paper has already been published). Then X submitted an $\varepsilon$ improvement of the previous result. That was a much weaker result than what I and Y could prove. What should I do? This is what I did:
I wrote to X asking them to withdraw the paper from the journal and join our team. The outcome was a win for everyone: I and Y were motivated by the work of X, and X became a coauthor of a very good paper, much better than their $\varepsilon$ improvement.
My advice is: be honest and straightforward and never let yourself go to the grey area as otherwise, sooner of later, you will have enemies. Sometimes it might mean giving up on your own ideas by leading others to improve their results. Well, someone will pay it pack, eventually.