The obvious solution is to use calibre, whose job is to package ebooks. The command-line interface to the conversion module accepts an OPF as input.
Or use the editor which handles all packaging and leaves you free to focus on the content.
Oh yeah, and I think Kovid finished the plugin system because it's an optional toolbar in the editor now. So extra functionality can be added in new an excitind ways.