Plugin Development Guide¶
This guide provides a comprehensive walkthrough for creating a new Xcore plugin, from the initial directory setup to production deployment.
1. Initialization¶
Use the xcore CLI to scaffold a new plugin. This ensures you follow the standard directory structure and have a valid manifest.
This will create:
- plugin.yaml: The manifest file.
- src/main.py: The entry point with a boilerplate Plugin class.
- src/__init__.py: To make src a package.
- tests/: A folder for your unit tests.
2. Implementing Logic¶
Open src/main.py and implement your business logic. For Trusted plugins, inherit from TrustedBase.
3. Declaring Dependencies¶
If your plugin needs to call another plugin, declare it in plugin.yaml. Xcore will ensure the dependency is loaded before your plugin.
| plugin.yaml | |
|---|---|
4. Testing your Plugin¶
Xcore encourages testing plugins in isolation. You can use the Xcore instance in your tests to simulate the full environment.
5. Production Readiness¶
Before deploying to production, especially if strict_trusted is enabled, you must sign your plugin.
Step 1: Verification¶
Run the built-in scanner to check for common issues.
Step 2: Signing¶
Generate the HMAC signature file.
Deployment Checklist¶
-
plugin.yamlversion is bumped. -
execution_modeis correctly set. -
permissionsare as restrictive as possible. - Unit tests pass with 100% coverage.
-
plugin.sigis generated and up-to-date.
Next Steps¶
- Events & Hooks: Learn how to communicate asynchronously.
- Custom Services: Learn how to expose new capabilities to other plugins.
- Security Best Practices: Deep dive into the isolation layers.