Looking at the source code, I see that plugins are supported, and it appears that there are already several plugins included with KLayout.
I suspect you do not have documentation on writing plugins. That's fine. Can you just:
1. Confirm that KLayout really does support plugins.
2. Tell me which existing plugin would make a good model for me to study?