1. Leave the free version close sourced
2. Charge for the code for whoever wants to look at it.
Open the source, while retaining all rights. Which means that people can look at it, review it, find flaws, submit patches, etc. But cannot just put it, legally, on another application without your consent.
Of course nothing will stop an unscrupulous person to just ignore your license and use the code anyway.