Op-amp (LM358N) half-wave rectifier and 3.3V clamp
Input up to 18VAC sine waves (possibly noisy) up to 20khz. With minimized part count.


The choice of the LM358 is particularly problematic, it is not a rail-rail output and at 3.3V operation a poor candidate. The input common mode limitations force you far from zero for any comparison point. 

You would be much better doing the following:


Use a comparator meant for operation at low voltage,
Use a part that allows comparison at close to zero. 


Here is a potentially suitable circuit using the LM393 comparator:







simulate this circuit &ndash; Schematic created using CircuitLab


The LM393 works down to 3.3V single rail.
The trigger point is close to zero.
There is about 100mV hysteresis. You can alter R2 to change this.