Checkout the excellent scripts found here: https://github.com/JettMonstersGoBoom/Mega65
Or my less than excellent WIP script at: https://github.com/smnjameson/M65_Examples/blob/main/_include/aseparse65/asp65.j...
At the very least theres will give you an insight of how to write exporting tools and convertors for Aseprite.