The MOPS SDK provides the core interfaces and types for developing MOPS plugins. This SDK enables independent plugin development without requiring the full MOPS core system.
- 🔌 Plugin Interface: Standard interface for MOPS plugins
- ⚡ Action System: Rich action execution framework with parameter validation
- 🏗️ Type System: Comprehensive type definitions for MOPS operations
- 📊 Version Management: API compatibility checking between plugins and core
- 🛡️ Validation: Built-in parameter and configuration validation
go mod init my-mops-plugin
go get github.com/totmicro/mops-sdk@latest
package main
import (
"fmt"
"github.com/totmicro/mops-sdk/actions"
"github.com/totmicro/mops-sdk/plugin"
"github.com/totmicro/mops-sdk/types"
)
// Plugin implementation
type MyPlugin struct{}
// NewPlugin is the required export function
func NewPlugin() plugin.Plugin {
return &MyPlugin{}
}
// Required plugin interface methods
func (p *MyPlugin) GetName() string { return "my-plugin" }
func (p *MyPlugin) GetVersion() string { return "1.0.0" }
func (p *MyPlugin) GetDescription() string { return "My awesome MOPS plugin" }
func (p *MyPlugin) GetAPIVersion() string { return "1.0.0" }
func (p *MyPlugin) Initialize(config *plugin.PluginConfig) error {
return nil
}
func (p *MyPlugin) GetProviders() []actions.DynamicProvider {
return []actions.DynamicProvider{}
}
func (p *MyPlugin) GetExecutors() []actions.ActionExecutor {
return []actions.ActionExecutor{&MyExecutor{}}
}
func (p *MyPlugin) GetFunctions() []actions.InteractiveFunction {
return []actions.InteractiveFunction{}
}
func (p *MyPlugin) Cleanup() error {
return nil
}
// Action executor implementation
type MyExecutor struct{}
func (e *MyExecutor) GetID() string {
return "my-action"
}
func (e *MyExecutor) GetActions() []actions.ActionInfo {
return []actions.ActionInfo{
{
ID: "hello",
Name: "Hello World",
Description: "Prints a hello message",
Parameters: []actions.ParameterInfo{
{
Name: "name",
Type: "string",
Description: "Name to greet",
Required: false,
Default: "World",
},
},
},
}
}
func (e *MyExecutor) Execute(actionID string, params map[string]interface{}) (*types.ActionResult, error) {
name, ok := params["name"].(string)
if !ok {
name = "World"
}
return &types.ActionResult{
Success: true,
Message: fmt.Sprintf("Hello, %s!", name),
Data: map[string]interface{}{"greeting": name},
}, nil
}
func (e *MyExecutor) Validate(actionID string, params map[string]interface{}) error {
return nil
}
// Required for plugin compilation
func main() {}
# Build as shared library
go build -buildmode=plugin -o my-plugin.so .
# Or use the MOPS plugin build tools for comprehensive validation
type Plugin interface {
GetName() string
GetVersion() string
GetDescription() string
GetAPIVersion() string
Initialize(config *PluginConfig) error
GetProviders() []actions.DynamicProvider
GetExecutors() []actions.ActionExecutor
GetFunctions() []actions.InteractiveFunction
Cleanup() error
}
type ActionExecutor interface {
GetID() string
GetActions() []ActionInfo
Execute(actionID string, params map[string]interface{}) (*types.ActionResult, error)
Validate(actionID string, params map[string]interface{}) error
}
types
: Core data structures and result typesactions
: Action execution interfaces and metadataplugin
: Plugin lifecycle and configuration interfacesversion
: Version management and compatibility checking
See the examples directory for complete plugin implementations:
- Simple Plugin: Basic plugin structure
- Action Plugin: Plugin with custom actions
- Provider Plugin: Plugin with dynamic menu providers
- Complex Plugin: Advanced plugin with multiple features
The MOPS SDK follows semantic versioning:
- 1.0.x: Stable API, backward compatible
- 1.x.x: Minor features, backward compatible
- x.x.x: Major changes, may require plugin updates
Current API version: 1.0.0
git clone https://github.com/totmicro/mops-sdk.git
cd mops-sdk
go mod tidy
go test ./...
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- 📖 Documentation
- 🐛 Issues
- 💬 Discussions
- 📧 Support Email