|
| 1 | +# ElizaOS Plugin |
| 2 | + |
| 3 | +This is an ElizaOS plugin built with the official plugin starter template. |
| 4 | + |
| 5 | +## Getting Started |
| 6 | + |
| 7 | +```bash |
| 8 | +# Create a new plugin (automatically adds "plugin-" prefix) |
| 9 | +elizaos create -t plugin solana |
| 10 | +# This creates: plugin-solana |
| 11 | +# Dependencies are automatically installed and built |
| 12 | + |
| 13 | +# Navigate to the plugin directory |
| 14 | +cd plugin-solana |
| 15 | + |
| 16 | +# Start development immediately |
| 17 | +elizaos dev |
| 18 | +``` |
| 19 | + |
| 20 | +## Development |
| 21 | + |
| 22 | +```bash |
| 23 | +# Start development with hot-reloading (recommended) |
| 24 | +elizaos dev |
| 25 | + |
| 26 | +# OR start without hot-reloading |
| 27 | +elizaos start |
| 28 | +# Note: When using 'start', you need to rebuild after changes: |
| 29 | +# bun run build |
| 30 | + |
| 31 | +# Test the plugin |
| 32 | +elizaos test |
| 33 | +``` |
| 34 | + |
| 35 | +## Testing |
| 36 | + |
| 37 | +ElizaOS provides a comprehensive testing structure for plugins: |
| 38 | + |
| 39 | +### Test Structure |
| 40 | + |
| 41 | +- **Component Tests** (`__tests__/` directory): |
| 42 | + |
| 43 | + - **Unit Tests**: Test individual functions/classes in isolation |
| 44 | + - **Integration Tests**: Test how components work together |
| 45 | + - Run with: `elizaos test component` |
| 46 | + |
| 47 | +- **End-to-End Tests** (`e2e/` directory): |
| 48 | + |
| 49 | + - Test the plugin within a full ElizaOS runtime |
| 50 | + - Run with: `elizaos test e2e` |
| 51 | + |
| 52 | +- **Running All Tests**: |
| 53 | + - `elizaos test` runs both component and e2e tests |
| 54 | + |
| 55 | +### Writing Tests |
| 56 | + |
| 57 | +Component tests use Vitest: |
| 58 | + |
| 59 | +```typescript |
| 60 | +// Unit test example (__tests__/plugin.test.ts) |
| 61 | +describe('Plugin Configuration', () => { |
| 62 | + it('should have correct plugin metadata', () => { |
| 63 | + expect(starterPlugin.name).toBe('plugin-starter'); |
| 64 | + }); |
| 65 | +}); |
| 66 | + |
| 67 | +// Integration test example (__tests__/integration.test.ts) |
| 68 | +describe('Integration: HelloWorld Action with StarterService', () => { |
| 69 | + it('should handle HelloWorld action with StarterService', async () => { |
| 70 | + // Test interactions between components |
| 71 | + }); |
| 72 | +}); |
| 73 | +``` |
| 74 | + |
| 75 | +E2E tests use ElizaOS test interface: |
| 76 | + |
| 77 | +```typescript |
| 78 | +// E2E test example (e2e/starter-plugin.test.ts) |
| 79 | +export class StarterPluginTestSuite implements TestSuite { |
| 80 | + name = 'plugin_starter_test_suite'; |
| 81 | + tests = [ |
| 82 | + { |
| 83 | + name: 'example_test', |
| 84 | + fn: async (runtime) => { |
| 85 | + // Test plugin in a real runtime |
| 86 | + }, |
| 87 | + }, |
| 88 | + ]; |
| 89 | +} |
| 90 | + |
| 91 | +export default new StarterPluginTestSuite(); |
| 92 | +``` |
| 93 | + |
| 94 | +The test utilities in `__tests__/test-utils.ts` provide mock objects and setup functions to simplify writing tests. |
| 95 | + |
| 96 | +## Publishing & Continuous Development |
| 97 | + |
| 98 | +### Initial Setup |
| 99 | + |
| 100 | +Before publishing your plugin, ensure you meet these requirements: |
| 101 | + |
| 102 | +1. **npm Authentication** |
| 103 | + |
| 104 | + ```bash |
| 105 | + npm login |
| 106 | + ``` |
| 107 | + |
| 108 | +2. **GitHub Repository** |
| 109 | + |
| 110 | + - Create a public GitHub repository for this plugin |
| 111 | + - Add the 'elizaos-plugins' topic to the repository |
| 112 | + - Use 'main' as the default branch |
| 113 | + |
| 114 | +3. **Required Assets** |
| 115 | + - Add images to the `images/` directory: |
| 116 | + - `logo.jpg` (400x400px square, <500KB) |
| 117 | + - `banner.jpg` (1280x640px, <1MB) |
| 118 | + |
| 119 | +### Initial Publishing |
| 120 | + |
| 121 | +```bash |
| 122 | +# Test your plugin meets all requirements |
| 123 | +elizaos publish --test |
| 124 | + |
| 125 | +# Publish to npm + GitHub + registry (recommended) |
| 126 | +elizaos publish |
| 127 | +``` |
| 128 | + |
| 129 | +This command will: |
| 130 | + |
| 131 | +- Publish your plugin to npm for easy installation |
| 132 | +- Create/update your GitHub repository |
| 133 | +- Submit your plugin to the ElizaOS registry for discoverability |
| 134 | + |
| 135 | +### Continuous Development & Updates |
| 136 | + |
| 137 | +**Important**: After your initial publish with `elizaos publish`, all future updates should be done using standard npm and git workflows, not the ElizaOS CLI. |
| 138 | + |
| 139 | +#### Standard Update Workflow |
| 140 | + |
| 141 | +1. **Make Changes** |
| 142 | + |
| 143 | + ```bash |
| 144 | + # Edit your plugin code |
| 145 | + elizaos dev # Test locally with hot-reload |
| 146 | + ``` |
| 147 | + |
| 148 | +2. **Test Your Changes** |
| 149 | + |
| 150 | + ```bash |
| 151 | + # Run all tests |
| 152 | + elizaos test |
| 153 | + |
| 154 | + # Run specific test types if needed |
| 155 | + elizaos test component # Component tests only |
| 156 | + elizaos test e2e # E2E tests only |
| 157 | + ``` |
| 158 | + |
| 159 | +3. **Update Version** |
| 160 | + |
| 161 | + ```bash |
| 162 | + # Patch version (bug fixes): 1.0.0 → 1.0.1 |
| 163 | + npm version patch |
| 164 | + |
| 165 | + # Minor version (new features): 1.0.1 → 1.1.0 |
| 166 | + npm version minor |
| 167 | + |
| 168 | + # Major version (breaking changes): 1.1.0 → 2.0.0 |
| 169 | + npm version major |
| 170 | + ``` |
| 171 | + |
| 172 | +4. **Publish to npm** |
| 173 | + |
| 174 | + ```bash |
| 175 | + npm publish |
| 176 | + ``` |
| 177 | + |
| 178 | +5. **Push to GitHub** |
| 179 | + ```bash |
| 180 | + git push origin main |
| 181 | + git push --tags # Push version tags |
| 182 | + ``` |
| 183 | + |
| 184 | +#### Why Use Standard Workflows? |
| 185 | + |
| 186 | +- **npm publish**: Directly updates your package on npm registry |
| 187 | +- **git push**: Updates your GitHub repository with latest code |
| 188 | +- **Automatic registry updates**: The ElizaOS registry automatically syncs with npm, so no manual registry updates needed |
| 189 | +- **Standard tooling**: Uses familiar npm/git commands that work with all development tools |
| 190 | + |
| 191 | +### Alternative Publishing Options (Initial Only) |
| 192 | + |
| 193 | +```bash |
| 194 | +# Publish to npm only (skip GitHub and registry) |
| 195 | +elizaos publish --npm |
| 196 | + |
| 197 | +# Publish but skip registry submission |
| 198 | +elizaos publish --skip-registry |
| 199 | + |
| 200 | +# Generate registry files locally without publishing |
| 201 | +elizaos publish --dry-run |
| 202 | +``` |
| 203 | + |
| 204 | +## Configuration |
| 205 | + |
| 206 | +The `agentConfig` section in `package.json` defines the parameters your plugin requires: |
| 207 | + |
| 208 | +```json |
| 209 | +"agentConfig": { |
| 210 | + "pluginType": "elizaos:plugin:1.0.0", |
| 211 | + "pluginParameters": { |
| 212 | + "API_KEY": { |
| 213 | + "type": "string", |
| 214 | + "description": "API key for the service" |
| 215 | + } |
| 216 | + } |
| 217 | +} |
| 218 | +``` |
| 219 | + |
| 220 | +Customize this section to match your plugin's requirements. |
| 221 | + |
| 222 | +## Documentation |
| 223 | + |
| 224 | +Provide clear documentation about: |
| 225 | + |
| 226 | +- What your plugin does |
| 227 | +- How to use it |
| 228 | +- Required API keys or credentials |
| 229 | +- Example usage |
| 230 | +- Version history and changelog |
0 commit comments