Mode-locked fiber lasers based on nonlinear polarization evolution can generate femtosecond pulses with different pulse widths and rich spectral distributions for versatile applications through polarization tuning. However, a precise and repeatable location of a specific pulsation regime is extremely challenging. Here, by using fast spectral analysis based on a time-stretched dispersion Fourier transform as the spectral discrimination criterion, along with an intelligent polarization search algorithm, for the first time, we achieved real-time control of the spectral width and shape of mode-locked femtosecond pulses;the spectral width can be tuned from 10 to 40 nm with a resolution of~1.47 nm, and the spectral shape can be programmed to be hyperbolic secant or triangular. Furthermore, we reveal the complex, repeatable transition dynamics of the spectrum broadening of femtosecond pulses, including five middle phases, which provides deep insight into ultrashort pulse formation that cannot be observed with traditional mode-locked lasers.