# Example Plugin A demonstration plugin showing how to build plugins for the Plugin Host system. ## Features This example demonstrates: - ✅ Plugin activation/deactivation lifecycle - ✅ Hook registration and execution - ✅ Event listening and emission - ✅ Configuration access - ✅ Logging utilities - ✅ Periodic tasks - ✅ Exported functions ## Structure ``` Plugin-Example/ ├── plugin.json # Plugin manifest ├── index.js # Main plugin code ├── package.json # NPM metadata └── README.md # This file ``` ## Plugin Manifest (`plugin.json`) The manifest defines your plugin's metadata: ```json { "id": "example-plugin", "name": "Example Plugin", "version": "1.0.0", "description": "An example plugin", "author": "Your Name", "main": "index.js", "repository": "http://your-git-repo", "config": { "greeting": "Hello from Example Plugin!" }, "permissions": ["hooks", "events"] } ``` ## Plugin API ### Lifecycle Methods ```javascript export async function activate(context) { // Called when plugin loads } export async function deactivate(context) { // Called when plugin unloads } ``` ### Context API ```javascript context.registerHook(hookName, callback) // Register a hook context.runHook(hookName, ...args) // Execute hooks context.getConfig(key) // Get config value context.log(...args) // Log with plugin prefix context.on(event, listener) // Listen to events context.emit(event, ...args) // Emit events ``` ## Creating Your Own Plugin 1. Copy this example 2. Edit `plugin.json` with your plugin details 3. Implement `activate()` and `deactivate()` in `index.js` 4. Add any additional functions/features 5. Submit to the Plugin Directory ## Hooks This example registers: - `on-startup` - Called when the system starts - `transform-data` - Transform data objects ## License MIT