This directory contains example plugins demonstrating how to create Pocket plugins in different languages.
- sentiment-analyzer: Sentiment analysis plugin that analyzes text and determines positive/negative/neutral sentiment
- word-counter: Word counting and text analysis plugin with configurable stop words and minimum word length
- json-transformer: JSON transformation plugin supporting flatten, nest, filter, map, and reduce operations
Each plugin directory contains:
- Source code in the respective language
manifest.yaml- Plugin metadata and configurationREADME.md- Plugin-specific documentation- Build instructions for compiling to WebAssembly
All plugins follow the same patterns:
- Memory Management: Export
allocanddeallocfunctions for memory allocation - Metadata Export: Export plugin metadata through the
metadatafunction - Call Function: Main
callfunction that handles prep/exec/post lifecycle - JSON Communication: All data exchange uses JSON encoding
- Error Handling: Proper error responses with descriptive messages
Each node in a plugin follows the Pocket lifecycle:
- Prep: Validate input, prepare data for processing
- Exec: Core business logic execution
- Post: Process results, determine routing, update state
To create a new plugin:
- Choose your language and copy the relevant example
- Modify the node types and logic for your use case
- Update the manifest.yaml with your plugin details
- Build the plugin to WebAssembly
- Install with
pocket plugins install ./
Each example includes test cases in the manifest that demonstrate:
- Expected inputs and outputs
- Configuration options
- Routing behavior
You can test plugins using:
pocket plugins test <plugin-name>