In technologies operating at light wavelengths for wireless communication, sensor networks, positioning, and ranging, a dynamic coherent control and manipulation of light fields is an enabling element for properly generating and correctly receiving free-space optical (FSO) beams even in the presence of unpredictable objects and turbulence in the light path. In this work, we use a programmable mesh of Mach–Zehnder (MZI) interferometers to automatically control the complex field radiated and captured by an array of optical antennas. The implementation of local feedback control loops in each MZI stage, without global multivariable optimization techniques, enables an unlimited scalability. Several functionalities are demonstrated, including the generation of perfectly shaped beams with nonperfect optical antennas, the imaging of a desired field pattern through an obstacle or a diffusive medium, and the identification of an unknown obstacle inserted in the FSO path. Compared to conventional devices used for the manipulation of FSO beams, such as spatial light modulators, our programmable device can self-configure through automated control strategies and can be integrated with other functionalities implemented onto the same photonic chip.