You requirement to program the AVR over Serial from esp8266 SPIFFS is very specific. You could use the library called "dfu". I have its Arduino version here. It was made by arduino.org for the first Uno WiFi's esp8266 WiFiLink firmware. Here is the usage example.
With ISP/SPI wiring you can use the ESP8266AVRISP library. It is bundled with the esp8266 Arduino core. It has an example.
Over Serial but without SPIFFS storage, an esp8266 can also be used as direct network proxy for avrdude, where avrdude works over a network port communicating with a simple network to Serial sketch running on the esp8266.
Also an Arduino Mega can do a self update with my ArduinoOTA library and among other options for the transport of the updated binary the ArduinoOTA library can use my WiFiEspAT library which works with an ESP8266 or ESP32 with AT firmware.