Plugin Anatomy¶
An Xcore plugin is a self-contained directory that includes logic, metadata, and optional resources. Every plugin must follow a specific structure and provide a manifest file (plugin.yaml) for the framework to load it correctly.
Prerequisites¶
- Xcore Installation
- Basic knowledge of YAML syntax
Directory Structure¶
The standard structure for an Xcore plugin is:
- Manifest: Metadata, dependencies, and permissions.
- Source Code: Isolated namespace for the plugin logic.
- Entry Point: Contains the
class Plugin. - Persistent Data: The only directory writable by default in Sandboxed mode.
- Tests: Unit tests for the plugin.
The Manifest (plugin.yaml)¶
The manifest is the source of truth for the framework. It defines how the plugin should be executed and what resources it can access.
1. Identification¶
- Unique ID: Must be snake_case.
- Semantic Versioning: Used for dependency resolution.
- Compatibility: Xcore will refuse to load the plugin if the framework version is lower.
- Mode:
trusted(native) orsandboxed(isolated).
2. Dependencies¶
Declare other plugins your plugin depends on. Xcore uses this to determine the loading order (Waves).
3. Security & Permissions¶
Permissions are fail-closed. If not declared here, they are denied by default.
4. Sandbox Restrictions¶
Relevant only for execution_mode: sandboxed.
5. Environment & Configuration¶
Xcore supports environment variable substitution using ${VAR}.
- Resolved from the host system's environment variables.
- Available inside the plugin via
self.ctx.config.
Manifest Reference¶
| Field | Type | Default | Description |
|---|---|---|---|
name |
str |
Required | Unique identifier for the plugin. |
version |
str |
Required | Plugin version (SemVer). |
framework_version |
str |
"*" |
Minimum Xcore version required. |
execution_mode |
str |
"legacy" |
trusted or sandboxed. |
entry_point |
str |
"src/main.py" |
Path to the file containing class Plugin. |
requires |
list |
[] |
List of dependency objects (name + version). |
permissions |
list |
[] |
Explicit permissions for services and IPC. |
extra |
dict |
{} |
Arbitrary configuration parameters. |
Common Errors & Pitfalls¶
Invalid YAML Syntax
A simple indentation error in plugin.yaml will prevent the PluginLoader from even discovering the plugin. Use a YAML validator if the plugin doesn't appear in xcore plugin list.
Framework Version Mismatch
If you set framework_version: ">=3.0.0" but run Xcore 2.1.2, the plugin will be skipped during boot with a compatibility warning in the logs.
Entry Point Path
The entry_point path is relative to the plugin root. Ensure it points to the actual .py file, not just the directory.
Best Practices¶
Use semantic versioning
Always follow SemVer for your plugin versions. This ensures that dependents can safely use ^ (compatible) or ~ (patch) constraints.
Keep Extra Configuration Lean
Use the extra block for settings that change per environment. Hardcoded business logic should stay in your Python code.
See Also¶
- Trusted Plugins
- Implementing the
TrustedBasecontract. - Sandboxed Plugins
- Best practices for isolated plugin development.
- Dependency Management
- How Xcore resolves the loading order.