I'd look at one of the existing plugins and use that as a basis for moving forward in writing your own. Sadly there is no plugin guide yet, and I really want them to change it to make it a little more like Wordpress' plugin system and/or more API like.