sdk

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2025 License: MIT Imports: 21 Imported by: 0

README

MOPS SDK

The MOPS SDK provides a simple and powerful way to create plugins for the MOPS (Modular Operations Platform System).

Overview

The SDK enables developers to create plugins that integrate seamlessly with MOPS, providing:

  • Dynamic menu entries
  • Custom action execution
  • Interactive streaming functions
  • CLI command extensions
  • Configuration management

Installation

go get github.com/totmicro/mops-sdk

Quick Start

Create a simple plugin:

package main

import (
    "context"
    "github.com/totmicro/mops-sdk"
)

func main() {
    plugin := sdk.NewPluginBuilder("my-plugin", "1.0.0", "My first MOPS plugin").
        AddExecutor("hello", func(ctx context.Context, params map[string]interface{}) (string, error) {
            return "Hello from my plugin!", nil
        }).
        Build()

    plugin.Start()
}

Features

  • Plugin Builder: Fluent API for plugin construction
  • Action Executors: Execute custom business logic
  • Menu Providers: Dynamic menu generation
  • Interactive Functions: Real-time user interaction
  • CLI Commands: Extend MOPS command-line interface
  • Configuration: Plugin-specific configuration management

Examples

See the examples/ directory for complete plugin examples:

  • hello-world/ - Basic plugin with actions and interactive functions

Development

Building a Plugin
go build -o my-plugin .
Testing with MOPS
# Copy plugin to MOPS plugins directory
cp my-plugin ~/.mops/plugins/

# Run MOPS
mops

Documentation

  • Plugin interface definitions in plugin.go
  • RPC implementation in rpc.go
  • Base plugin utilities in base.go
  • Builder pattern in builder.go

License

MIT License - See LICENSE file for details. )

func main() { plugin := sdk.NewPluginBuilder("env-manager", "1.0.0", "A simple environment manager plugin"). SetAuthor("Your Name"). SetLicense("MIT"). WithSimpleExecutor("hello", func(entry sdk.MenuEntry, input string) sdk.ActionResult { name := input if name == "" { name = "World" } return sdk.ActionResult{ Success: true, Output: fmt.Sprintf("Hello, %s!", name), ShowOutput: true, } }). Build()

sdk.Main(plugin)

}


## Plugin Builder API

### Creating a Plugin

```go
plugin := sdk.NewPluginBuilder("plugin-name", "1.0.0", "Plugin description")
Setting Metadata
plugin.SetAuthor("Author Name").
       SetLicense("MIT").
       SetHomepage("https://github.com/user/plugin").
       SetMopsVersions("1.0.0", "2.0.0").
       AddTag("utility").
       AddDependency("some-other-plugin")
Adding Functionality
Simple Action Executor
plugin.WithSimpleExecutor("my-action", func(entry sdk.MenuEntry, input string) sdk.ActionResult {
    return sdk.ActionResult{
        Success:    true,
        Output:     "Action executed successfully",
        ShowOutput: true,
    }
})
Dynamic Provider
plugin.WithSimpleProvider("my-provider", "Provides dynamic entries", func(param string) ([]sdk.MenuEntry, error) {
    return []sdk.MenuEntry{
        {
            Key:    "1",
            Label:  "Option 1",
            Action: "my-action",
        },
        {
            Key:    "2", 
            Label:  "Option 2",
            Action: "my-action",
        },
    }, nil
})
Interactive Function
plugin.WithInteractiveFunction("my-interactive", func(ctx context.Context, outputChan chan<- string, inputChan <-chan string, params map[string]interface{}) error {
    outputChan <- "Enter your name:"
    
    select {
    case name := <-inputChan:
        outputChan <- fmt.Sprintf("Hello, %s!", name)
    case <-ctx.Done():
        return ctx.Err()
    }
    
    return nil
})
CLI Command
plugin.WithCLICommand("hello", "Print a greeting", func(args []string) error {
    name := "World"
    if len(args) > 0 {
        name = args[0]
    }
    fmt.Printf("Hello, %s!\n", name)
    return nil
})

Plugin Structure

A typical plugin project structure:

my-plugin/
├── main.go           # Plugin entry point
├── go.mod           # Go module file
├── plugin.yaml      # Plugin metadata (optional)
├── Makefile         # Build configuration
├── README.md        # Plugin documentation
└── internal/        # Internal plugin code
    ├── core/        # Core plugin logic
    ├── cli/         # CLI command handlers
    └── ui/          # UI-related code

Building and Distribution

Local Development
go build -o my-plugin .
mkdir -p ~/.mops/plugins
cp my-plugin ~/.mops/plugins/
Multi-platform Build
# Linux AMD64
GOOS=linux GOARCH=amd64 go build -o my-plugin-linux-amd64 .

# macOS AMD64  
GOOS=darwin GOARCH=amd64 go build -o my-plugin-darwin-amd64 .

# Windows AMD64
GOOS=windows GOARCH=amd64 go build -o my-plugin-windows-amd64.exe .

Plugin Metadata (plugin.yaml)

name: my-plugin
version: 1.0.0
description: "My awesome plugin"
author: "Your Name"
license: "MIT"
homepage: "https://github.com/user/my-plugin"
tags:
  - "utility"
  - "example"

# MOPS version compatibility
mops_version:
  min_version: "1.0.0"
  max_version: "2.0.0"

# Build targets
build_targets:
  - os: linux
    arch: amd64
    output: my-plugin-linux-amd64
  - os: darwin
    arch: amd64
    output: my-plugin-darwin-amd64
  - os: windows
    arch: amd64
    output: my-plugin-windows-amd64.exe

# Default configuration
default_config:
  enabled: true
  timeout: 30

# CLI commands
cli_commands:
  - name: hello
    description: "Print a greeting"
    usage: "mops plugin my-plugin hello [name]"
    examples:
      - "mops plugin my-plugin hello"
      - "mops plugin my-plugin hello World"

Examples

Check the examples/ directory for complete plugin examples:

  • env-manager/ - Basic plugin with action executor
  • file-manager/ - Plugin with dynamic providers
  • interactive-demo/ - Plugin with interactive functions
  • cli-tools/ - Plugin with CLI commands

API Reference

Core Types
  • Plugin - Main plugin interface
  • PluginInfo - Plugin metadata
  • ActionResult - Result of action execution
  • MenuEntry - Menu entry definition
  • DynamicProvider - Interface for dynamic menu providers
  • ActionExecutor - Interface for action executors
  • InteractiveGoFunction - Interactive function type
Plugin Builder Methods
  • NewPluginBuilder(name, version, description) - Create new builder
  • SetAuthor(author) - Set plugin author
  • SetLicense(license) - Set plugin license
  • SetHomepage(url) - Set plugin homepage
  • AddTag(tag) - Add plugin tag
  • WithSimpleExecutor(type, handler) - Add action executor
  • WithSimpleProvider(name, description, handler) - Add dynamic provider
  • WithInteractiveFunction(name, handler) - Add interactive function
  • WithCLICommand(name, description, handler) - Add CLI command
  • Build() - Build the plugin

License

MIT License - see LICENSE file for details.

Documentation

Overview

Package sdk provides the MOPS SDK for building plugins

Index

Constants

View Source
const (
	SharedStorageSetMarker    = "MOPS_SHARED_SET:"
	SharedStorageGetMarker    = "MOPS_SHARED_GET:"
	SharedStorageListMarker   = "MOPS_SHARED_LIST"
	SharedStorageResultMarker = "MOPS_SHARED_RESULT:"
	SharedStorageErrorMarker  = "MOPS_SHARED_ERROR:"
)

Shared storage markers for interactive function communication

View Source
const (
	PluginName      = "mops-plugin"
	ProtocolVersion = 1
)
View Source
const EnvVarPrefix = "MOPS_ENV_"

Variables

View Source
var PluginMap = map[string]plugin.Plugin{
	PluginName: &MopsPlugin{},
}

PluginMap is the map of plugins we can dispense.

View Source
var WithInteractiveFunction = (*PluginBuilder).WithInteractiveFunction

Exported helpers and types for plugin authors

Functions

func GetParentMonitoringStatus added in v1.0.2

func GetParentMonitoringStatus() map[string]interface{}

GetParentMonitoringStatus returns information about the parent process monitoring This can be useful for debugging or status checks

func GetSharedVar added in v1.0.2

func GetSharedVar(key string) (string, error)

GetSharedVar retrieves a value from the host shared storage

func ListSharedVars added in v1.0.2

func ListSharedVars() ([]string, error)

ListSharedVars returns all keys in the host shared storage

func LogDebug added in v1.0.2

func LogDebug(component, msg string)

LogDebug logs a debug message using the global plugin logger

func LogDebugf added in v1.0.2

func LogDebugf(component, format string, args ...interface{})

LogDebugf logs a formatted debug message using the global plugin logger

func LogError added in v1.0.2

func LogError(component, msg string)

LogError logs an error message using the global plugin logger

func LogErrorf added in v1.0.2

func LogErrorf(component, format string, args ...interface{})

LogErrorf logs a formatted error message using the global plugin logger

func LogInfo added in v1.0.2

func LogInfo(component, msg string)

LogInfo logs an info message using the global plugin logger

func LogInfof added in v1.0.2

func LogInfof(component, format string, args ...interface{})

LogInfof logs a formatted info message using the global plugin logger

func LogWarn added in v1.0.2

func LogWarn(component, msg string)

LogWarn logs a warning message using the global plugin logger

func LogWarnf added in v1.0.2

func LogWarnf(component, format string, args ...interface{})

LogWarnf logs a formatted warning message using the global plugin logger

func LogWithFields added in v1.0.2

func LogWithFields(level LogLevel, component string, msg string, fields map[string]interface{})

LogWithFields logs a message with custom fields using the global plugin logger

func Main

func Main(pluginImpl Plugin)

Main is a convenience function to serve a plugin

func NewError added in v1.0.2

func NewError(format string, args ...interface{}) error

NewError creates a formatted error - helper function

func ParseAndValidateArgs added in v1.0.2

func ParseAndValidateArgs(args []string, definitions []ParameterDefinition) (map[string]string, error)

ParseAndValidate parses CLI arguments against parameter definitions and returns validated values

func SetHostSharedStorageClient added in v1.0.2

func SetHostSharedStorageClient(setVar func(string, string) error, getVar func(string) (string, error), listVars func() ([]string, error))

SetHostSharedStorageClient sets the host shared storage client This is called by the host during plugin initialization

func SetSharedVar added in v1.0.2

func SetSharedVar(key, value string) error

SetSharedVar stores a key-value pair in the host shared storage

Types

type ActionMappingBuilder added in v1.0.2

type ActionMappingBuilder struct {
	// contains filtered or unexported fields
}

ActionMappingBuilder provides a fluent interface for creating action mappings

func (*ActionMappingBuilder) AddInteractive added in v1.0.2

func (amb *ActionMappingBuilder) AddInteractive(mapping InteractiveMapping) *ActionMappingBuilder

AddInteractive adds a CLI command that maps to an interactive function

func (*ActionMappingBuilder) Build added in v1.0.2

func (amb *ActionMappingBuilder) Build() *PluginBuilder

Build finalizes the action mappings and returns the original builder

type ActionResult

type ActionResult struct {
	Success     bool
	Output      string
	Error       error
	ShowOutput  bool
	Title       string
	IsStreaming bool
	RefreshMenu bool // Indicates if the parent menu should refresh its dynamic content
}

ActionResult represents the result of executing an action

type AppState

type AppState int

AppState represents the application state

const (
	MainMenu AppState = iota
	DoneScreen
)

type ArgumentBasedActionConfig added in v1.0.2

type ArgumentBasedActionConfig struct {
	CommandName     string                // CLI command name
	Description     string                // CLI command description
	MenuID          string                // Menu ID for selection
	MenuTitle       string                // Menu title for interactive selection
	CLITitle        string                // Title for CLI execution (optional, defaults to MenuTitle)
	Items           []SelectionItem       // Selectable items
	Parameters      []ParameterDefinition // Parameter definitions for validation
	DirectFunction  InteractiveGoFunction // Function for direct CLI execution with args
	ExecuteFunction InteractiveGoFunction // Function for menu-based execution
	ExampleCommand  string                // Custom example command prefix (optional, defaults to plugin name)
}

ArgumentBasedActionConfig configures a complete CLI-with-args action pattern

type BuildTarget

type BuildTarget struct {
	OS     string `yaml:"os"`
	Arch   string `yaml:"arch"`
	Output string `yaml:"output"`
}

BuildTarget represents a build target configuration

type CLICommandConfig added in v1.0.2

type CLICommandConfig struct {
	Command     string
	Description string
	Handler     func(args []string) error
	UIAction    string
	UITarget    string
	UICommand   string
}

CLICommandConfig represents the configuration for a CLI command with UI mapping

func SmartCLICommand added in v1.0.2

func SmartCLICommand(command, description string, directExecutor func(args []string) error, interactiveFunctionName string) CLICommandConfig

SmartCLICommand creates a CLI command configuration with UI mapping that uses the smart selector pattern

type CLICommandExecuteArgs

type CLICommandExecuteArgs struct {
	Name string
	Args []string
}

type CLICommandExecuteResponse

type CLICommandExecuteResponse struct {
	Output string
	Error  error
}

type CLICommandHandler

type CLICommandHandler func(args []string) error

CLICommandHandler handles CLI command execution

type CLICommandInfo

type CLICommandInfo struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Usage       string   `json:"usage"`
	Examples    []string `json:"examples"`
	Hidden      bool     `json:"hidden,omitempty"` // Hide this command from CLI help and prevent execution with args

	// UI Action mapping - allows CLI commands to specify their UI equivalent
	UIAction  string `json:"ui_action,omitempty"`  // The UI action type (e.g., "goto", "core_interactive-go", "action")
	UITarget  string `json:"ui_target,omitempty"`  // For goto actions - the target menu/provider
	UICommand string `json:"ui_command,omitempty"` // For core_interactive-go actions - the command to execute
	UITitle   string `json:"ui_title,omitempty"`   // Custom title for Bubble Tea UI when executed via CLI
}

CLICommandInfo describes a CLI command provided by the plugin

type CLIShortcut added in v1.0.2

type CLIShortcut struct {
	Command     string // CLI command name
	MenuID      string // Target menu ID
	Description string // Description for help
}

CLIShortcut represents a CLI shortcut configuration

type CheckboxItem added in v1.0.2

type CheckboxItem struct {
	Key         string                 // Item key/identifier
	Label       string                 // Item display label
	Description string                 // Item description
	Params      map[string]interface{} // Parameters to pass when selected
	IsChecked   bool                   // Initial checked state
}

CheckboxItem represents an item in a checkbox menu

type ConfigPreset added in v1.0.2

type ConfigPreset struct {
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	Config      map[string]interface{} `json:"config"`
}

ConfigPreset represents a plugin configuration preset

type CrossPluginInvocationResult added in v1.0.2

type CrossPluginInvocationResult struct {
	Success bool
	Error   error
	Output  []string // Collected output lines
}

CrossPluginInvocationResult represents the result of a cross-plugin function call

type CrossPluginInvoker added in v1.0.2

type CrossPluginInvoker struct {
	// contains filtered or unexported fields
}

CrossPluginInvoker provides functionality to invoke functions from other plugins

func NewCrossPluginInvoker added in v1.0.2

func NewCrossPluginInvoker(ctx context.Context, outputChan chan<- string, inputChan <-chan string) *CrossPluginInvoker

NewCrossPluginInvoker creates a new cross-plugin invoker for interactive functions

func (*CrossPluginInvoker) InvokeFunction added in v1.0.2

func (c *CrossPluginInvoker) InvokeFunction(functionName string, params map[string]interface{}) (*CrossPluginInvocationResult, error)

InvokeFunction executes a function from another plugin

func (*CrossPluginInvoker) InvokeFunctionWithInput added in v1.0.2

func (c *CrossPluginInvoker) InvokeFunctionWithInput(functionName string, params map[string]interface{}, inputResponses []string) (*CrossPluginInvocationResult, error)

InvokeFunctionWithInput executes a function that may require user input This version handles interactive functions that prompt for user input

func (*CrossPluginInvoker) ListAvailableFunctions added in v1.0.2

func (c *CrossPluginInvoker) ListAvailableFunctions() ([]string, error)

ListAvailableFunctions returns a list of all available functions from all plugins

type DynamicMenuConfig added in v1.0.2

type DynamicMenuConfig struct {
	MaxEntries       int
	EnableExitButton bool
	ExitKey          string
	ExitLabel        string
	EmptyMessage     string
	EmptyKey         string
}

DynamicMenuConfig represents configuration for generating dynamic menus

func CLIDynamicMenuConfig added in v1.0.2

func CLIDynamicMenuConfig() DynamicMenuConfig

CLIDynamicMenuConfig returns a CLI-optimized configuration for dynamic menus

func DefaultDynamicMenuConfig added in v1.0.2

func DefaultDynamicMenuConfig() DynamicMenuConfig

DefaultDynamicMenuConfig returns a default configuration for dynamic menus

type DynamicProvider

type DynamicProvider interface {
	GetName() string
	GetDescription() string
	GenerateEntries(param string) ([]MenuEntry, error)
	SupportsRefresh() bool
}

DynamicProvider is an interface that provides dynamic menu entries

type DynamicProviderRPC

type DynamicProviderRPC struct {
	Name        string
	Description string
}

RPC argument types

type DynamicProviderRPCClient

type DynamicProviderRPCClient struct {
	// contains filtered or unexported fields
}

RPC client implementations

func (*DynamicProviderRPCClient) GenerateEntries added in v1.0.2

func (d *DynamicProviderRPCClient) GenerateEntries(param string) ([]MenuEntry, error)

func (*DynamicProviderRPCClient) GetDescription added in v1.0.2

func (d *DynamicProviderRPCClient) GetDescription() string

func (*DynamicProviderRPCClient) GetName

func (d *DynamicProviderRPCClient) GetName() string

func (*DynamicProviderRPCClient) SupportsRefresh added in v1.0.2

func (d *DynamicProviderRPCClient) SupportsRefresh() bool

type FavoriteItem added in v1.0.2

type FavoriteItem struct {
	Key    string                 // Unique key for the item
	Label  string                 // Display label
	Params map[string]interface{} // Additional parameters
}

FavoriteItem represents an item that can be marked as favorite

type FavoritesConfig added in v1.0.2

type FavoritesConfig struct {
	MenuID     string         // Menu ID for the favorites
	Title      string         // Menu title
	Items      []FavoriteItem // Items that can be favorited
	PluginName string         // Plugin name for config storage
	SummaryKey string         // Key for summary menu entry (optional)
}

FavoritesConfig represents configuration for favorites functionality

type FavoritesHelper added in v1.0.2

type FavoritesHelper struct {
	// contains filtered or unexported fields
}

FavoritesHelper provides common functionality for working with favorites across plugins Example usage:

var favoritesHelper = sdk.NewFavoritesHelper("my-plugin", map[string]string{
    "item1": "Item One",
    "item2": "Item Two",
})

// Use in plugin builder:
.AddInteractive(sdk.StreamingAction("favorites-summary", "Favorites summary",
    "my-plugin_favorites-summary", favoritesHelper.CreateFavoritesSummaryFunction(getCurrentPluginConfig)))

func NewFavoritesHelper added in v1.0.2

func NewFavoritesHelper(pluginName string, items map[string]string) *FavoritesHelper

NewFavoritesHelper creates a new favorites helper

func (*FavoritesHelper) CreateFavoritesSummaryFunction added in v1.0.2

func (f *FavoritesHelper) CreateFavoritesSummaryFunction(getPluginConfig func() map[string]interface{}) InteractiveGoFunction

CreateFavoritesSummaryFunction creates a ready-to-use interactive function for displaying favorites summary

func (*FavoritesHelper) DisplayFavoritesSummary added in v1.0.2

func (f *FavoritesHelper) DisplayFavoritesSummary(pluginConfig map[string]interface{}, outputChan chan<- string)

DisplayFavoritesSummary creates a favorites summary function that can be used as an interactive function

func (*FavoritesHelper) GetCurrentFavorites added in v1.0.2

func (f *FavoritesHelper) GetCurrentFavorites(pluginConfig map[string]interface{}) []string

GetCurrentFavorites reads the current favorites from plugin config

func (*FavoritesHelper) GetFavorites added in v1.0.2

func (f *FavoritesHelper) GetFavorites(pluginConfig map[string]interface{}) map[string]string

GetFavorites returns items that are currently favorites

func (*FavoritesHelper) GetNonFavorites added in v1.0.2

func (f *FavoritesHelper) GetNonFavorites(pluginConfig map[string]interface{}) map[string]string

GetNonFavorites returns items that are not currently favorites

type FormField added in v1.0.2

type FormField struct {
	Key   string // Field identifier
	Label string // Field display label
	Type  string // Field type (text, number, etc.)
}

FormField represents a form field configuration for input menus

type GitHubRelease added in v1.0.2

type GitHubRelease struct {
	TagName     string               `json:"tag_name"`
	Name        string               `json:"name"`
	Body        string               `json:"body"`
	Draft       bool                 `json:"draft"`
	Prerelease  bool                 `json:"prerelease"`
	PublishedAt time.Time            `json:"published_at"`
	HTMLURL     string               `json:"html_url"`
	Assets      []GitHubReleaseAsset `json:"assets"`
}

GitHubRelease represents a GitHub release

type GitHubReleaseAsset added in v1.0.2

type GitHubReleaseAsset struct {
	ID                 int64  `json:"id"`
	Name               string `json:"name"`
	Label              string `json:"label"`
	ContentType        string `json:"content_type"`
	Size               int64  `json:"size"`
	BrowserDownloadURL string `json:"browser_download_url"`
	URL                string `json:"url"` // API URL for authenticated downloads
}

GitHubReleaseAsset represents a release asset

type GitHubReleaseHelper added in v1.0.2

type GitHubReleaseHelper struct {
	// contains filtered or unexported fields
}

GitHubReleaseHelper provides utilities for working with GitHub releases

func NewAuthenticatedGitHubReleaseHelper added in v1.0.2

func NewAuthenticatedGitHubReleaseHelper() (*GitHubReleaseHelper, error)

NewAuthenticatedGitHubReleaseHelper creates a GitHub release helper with automatic gh CLI authentication

func NewGitHubReleaseHelper added in v1.0.2

func NewGitHubReleaseHelper() *GitHubReleaseHelper

NewGitHubReleaseHelper creates a new GitHub release helper

func NewGitHubReleaseHelperWithAuth added in v1.0.2

func NewGitHubReleaseHelperWithAuth(token string) *GitHubReleaseHelper

NewGitHubReleaseHelperWithAuth creates a new GitHub release helper with authentication

func (*GitHubReleaseHelper) CheckVersions added in v1.0.2

func (g *GitHubReleaseHelper) CheckVersions(owner, repo, currentVersion string) *VersionCheckResult

CheckVersions is a convenience method that checks both current and latest versions

func (*GitHubReleaseHelper) CompareVersions added in v1.0.2

func (g *GitHubReleaseHelper) CompareVersions(v1, v2 string) int

CompareVersions compares two semantic version strings Returns: -1 if v1 < v2, 0 if v1 == v2, 1 if v1 > v2

func (*GitHubReleaseHelper) DownloadAsset added in v1.0.2

func (g *GitHubReleaseHelper) DownloadAsset(asset *GitHubReleaseAsset, outputPath string) error

DownloadAsset downloads an asset from a private repository using authentication

func (*GitHubReleaseHelper) FindAssetByName added in v1.0.2

func (g *GitHubReleaseHelper) FindAssetByName(release *GitHubRelease, namePattern string) *GitHubReleaseAsset

FindAssetByName finds an asset by name pattern in a release

func (*GitHubReleaseHelper) GetLatestRelease added in v1.0.2

func (g *GitHubReleaseHelper) GetLatestRelease(owner, repo string) (*GitHubRelease, error)

GetLatestRelease fetches the latest release for a GitHub repository

func (*GitHubReleaseHelper) GetLatestVersion added in v1.0.2

func (g *GitHubReleaseHelper) GetLatestVersion(owner, repo string) (string, error)

GetLatestVersion returns just the version string from the latest release

func (*GitHubReleaseHelper) GetReleases added in v1.0.2

func (g *GitHubReleaseHelper) GetReleases(owner, repo string, limit int) ([]GitHubRelease, error)

GetReleases fetches all releases for a GitHub repository (up to 100)

func (*GitHubReleaseHelper) GetToken added in v1.0.2

func (g *GitHubReleaseHelper) GetToken() string

GetToken returns the GitHub token if available

func (*GitHubReleaseHelper) IsUpdateAvailable added in v1.0.2

func (g *GitHubReleaseHelper) IsUpdateAvailable(owner, repo, currentVersion string) (bool, string, error)

IsUpdateAvailable checks if an update is available for the given current version

type InputRequester added in v1.0.2

type InputRequester interface {
	// RequestInput sends a prompt and waits for user input
	RequestInput(prompt string) (string, error)
	// RequestInputWithDefault sends a prompt with a default value
	RequestInputWithDefault(prompt string, defaultValue string) (string, error)
	// RequestPassword sends a prompt and waits for hidden password input
	RequestPassword(prompt string) (string, error)
}

InputRequester provides methods for functions to explicitly request user input

func NewInputRequester added in v1.0.2

func NewInputRequester(ctx context.Context, outputChan chan<- string, inputChan <-chan string) InputRequester

NewInputRequester creates a new InputRequester instance

func NewInputRequesterWithSession added in v1.0.2

func NewInputRequesterWithSession(ctx context.Context, outputChan chan<- string, inputChan <-chan string, sessionID string) InputRequester

NewInputRequesterWithSession creates a new InputRequester instance with session ID

type InteractiveGoFunction

type InteractiveGoFunction func(ctx context.Context, outputChan chan<- string, inputChan <-chan string, params map[string]interface{}) error

InteractiveGoFunction represents a Go function that can be executed with real-time interaction

func CreateSmartSelector added in v1.0.2

func CreateSmartSelector(config SmartSelectorConfig) InteractiveGoFunction

CreateSmartSelector creates a smart selector function that handles both direct execution and interactive selection

type InteractiveMapping added in v1.0.2

type InteractiveMapping struct {
	CLIName        string                 // Name of the CLI command (e.g., "streaming")
	CLIDescription string                 // Description for CLI help
	UICommand      string                 // Interactive function name
	Function       InteractiveGoFunction  // The interactive function implementation (nil to use built-in)
	Params         map[string]interface{} // Parameters to pass to the interactive function
	Hidden         bool                   // Hide this command from CLI help and prevent CLI execution
	MenuTarget     string                 // Target menu for navigation when no CLI args provided
}

InteractiveMapping defines CLI to Interactive Function mappings

func CLIHiddenStreamingAction added in v1.0.2

func CLIHiddenStreamingAction(name, description, functionName string, function InteractiveGoFunction) InteractiveMapping

CLIHiddenStreamingAction creates an interactive mapping that's hidden from CLI help but available in UI

func SelectionAction added in v1.0.2

func SelectionAction(name, description, menuTarget string, directFunction InteractiveGoFunction) InteractiveMapping

SelectionAction creates a CLI command that shows a selection menu when no args provided, or executes directly when args are provided. Generic pattern for any CLI command with arguments.

func ShellAction added in v1.0.2

func ShellAction(name, description, command string) InteractiveMapping

ShellAction creates an interactive mapping for shell command execution using the built-in shell_command function

func StreamingAction added in v1.0.2

func StreamingAction(name, description, functionName string, function InteractiveGoFunction) InteractiveMapping

StreamingAction creates an interactive function mapping for real-time output

type InteractiveSharedStorage added in v1.0.2

type InteractiveSharedStorage struct {
	// contains filtered or unexported fields
}

InteractiveSharedStorage provides shared storage access during interactive function execution

func NewInteractiveSharedStorage added in v1.0.2

func NewInteractiveSharedStorage(ctx context.Context, outputChan chan<- string, inputChan <-chan string) *InteractiveSharedStorage

NewInteractiveSharedStorage creates a new shared storage accessor for interactive functions

func (*InteractiveSharedStorage) GetEnvVar added in v1.0.2

func (s *InteractiveSharedStorage) GetEnvVar(key string) (string, error)

GetEnvVar gets an environment variable from shared storage, removing MOPS_ENV_ prefix

func (*InteractiveSharedStorage) GetVar added in v1.0.2

func (s *InteractiveSharedStorage) GetVar(key string) (string, error)

GetVar gets a shared variable during interactive function execution

func (*InteractiveSharedStorage) ListEnvVars added in v1.0.2

func (s *InteractiveSharedStorage) ListEnvVars() ([]string, error)

ListEnvVars lists all environment variables (keys with MOPS_ENV_ prefix), returning keys without prefix

func (*InteractiveSharedStorage) ListVars added in v1.0.2

func (s *InteractiveSharedStorage) ListVars() ([]string, error)

ListVars lists all shared variables during interactive function execution

func (*InteractiveSharedStorage) SetEnvVar added in v1.0.2

func (s *InteractiveSharedStorage) SetEnvVar(key, value string) error

SetEnvVar sets an environment variable in shared storage with MOPS_ENV_ prefix

func (*InteractiveSharedStorage) SetVar added in v1.0.2

func (s *InteractiveSharedStorage) SetVar(key, value string) error

SetVar sets a shared variable during interactive function execution

type InteractiveStreamCleanupArgs added in v1.0.2

type InteractiveStreamCleanupArgs struct {
	SessionID string
}

type InteractiveStreamCleanupResponse added in v1.0.2

type InteractiveStreamCleanupResponse struct {
	Success bool
	Error   error
}

type InteractiveStreamInitArgs added in v1.0.2

type InteractiveStreamInitArgs struct {
	FunctionName string
	Params       map[string]interface{}
}

Streaming Interactive Function RPC Types

type InteractiveStreamInitResponse added in v1.0.2

type InteractiveStreamInitResponse struct {
	SessionID string
	Error     error
}

type InteractiveStreamInputArgs added in v1.0.2

type InteractiveStreamInputArgs struct {
	SessionID string
	Input     string
}

type InteractiveStreamInputResponse added in v1.0.2

type InteractiveStreamInputResponse struct {
	Success bool
	Error   error
}

type InteractiveStreamOutputArgs added in v1.0.2

type InteractiveStreamOutputArgs struct {
	SessionID string
}

type InteractiveStreamOutputResponse added in v1.0.2

type InteractiveStreamOutputResponse struct {
	NewOutput   []string
	Completed   bool
	Error       error
	NeedsInput  bool   // Indicates if the function is waiting for user input
	InputPrompt string // Optional prompt message for the input
}

type InteractiveStreamSession added in v1.0.2

type InteractiveStreamSession struct {
	FunctionName    string
	Params          map[string]interface{}
	OutputChan      chan string
	InputChan       chan string
	ErrorChan       chan error
	Context         context.Context
	Cancel          context.CancelFunc
	OutputBuffer    []string
	LastSentIndex   int // Track what has been sent to avoid duplicates
	Completed       bool
	FinalError      error
	WaitingForInput bool   // Track if function is waiting for input
	InputPrompt     string // Current input prompt
	// contains filtered or unexported fields
}

type LogLevel added in v1.0.2

type LogLevel string

LogLevel represents the logging level

const (
	DebugLevel LogLevel = "debug"
	InfoLevel  LogLevel = "info"
	WarnLevel  LogLevel = "warn"
	ErrorLevel LogLevel = "error"
)

type Logger added in v1.0.2

type Logger struct {
	*logrus.Logger
	// contains filtered or unexported fields
}

Logger provides a unified logging interface for plugins

func GetPluginLogger added in v1.0.2

func GetPluginLogger() *Logger

GetPluginLogger returns the global plugin logger instance

func InitPluginLogger added in v1.0.2

func InitPluginLogger(pluginName string) (*Logger, error)

InitPluginLogger initializes the logger for a plugin

func (*Logger) Close added in v1.0.2

func (l *Logger) Close() error

Close closes the log file

func (*Logger) Debug added in v1.0.2

func (l *Logger) Debug(msg string)

Debug logs a debug message

func (*Logger) Debugf added in v1.0.2

func (l *Logger) Debugf(format string, args ...interface{})

Debugf logs a formatted debug message

func (*Logger) Error added in v1.0.2

func (l *Logger) Error(msg string)

Error logs an error message

func (*Logger) Errorf added in v1.0.2

func (l *Logger) Errorf(format string, args ...interface{})

Errorf logs a formatted error message

func (*Logger) Info added in v1.0.2

func (l *Logger) Info(msg string)

Info logs an info message

func (*Logger) Infof added in v1.0.2

func (l *Logger) Infof(format string, args ...interface{})

Infof logs a formatted info message

func (*Logger) Warn added in v1.0.2

func (l *Logger) Warn(msg string)

Warn logs a warning message

func (*Logger) Warnf added in v1.0.2

func (l *Logger) Warnf(format string, args ...interface{})

Warnf logs a formatted warning message

func (*Logger) WithComponent added in v1.0.2

func (l *Logger) WithComponent(component string) *logrus.Entry

WithComponent adds a component field to log entries

func (*Logger) WithError added in v1.0.2

func (l *Logger) WithError(err error) *logrus.Entry

WithError adds an error field to log entries

func (*Logger) WithFields added in v1.0.2

func (l *Logger) WithFields(fields map[string]interface{}) *logrus.Entry

WithFields adds multiple fields to log entries

type Menu struct {
	ID            string          `yaml:"id"`
	Title         string          `yaml:"title"`
	Input         bool            `yaml:"input,omitempty"`
	Entries       []MenuEntry     `yaml:"entries,omitempty"`
	ConfirmAction *MenuAction     `yaml:"confirm_action,omitempty"`
	CancelKey     string          `yaml:"cancel_key,omitempty"`
	CancelNextID  string          `yaml:"cancel_next_id,omitempty"`
	Provider      string          `yaml:"provider,omitempty"`
	ProviderParam string          `yaml:"provider_param,omitempty"`
	Map           map[string]Menu `yaml:"-"`
	// Checkbox functionality
	IsCheckboxMenu bool        `yaml:"is_checkbox_menu,omitempty"` // Marks this menu as supporting checkboxes
	ExecuteAction  *MenuAction `yaml:"execute_action,omitempty"`   // Action to run with selected checkboxes
	ExecuteKey     string      `yaml:"execute_key,omitempty"`      // Key to trigger execute action (defaults to 'e')
}

Menu represents a menu definition

type MenuAction struct {
	Action  string                 `yaml:"action"`
	Target  string                 `yaml:"target,omitempty"`
	Command string                 `yaml:"command,omitempty"`
	NextID  string                 `yaml:"next_id,omitempty"`
	Params  map[string]interface{} `yaml:"params,omitempty"`
}

MenuAction represents a menu action

type MenuConfig struct {
	Menus []Menu `yaml:"menus"`
}

MenuConfig represents the menu configuration

type MenuEntry struct {
	Key           string                 `yaml:"key"`
	Label         string                 `yaml:"label"`
	ID            string                 `yaml:"id,omitempty"` // Unique identifier for CLI auto-execution
	Action        string                 `yaml:"action"`
	Target        string                 `yaml:"target,omitempty"`
	Message       string                 `yaml:"message,omitempty"`
	Command       string                 `yaml:"command,omitempty"`
	NextID        string                 `yaml:"next_id,omitempty"`
	FilePath      string                 `yaml:"file_path,omitempty"`
	Params        map[string]interface{} `yaml:"params,omitempty"`
	IsDynamic     bool                   `yaml:"-"`
	KeyBind       string                 `yaml:"key_bind,omitempty"`
	IsInteractive bool                   `yaml:"is_interactive,omitempty"`
	// Checkbox functionality
	IsCheckbox    bool   `yaml:"is_checkbox,omitempty"`    // Marks this entry as a checkbox
	IsChecked     bool   `yaml:"-"`                        // Runtime state - not persisted in YAML
	CheckboxGroup string `yaml:"checkbox_group,omitempty"` // Group name for related checkboxes
}

MenuEntry represents a menu entry

func GenerateAutoNumberedEntries added in v1.0.2

func GenerateAutoNumberedEntries(entries []MenuEntryConfig, config DynamicMenuConfig) []MenuEntry

GenerateAutoNumberedEntries creates auto-numbered menu entries from a list of entry configs

type MenuEntryConfig struct {
	Key     string
	Label   string
	Action  string
	Command string
	Target  string
	Message string
	Params  map[string]interface{}
}

MenuEntryConfig represents configuration for generating a single menu entry

type MopsPlugin

type MopsPlugin struct {
	// Impl Injection
	Impl Plugin
}

MopsPlugin is the implementation of plugin.Plugin so we can serve/consume this

func (*MopsPlugin) Client

func (p *MopsPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)

func (*MopsPlugin) Server

func (p *MopsPlugin) Server(*plugin.MuxBroker) (interface{}, error)

type MopsVersionConstraint

type MopsVersionConstraint struct {
	MinVersion string `yaml:"min_version"`
	MaxVersion string `yaml:"max_version"`
}

MopsVersionConstraint represents MOPS version compatibility

type NavMsg struct {
	Next          AppState
	NextID        string
	Data          any
	IsBack        bool
	Params        map[string]interface{}
	TitleOverride string
}

NavMsg represents navigation messages

type ParameterDefinition added in v1.0.2

type ParameterDefinition struct {
	Name         string        // Parameter name (used for flag parsing, e.g., "profile")
	Description  string        // Human-readable description
	Type         ParameterType // Parameter data type
	Required     bool          // Whether parameter is required
	Default      string        // Default value if not provided
	Pattern      string        // Regex pattern for validation (optional)
	MinValue     *int          // Minimum value for numeric types (optional)
	MaxValue     *int          // Maximum value for numeric types (optional)
	Choices      []string      // Valid choices for the parameter (optional)
	ExampleValue string        // Custom example value for documentation (optional)
}

ParameterDefinition defines validation rules and metadata for a parameter

func BoolParameter added in v1.0.2

func BoolParameter(name, description string, defaultValue bool) ParameterDefinition

BoolParameter creates a boolean parameter

func BoolParameterWithExample added in v1.0.2

func BoolParameterWithExample(name, description string, defaultValue bool, exampleValue string) ParameterDefinition

BoolParameterWithExample creates a boolean parameter with custom example

func ChoiceParam added in v1.0.2

func ChoiceParam(name, description string, choices []string, required bool) ParameterDefinition

ChoiceParam creates a parameter with predefined choices

func OptionalIntParam added in v1.0.2

func OptionalIntParam(name, description string, defaultValue int) ParameterDefinition

OptionalIntParam creates an optional integer parameter with default value

func OptionalIntParamWithExample added in v1.0.2

func OptionalIntParamWithExample(name, description string, defaultValue int, exampleValue string) ParameterDefinition

OptionalIntParamWithExample creates an optional integer parameter with default and example

func OptionalStringParam added in v1.0.2

func OptionalStringParam(name, description, defaultValue string) ParameterDefinition

OptionalStringParam creates an optional string parameter with default value

func OptionalStringParamWithExample added in v1.0.2

func OptionalStringParamWithExample(name, description, defaultValue, exampleValue string) ParameterDefinition

OptionalStringParamWithExample creates an optional string parameter with default and example

func PortParameter added in v1.0.2

func PortParameter(name, description string, required bool) ParameterDefinition

PortParameter creates a port parameter (required by default)

func RequiredIntParam added in v1.0.2

func RequiredIntParam(name, description string) ParameterDefinition

RequiredIntParam creates a required integer parameter

func RequiredIntParamWithExample added in v1.0.2

func RequiredIntParamWithExample(name, description, exampleValue string) ParameterDefinition

RequiredIntParamWithExample creates a required integer parameter with example

func RequiredStringParam added in v1.0.2

func RequiredStringParam(name, description string) ParameterDefinition

RequiredStringParam creates a required string parameter

func RequiredStringParamWithExample added in v1.0.2

func RequiredStringParamWithExample(name, description, exampleValue string) ParameterDefinition

RequiredStringParamWithExample creates a required string parameter with custom example

func (*ParameterDefinition) ValidateValue added in v1.0.2

func (p *ParameterDefinition) ValidateValue(value string) error

ValidateValue validates a parameter value against its definition

type ParameterType added in v1.0.2

type ParameterType string

ParameterType represents the data type of a parameter

const (
	StringParam ParameterType = "string"
	IntParam    ParameterType = "int"
	BoolParam   ParameterType = "bool"
	PortParam   ParameterType = "port"
	UrlParam    ParameterType = "url"
)

type PlatformInfo

type PlatformInfo struct {
	OS         string // "linux", "darwin", "windows"
	Arch       string // "amd64", "arm64"
	Platform   string // "linux-amd64", "darwin-arm64", etc.
	BinaryExt  string // ".exe" on Windows, "" on Unix
	ArchiveExt string // Expected archive extension: ".tar.gz", ".zip"
	InstallDir string // Default installation directory
	InPath     bool   // Whether install directory is in PATH
}

PlatformInfo contains platform-specific information

func GetCurrentPlatform

func GetCurrentPlatform() PlatformInfo

GetCurrentPlatform returns the current platform information

type Plugin

type Plugin interface {
	GetInfo() PluginInfo
	Initialize(config map[string]any) error
	ReloadConfig(config map[string]any) error
	RegisterProviders() []DynamicProvider
	RegisterInteractiveFunctions() map[string]InteractiveGoFunction
	GetCLICommands() (map[string]CLICommandHandler, error)
	GetStreamingCLICommands() (map[string]StreamingCLICommandHandler, error)
	GetMenuEntries() (map[string][]MenuEntry, error)
	Cleanup() error
	ValidateConfig(config map[string]any) error
}

Plugin is the interface that all plugins must implement

type PluginBase

type PluginBase struct {
	// contains filtered or unexported fields
}

PluginBase provides a base implementation for mops plugins

func NewPluginBase

func NewPluginBase(info PluginInfo) *PluginBase

NewPluginBase creates a new plugin base

func (*PluginBase) AddCLICommand

func (p *PluginBase) AddCLICommand(name string, handler CLICommandHandler)

AddCLICommand adds a CLI command to the plugin

func (*PluginBase) AddInteractiveFunction

func (p *PluginBase) AddInteractiveFunction(name string, fn InteractiveGoFunction)

AddInteractiveFunction adds an interactive function to the plugin

func (*PluginBase) AddMenuEntry

func (p *PluginBase) AddMenuEntry(menuID string, entry MenuEntry)

AddMenuEntry adds a menu entry to a specific menu

func (*PluginBase) AddProvider

func (p *PluginBase) AddProvider(provider DynamicProvider)

AddProvider adds a dynamic provider to the plugin

func (*PluginBase) AddStreamingCLICommand added in v1.0.2

func (p *PluginBase) AddStreamingCLICommand(name string, handler StreamingCLICommandHandler)

AddStreamingCLICommand adds a streaming CLI command to the plugin

func (*PluginBase) Cleanup

func (p *PluginBase) Cleanup() error

Cleanup performs cleanup when the plugin is being unloaded

func (*PluginBase) GetCLICommands

func (p *PluginBase) GetCLICommands() (map[string]CLICommandHandler, error)

GetCLICommands returns CLI command handlers

func (*PluginBase) GetInfo

func (p *PluginBase) GetInfo() PluginInfo

GetInfo returns metadata about the plugin

func (*PluginBase) GetMenuEntries

func (p *PluginBase) GetMenuEntries() (map[string][]MenuEntry, error)

GetMenuEntries returns menu entries that should be added to menus

func (*PluginBase) GetStreamingCLICommands added in v1.0.2

func (p *PluginBase) GetStreamingCLICommands() (map[string]StreamingCLICommandHandler, error)

GetStreamingCLICommands returns all streaming CLI commands

func (*PluginBase) Initialize

func (p *PluginBase) Initialize(config map[string]any) error

Initialize sets up the plugin with the provided config

func (*PluginBase) RegisterInteractiveFunctions

func (p *PluginBase) RegisterInteractiveFunctions() map[string]InteractiveGoFunction

RegisterInteractiveFunctions registers interactive functions with mops

func (*PluginBase) RegisterProviders

func (p *PluginBase) RegisterProviders() []DynamicProvider

RegisterProviders registers dynamic providers with mops

func (*PluginBase) ReloadConfig added in v1.0.2

func (p *PluginBase) ReloadConfig(config map[string]any) error

ReloadConfig reloads the plugin configuration without full restart

func (*PluginBase) ValidateConfig

func (p *PluginBase) ValidateConfig(config map[string]any) error

ValidateConfig validates the plugin configuration

func (*PluginBase) WithCLICommand

func (p *PluginBase) WithCLICommand(name string, handler CLICommandHandler) *PluginBase

WithCLICommand adds a CLI command to the plugin base

func (*PluginBase) WithInteractiveFunction

func (p *PluginBase) WithInteractiveFunction(name string, fn InteractiveGoFunction) *PluginBase

WithInteractiveFunction adds an interactive function to the plugin base

func (*PluginBase) WithMenuEntry

func (p *PluginBase) WithMenuEntry(menuID string, entry MenuEntry) *PluginBase

WithMenuEntry adds a menu entry to the plugin base

func (*PluginBase) WithSimpleProvider

func (p *PluginBase) WithSimpleProvider(name string, fn func(param string) ([]MenuEntry, error)) *PluginBase

WithSimpleProvider adds a simple provider to the plugin base

func (*PluginBase) WithStreamingCLICommand added in v1.0.2

func (p *PluginBase) WithStreamingCLICommand(name string, handler StreamingCLICommandHandler) *PluginBase

WithStreamingCLICommand adds a streaming CLI command to the plugin base

type PluginBuilder

type PluginBuilder struct {
	// contains filtered or unexported fields
}

PluginBuilder provides a fluent interface for creating plugins

func MustNewPluginBuilderFromEmbeddedYAML added in v1.0.2

func MustNewPluginBuilderFromEmbeddedYAML(embeddedData []byte) *PluginBuilder

MustNewPluginBuilderFromEmbeddedYAML creates a PluginBuilder from embedded YAML and panics on error

func NewPluginBuilder

func NewPluginBuilder(name, version, description string) *PluginBuilder

NewPluginBuilder creates a new plugin builder

func NewPluginBuilderFromEmbeddedYAML added in v1.0.2

func NewPluginBuilderFromEmbeddedYAML(embeddedData []byte) (*PluginBuilder, error)

NewPluginBuilderFromEmbeddedYAML creates a PluginBuilder from embedded YAML data

func NewPluginBuilderFromMetadata added in v1.0.2

func NewPluginBuilderFromMetadata(metadata *PluginMetadata) *PluginBuilder

NewPluginBuilderFromMetadata creates a PluginBuilder using provided metadata

func (*PluginBuilder) AddDependency

func (b *PluginBuilder) AddDependency(dependency string) *PluginBuilder

AddDependency adds a dependency to the plugin

func (*PluginBuilder) AddTag

func (b *PluginBuilder) AddTag(tag string) *PluginBuilder

AddTag adds a tag to the plugin

func (*PluginBuilder) Build

func (b *PluginBuilder) Build() Plugin

Build creates the plugin

func (*PluginBuilder) GetFullMenuID added in v1.0.2

func (b *PluginBuilder) GetFullMenuID(menuID string) string

GetFullMenuID returns the full prefixed menu ID for goto targets

func (*PluginBuilder) SetAuthor

func (b *PluginBuilder) SetAuthor(author string) *PluginBuilder

SetAuthor sets the plugin author

func (*PluginBuilder) SetDefaultConfig

func (b *PluginBuilder) SetDefaultConfig(config map[string]any) *PluginBuilder

SetDefaultConfig sets the default configuration

func (*PluginBuilder) SetDisplayName added in v1.0.2

func (b *PluginBuilder) SetDisplayName(displayName string) *PluginBuilder

SetDisplayName sets the plugin display name for UI

func (*PluginBuilder) SetHomepage

func (b *PluginBuilder) SetHomepage(homepage string) *PluginBuilder

SetHomepage sets the plugin homepage

func (*PluginBuilder) SetLicense

func (b *PluginBuilder) SetLicense(license string) *PluginBuilder

SetLicense sets the plugin license

func (*PluginBuilder) SetMopsVersions

func (b *PluginBuilder) SetMopsVersions(minVersion, maxVersion string) *PluginBuilder

SetMopsVersions sets the MOPS version constraints

func (*PluginBuilder) WithActionMappings added in v1.0.2

func (b *PluginBuilder) WithActionMappings() *ActionMappingBuilder

WithActionMappings adds multiple action mappings with a fluent interface

func (*PluginBuilder) WithArgumentBasedAction added in v1.0.2

func (b *PluginBuilder) WithArgumentBasedAction(config ArgumentBasedActionConfig) *PluginBuilder

WithArgumentBasedAction creates a complete CLI-with-args pattern: - CLI command with arguments executes directly - CLI command without arguments navigates to selection menu - UI menu provides interactive selection

func (*PluginBuilder) WithAutoConfigPresets added in v1.0.2

func (b *PluginBuilder) WithAutoConfigPresets() *PluginBuilder

WithAutoConfigPresets: Auto-load config presets from embedded metadata with hierarchical inheritance

func (*PluginBuilder) WithAutoStartMenu added in v1.0.2

func (b *PluginBuilder) WithAutoStartMenu(menuID string) *PluginBuilder

WithAutoStartMenu: Set a menu to start automatically when UI opens

func (*PluginBuilder) WithBasicMenuProvider added in v1.0.2

func (b *PluginBuilder) WithBasicMenuProvider(entries []MenuEntry) *PluginBuilder

WithBasicMenuProvider: Quickly define a main menu with minimal code

func (*PluginBuilder) WithCLICommand

func (b *PluginBuilder) WithCLICommand(name, description string, handler CLICommandHandler) *PluginBuilder

WithCLICommand adds a CLI command

func (*PluginBuilder) WithCLICommandAndUIMapping added in v1.0.2

func (b *PluginBuilder) WithCLICommandAndUIMapping(name, description string, handler CLICommandHandler, uiAction, uiTarget, uiCommand string) *PluginBuilder

WithCLICommandAndUIMapping adds a CLI command with UI action mapping

func (*PluginBuilder) WithCLICommandOptions added in v1.0.2

func (b *PluginBuilder) WithCLICommandOptions(name, description string, handler CLICommandHandler, hidden bool) *PluginBuilder

WithCLICommandOptions adds a CLI command with visibility options

func (*PluginBuilder) WithCheckboxMenu added in v1.0.2

func (b *PluginBuilder) WithCheckboxMenu(menuID, title string, items []CheckboxItem, executeFunction InteractiveGoFunction, executeKey string) *PluginBuilder

WithCheckboxMenu creates a menu with checkbox entries that can be toggled and executed in batch

func (*PluginBuilder) WithCheckboxMenuSimple added in v1.0.2

func (b *PluginBuilder) WithCheckboxMenuSimple(menuID, title string, itemLabels []string, executeFunction InteractiveGoFunction) *PluginBuilder

WithCheckboxMenuSimple creates a simple checkbox menu with string items

func (*PluginBuilder) WithCommandShortcuts added in v1.0.2

func (b *PluginBuilder) WithCommandShortcuts(shortcuts map[string]string) *PluginBuilder

WithCommandShortcuts: Add multiple CLI shortcuts at once

func (*PluginBuilder) WithConfigPreset added in v1.0.2

func (b *PluginBuilder) WithConfigPreset(name, displayName, description string, config map[string]interface{}) *PluginBuilder

WithConfigPreset adds a configuration preset

func (*PluginBuilder) WithConfigProvider added in v1.0.2

func (b *PluginBuilder) WithConfigProvider(componentName, param, description string, providerFunc func(string) ([]MenuEntry, error)) *PluginBuilder

WithConfigProvider adds a config provider with standardized naming (type: "config")

func (*PluginBuilder) WithDataProvider added in v1.0.2

func (b *PluginBuilder) WithDataProvider(componentName, param, description string, providerFunc func(string) ([]MenuEntry, error)) *PluginBuilder

WithDataProvider adds a data provider with standardized naming (type: "data")

func (*PluginBuilder) WithFavoritesMenu added in v1.0.2

func (b *PluginBuilder) WithFavoritesMenu(config FavoritesConfig) *PluginBuilder

WithFavoritesMenu adds a favorites toggle menu to the plugin This creates a menu where users can toggle items as favorites, with persistence

func (*PluginBuilder) WithFormMenu added in v1.0.2

func (b *PluginBuilder) WithFormMenu(menuID, title string, fields []FormField, submitAction string) *PluginBuilder

WithFormMenu: Create a form-based menu for input collection

func (*PluginBuilder) WithHiddenCLICommand added in v1.0.2

func (b *PluginBuilder) WithHiddenCLICommand(name, description string, handler CLICommandHandler) *PluginBuilder

WithHiddenCLICommand adds a hidden CLI command (won't appear in help and prevents execution with args)

func (*PluginBuilder) WithInteractiveFunction

func (b *PluginBuilder) WithInteractiveFunction(name string, fn InteractiveGoFunction) *PluginBuilder

WithInteractiveFunction adds an interactive function

func (*PluginBuilder) WithMainMenuProvider added in v1.0.2

func (b *PluginBuilder) WithMainMenuProvider(description string, providerFunc func(string) ([]MenuEntry, error)) *PluginBuilder

WithMainMenuProvider adds the main menu provider (type: "menu", param: "main")

func (*PluginBuilder) WithMenuEntry

func (b *PluginBuilder) WithMenuEntry(menuID string, entry MenuEntry) *PluginBuilder

WithMenuEntry adds a menu entry

func (*PluginBuilder) WithMenuIntegration added in v1.0.2

func (b *PluginBuilder) WithMenuIntegration(autoRegister bool, key, label, icon string, priority int) *PluginBuilder

WithMenuIntegration configures automatic menu integration

func (*PluginBuilder) WithMenuIntegrationAdvanced added in v1.0.2

func (b *PluginBuilder) WithMenuIntegrationAdvanced(integration PluginMenuIntegration) *PluginBuilder

WithMenuIntegrationAdvanced configures automatic menu integration with all options

func (*PluginBuilder) WithMenuProvider added in v1.0.2

func (b *PluginBuilder) WithMenuProvider(componentName, param, description string, providerFunc func(string) ([]MenuEntry, error)) *PluginBuilder

WithMenuProvider adds a menu provider with standardized naming (type: "menu")

func (*PluginBuilder) WithMenuStartupShortcut added in v1.0.2

func (b *PluginBuilder) WithMenuStartupShortcut(command, menuID, description string) *PluginBuilder

WithMenuStartupShortcut: Register a CLI command to start UI at a specific menu

func (*PluginBuilder) WithPluginFromYAML added in v1.0.2

func (b *PluginBuilder) WithPluginFromYAML() *PluginBuilder

WithPluginFromYAML: Auto-configure plugin from plugin.yaml metadata

func (*PluginBuilder) WithQuickMenu added in v1.0.2

func (b *PluginBuilder) WithQuickMenu(menuID, title string, entries []MenuEntry) *PluginBuilder

WithQuickMenu: Create a menu with minimal configuration using menu provider

func (*PluginBuilder) WithQuickSetup added in v1.0.2

func (b *PluginBuilder) WithQuickSetup(menuEntries []MenuEntry) *PluginBuilder

WithQuickSetup: One-liner to create a fully configured plugin (simplified to interactive functions only)

func (*PluginBuilder) WithSelectionMenuProvider added in v1.0.2

func (b *PluginBuilder) WithSelectionMenuProvider(menuID, title string, items []SelectionItem, executeFunction InteractiveGoFunction) *PluginBuilder

MenuProviderAction creates a standardized menu provider with auto-numbered entries that work with CLI arguments and UI interaction

func (*PluginBuilder) WithShellCommand added in v1.0.2

func (b *PluginBuilder) WithShellCommand(key, label, description, command string) *PluginBuilder

WithShellCommand adds a single shell command menu entry

func (*PluginBuilder) WithShellCommands added in v1.0.2

func (b *PluginBuilder) WithShellCommands(commands map[string]ShellCommandEntry) *PluginBuilder

WithShellCommands adds multiple shell command menu entries

func (*PluginBuilder) WithSimplePlugin added in v1.0.2

func (b *PluginBuilder) WithSimplePlugin(config SimplePluginConfig) *PluginBuilder

WithSimplePlugin: Creates a complete simple plugin with minimal configuration

func (*PluginBuilder) WithSimpleProvider

func (b *PluginBuilder) WithSimpleProvider(name, description string, fn func(param string) ([]MenuEntry, error)) *PluginBuilder

WithSimpleProvider adds a simple provider

func (*PluginBuilder) WithSmartCLICommand added in v1.0.2

func (b *PluginBuilder) WithSmartCLICommand(config SmartCLICommandConfig) *PluginBuilder

WithSmartCLICommand adds a CLI command that automatically handles both direct execution and interactive selection

func (*PluginBuilder) WithStandardInteractiveFunction added in v1.0.2

func (b *PluginBuilder) WithStandardInteractiveFunction(functionName string, function InteractiveGoFunction) *PluginBuilder

WithStandardInteractiveFunction adds an interactive function with standardized naming

func (*PluginBuilder) WithStandardProvider added in v1.0.2

func (b *PluginBuilder) WithStandardProvider(componentName, providerType, param, description string, providerFunc func(string) ([]MenuEntry, error)) *PluginBuilder

WithStandardProvider adds a provider with standardized naming and type

func (*PluginBuilder) WithStreamingCLICommand added in v1.0.2

func (b *PluginBuilder) WithStreamingCLICommand(name, description string, handler StreamingCLICommandHandler) *PluginBuilder

WithStreamingCLICommand adds a streaming CLI command that supports real-time output

func (*PluginBuilder) WithTags added in v1.0.2

func (b *PluginBuilder) WithTags(tags []string) *PluginBuilder

WithTags: Set multiple tags at once

func (*PluginBuilder) WithUnifiedProvider added in v1.0.2

func (b *PluginBuilder) WithUnifiedProvider(description string) *UnifiedProviderBuilder

WithUnifiedProvider adds a single unified provider that handles multiple contexts

type PluginInfo

type PluginInfo struct {
	Name               string                  `json:"name"`
	Version            string                  `json:"version"`
	Description        string                  `json:"description"`
	DisplayName        string                  `json:"display_name,omitempty"` // Optional display name for UI
	Author             string                  `json:"author"`
	License            string                  `json:"license"`
	Homepage           string                  `json:"homepage"`
	MopsMinVersion     string                  `json:"mops_min_version"`
	MopsMaxVersion     string                  `json:"mops_max_version"`
	Dependencies       []string                `json:"dependencies"`
	Tags               []string                `json:"tags"`
	CLICommands        []CLICommandInfo        `json:"cli_commands"`
	DefaultConfig      map[string]any          `json:"default_config"`
	ConfigPresets      map[string]ConfigPreset `json:"config_presets,omitempty"`
	Platform           PlatformInfo            `json:"platform"`
	SupportedPlatforms []PlatformInfo          `json:"supported_platforms"`
	MenuIntegration    *PluginMenuIntegration  `json:"menu_integration,omitempty"`
}

PluginInfo contains metadata about a plugin

type PluginInfoRPC

type PluginInfoRPC struct {
	Name               string                 `json:"name"`
	Version            string                 `json:"version"`
	Description        string                 `json:"description"`
	DisplayName        string                 `json:"display_name,omitempty"` // Optional display name for UI
	Author             string                 `json:"author"`
	License            string                 `json:"license"`
	Homepage           string                 `json:"homepage"`
	MopsMinVersion     string                 `json:"mops_min_version"`
	MopsMaxVersion     string                 `json:"mops_max_version"`
	Dependencies       []string               `json:"dependencies"`
	Tags               []string               `json:"tags"`
	CLICommands        []CLICommandInfo       `json:"cli_commands"`
	DefaultConfigJSON  string                 `json:"default_config_json"` // JSON-encoded config to avoid GOB issues
	ConfigPresetsJSON  string                 `json:"config_presets_json"` // JSON-encoded presets to avoid GOB issues
	Platform           PlatformInfo           `json:"platform"`
	SupportedPlatforms []PlatformInfo         `json:"supported_platforms"`
	MenuIntegration    *PluginMenuIntegration `json:"menu_integration,omitempty"` // Menu integration config
}

PluginInfoRPC is a GOB-safe version of PluginInfo for RPC transport

func NewPluginInfoRPC

func NewPluginInfoRPC(info PluginInfo) (PluginInfoRPC, error)

NewPluginInfoRPC converts PluginInfo to PluginInfoRPC

func (*PluginInfoRPC) ToPluginInfo

func (rpc *PluginInfoRPC) ToPluginInfo() (PluginInfo, error)

ToPluginInfo converts PluginInfoRPC to PluginInfo

type PluginMenuIntegration added in v1.0.2

type PluginMenuIntegration struct {
	AutoRegister bool   `yaml:"auto_register"` // Whether to automatically add to main menu
	MenuID       string `yaml:"menu_id"`       // Which menu to integrate with (default: "main")
	Key          string `yaml:"key"`           // Shortcut key for the menu entry
	Label        string `yaml:"label"`         // Display label for the menu entry
	Icon         string `yaml:"icon"`          // Optional icon/emoji for the menu entry
	Priority     int    `yaml:"priority"`      // Priority for ordering (lower = higher priority)
	Group        string `yaml:"group"`         // Optional grouping for organizing menu items
}

PluginMenuIntegration defines how a plugin integrates with MOPS menus

type PluginMetadata

type PluginMetadata struct {
	Name               string                  `yaml:"name"`
	Version            string                  `yaml:"version"`
	Description        string                  `yaml:"description"`
	DisplayName        string                  `yaml:"display_name,omitempty"`
	Author             string                  `yaml:"author"`
	License            string                  `yaml:"license"`
	Homepage           string                  `yaml:"homepage"`
	Repository         string                  `yaml:"repository"`
	Category           string                  `yaml:"category"`
	Tags               []string                `yaml:"tags"`
	MinimumMopsVersion string                  `yaml:"minimum_mops_version"`
	MopsVersion        MopsVersionConstraint   `yaml:"mops_version"`
	BuildTargets       []BuildTarget           `yaml:"build_targets"`
	DefaultConfig      map[string]any          `yaml:"default_config"`
	ConfigPresets      map[string]ConfigPreset `yaml:"config_presets,omitempty"`
	CLICommands        []CLICommandInfo        `yaml:"cli_commands"`
	MenuIntegration    *PluginMenuIntegration  `yaml:"menu_integration,omitempty"`
}

PluginMetadata represents the plugin.yaml file structure

func LoadPluginMetadataFromBytes added in v1.0.2

func LoadPluginMetadataFromBytes(data []byte) (*PluginMetadata, error)

LoadPluginMetadataFromBytes loads metadata from YAML bytes (for embedded data)

type PluginRPCClient

type PluginRPCClient struct {
	// contains filtered or unexported fields
}

PluginRPCClient is an implementation of Plugin that talks over RPC.

func (*PluginRPCClient) Cleanup

func (g *PluginRPCClient) Cleanup() error

func (*PluginRPCClient) GetCLICommands

func (g *PluginRPCClient) GetCLICommands() (map[string]CLICommandHandler, error)

func (*PluginRPCClient) GetInfo

func (m *PluginRPCClient) GetInfo() (*PluginInfo, error)

func (*PluginRPCClient) GetMenuEntries

func (g *PluginRPCClient) GetMenuEntries() (map[string][]MenuEntry, error)

func (*PluginRPCClient) GetStreamingCLICommands added in v1.0.2

func (g *PluginRPCClient) GetStreamingCLICommands() (map[string]StreamingCLICommandHandler, error)

func (*PluginRPCClient) Initialize

func (g *PluginRPCClient) Initialize(config map[string]any) error

func (*PluginRPCClient) RegisterInteractiveFunctions

func (g *PluginRPCClient) RegisterInteractiveFunctions() map[string]InteractiveGoFunction

func (*PluginRPCClient) RegisterProviders

func (g *PluginRPCClient) RegisterProviders() []DynamicProvider

func (*PluginRPCClient) ReloadConfig added in v1.0.2

func (g *PluginRPCClient) ReloadConfig(config map[string]any) error

func (*PluginRPCClient) ValidateConfig

func (g *PluginRPCClient) ValidateConfig(config map[string]any) error

type PluginRPCServer

type PluginRPCServer struct {
	Impl Plugin
}

PluginRPCServer is the RPC server that PluginRPCClient talks to

func (*PluginRPCServer) Cleanup

func (s *PluginRPCServer) Cleanup(args interface{}, resp *error) error

func (*PluginRPCServer) CleanupInteractiveStream added in v1.0.2

func (s *PluginRPCServer) CleanupInteractiveStream(args *InteractiveStreamCleanupArgs, resp *InteractiveStreamCleanupResponse) error

func (*PluginRPCServer) ExecuteCLICommand

func (s *PluginRPCServer) ExecuteCLICommand(args *CLICommandExecuteArgs, resp *CLICommandExecuteResponse) error

func (*PluginRPCServer) ExecuteStreamingCLICommand added in v1.0.2

func (s *PluginRPCServer) ExecuteStreamingCLICommand(args *CLICommandExecuteArgs, resp *CLICommandExecuteResponse) error

func (*PluginRPCServer) GenerateProviderEntries

func (s *PluginRPCServer) GenerateProviderEntries(args *ProviderGenerateEntriesArgs, resp *[]MenuEntry) error

func (*PluginRPCServer) GetCLICommands

func (s *PluginRPCServer) GetCLICommands(args interface{}, resp *map[string]CLICommandInfo) error

func (*PluginRPCServer) GetInfo

func (s *PluginRPCServer) GetInfo(args interface{}, resp *PluginInfoRPC) error

func (*PluginRPCServer) GetInteractiveStreamOutput added in v1.0.2

func (s *PluginRPCServer) GetInteractiveStreamOutput(args *InteractiveStreamOutputArgs, resp *InteractiveStreamOutputResponse) error

func (*PluginRPCServer) GetMenuEntries

func (s *PluginRPCServer) GetMenuEntries(args interface{}, resp *map[string][]MenuEntry) error

func (*PluginRPCServer) GetStreamingCLICommands added in v1.0.2

func (s *PluginRPCServer) GetStreamingCLICommands(args interface{}, resp *map[string]CLICommandInfo) error

func (*PluginRPCServer) InitInteractiveStream added in v1.0.2

func (s *PluginRPCServer) InitInteractiveStream(args *InteractiveStreamInitArgs, resp *InteractiveStreamInitResponse) error

func (*PluginRPCServer) Initialize

func (s *PluginRPCServer) Initialize(configJSON string, resp *error) error

func (*PluginRPCServer) RegisterInteractiveFunctions

func (s *PluginRPCServer) RegisterInteractiveFunctions(args interface{}, resp *map[string]string) error

func (*PluginRPCServer) RegisterProviders

func (s *PluginRPCServer) RegisterProviders(args interface{}, resp *[]DynamicProviderRPC) error

func (*PluginRPCServer) ReloadConfig added in v1.0.2

func (s *PluginRPCServer) ReloadConfig(configJSON string, resp *error) error

func (*PluginRPCServer) SendInteractiveStreamInput added in v1.0.2

func (s *PluginRPCServer) SendInteractiveStreamInput(args *InteractiveStreamInputArgs, resp *InteractiveStreamInputResponse) error

func (*PluginRPCServer) ValidateConfig

func (s *PluginRPCServer) ValidateConfig(args map[string]any, resp *error) error

type ProviderGenerateEntriesArgs

type ProviderGenerateEntriesArgs struct {
	Name  string
	Param string
}

type Registry

type Registry interface {
	RegisterProvider(provider DynamicProvider)
	GetProvider(name string) (DynamicProvider, bool)
	ListProviders() []string
}

Registry interface for managing providers

type RepositoryPlugin

type RepositoryPlugin struct {
	Name        string                           `json:"name"`
	Version     string                           `json:"version"`
	Description string                           `json:"description"`
	Author      string                           `json:"author"`
	License     string                           `json:"license"`
	Homepage    string                           `json:"homepage"`
	Repository  string                           `json:"repository"`
	Tags        []string                         `json:"tags"`
	MopsVersion MopsVersionConstraint            `json:"mops_version"`
	Platforms   map[string]RepositoryPluginAsset `json:"platforms"`
	Checksums   map[string]string                `json:"checksums"`
	LastUpdated time.Time                        `json:"last_updated"`
}

RepositoryPlugin represents a plugin entry in a repository registry

type RepositoryPluginAsset

type RepositoryPluginAsset struct {
	Platform struct {
		OS   string `json:"os"`
		Arch string `json:"arch"`
	} `json:"platform"`
	DownloadURL string `json:"download_url"`
	Size        int64  `json:"size"`
	Checksum    string `json:"checksum"`
	Filename    string `json:"filename"`
}

RepositoryPluginAsset represents a platform-specific plugin asset

type RepositoryRegistry

type RepositoryRegistry struct {
	Repository struct {
		Name        string    `json:"name"`
		Description string    `json:"description"`
		URL         string    `json:"url"`
		LastUpdated time.Time `json:"last_updated"`
		Version     string    `json:"version"`
	} `json:"repository"`
	Plugins map[string]RepositoryPlugin `json:"plugins"`
}

RepositoryRegistry represents a registry of all plugins in a repository

type SelectionItem added in v1.0.2

type SelectionItem struct {
	Name        string                 // Item name/identifier
	Description string                 // Item description
	Icon        string                 // Item icon/emoji
	Title       string                 // Custom title for Bubble Tea UI (optional)
	Params      map[string]interface{} // Parameters to pass to the execute function
}

SelectionItem represents a selectable item in a menu

type ShellCommandEntry added in v1.0.2

type ShellCommandEntry struct {
	Label       string // Display label for the menu entry
	Description string // Description/message for the entry
	Command     string // Shell command to execute
}

ShellCommandEntry represents a shell command configuration

type SimplePluginConfig added in v1.0.2

type SimplePluginConfig struct {
	Author               string                           // Plugin author
	DisplayName          string                           // Plugin display name
	AutoLoadPresets      bool                             // Whether to auto-load presets from plugin.yaml
	InteractiveFunctions map[string]InteractiveGoFunction // Interactive functions
	MenuEntries          []MenuEntry                      // Menu entries for UI
	CLIShortcuts         []CLIShortcut                    // CLI shortcuts for menu access
}

SimplePluginConfig provides a configuration structure for quick plugin setup

type SimpleProvider

type SimpleProvider struct {
	// contains filtered or unexported fields
}

SimpleProvider provides a convenient way to create basic providers

func NewSimpleProvider

func NewSimpleProvider(name string, fn func(param string) ([]MenuEntry, error)) *SimpleProvider

NewSimpleProvider creates a new simple provider

func (*SimpleProvider) GenerateEntries added in v1.0.2

func (p *SimpleProvider) GenerateEntries(param string) ([]MenuEntry, error)

GenerateEntries returns the menu entries

func (*SimpleProvider) GetDescription added in v1.0.2

func (p *SimpleProvider) GetDescription() string

GetDescription returns the provider description

func (*SimpleProvider) GetName

func (p *SimpleProvider) GetName() string

GetName returns the provider name

func (*SimpleProvider) SupportsRefresh added in v1.0.2

func (p *SimpleProvider) SupportsRefresh() bool

SupportsRefresh indicates if this provider supports real-time updates

type SmartCLICommandConfig added in v1.0.2

type SmartCLICommandConfig struct {
	// Command name
	Command string

	// Command description
	Description string

	// Usage string for help
	Usage string

	// Name of the smart selector function to register
	SmartFunctionName string

	// UI target menu to navigate to when no CLI arguments are provided (optional)
	UITarget string

	// UI title for Bubble Tea display when executed via CLI with arguments
	UITitle string

	// Direct CLI handler - called when the command is executed directly from CLI
	DirectHandler func(args []string) error

	// Direct executor for UI mode - called when CLI arguments are provided to the UI function
	DirectExecutor func(ctx context.Context, outputChan chan<- string, inputChan <-chan string, args []string) error

	// Interactive selector function - called when no CLI arguments are provided in UI mode
	InteractiveSelector func(ctx context.Context, outputChan chan<- string, inputChan <-chan string, params map[string]interface{}) error
}

SmartCLICommandConfig defines the configuration for a smart CLI command

type SmartSelectorConfig added in v1.0.2

type SmartSelectorConfig struct {
	// Direct execution function - called when CLI arguments are provided
	DirectExecutor func(ctx context.Context, outputChan chan<- string, inputChan <-chan string, args []string) error

	// Interactive selector function - called when no CLI arguments are provided
	InteractiveSelector func(ctx context.Context, outputChan chan<- string, inputChan <-chan string, params map[string]interface{}) error

	// Name of the command for error messages
	CommandName string

	// Usage string for help
	Usage string
}

SmartSelectorConfig defines the configuration for a smart selector function

type StandardProvider added in v1.0.2

type StandardProvider struct {
	// contains filtered or unexported fields
}

StandardProvider provides a provider with standardized naming and metadata

func NewStandardProvider added in v1.0.2

func NewStandardProvider(name, providerType, param, description string, fn func(param string) ([]MenuEntry, error)) *StandardProvider

NewStandardProvider creates a new standard provider

func (*StandardProvider) GenerateEntries added in v1.0.2

func (p *StandardProvider) GenerateEntries(param string) ([]MenuEntry, error)

GenerateEntries returns the menu entries

func (*StandardProvider) GetDescription added in v1.0.2

func (p *StandardProvider) GetDescription() string

GetDescription returns the provider description

func (*StandardProvider) GetName added in v1.0.2

func (p *StandardProvider) GetName() string

GetName returns the provider name

func (*StandardProvider) GetParam added in v1.0.2

func (p *StandardProvider) GetParam() string

GetParam returns the provider param

func (*StandardProvider) GetType added in v1.0.2

func (p *StandardProvider) GetType() string

GetType returns the provider type

func (*StandardProvider) SupportsRefresh added in v1.0.2

func (p *StandardProvider) SupportsRefresh() bool

SupportsRefresh indicates if this provider supports real-time updates

type StreamingCLICommandHandler added in v1.0.2

type StreamingCLICommandHandler interface {
	// Execute runs the CLI command with given arguments (fallback method)
	Execute(ctx context.Context, args []string) error

	// GetHelp returns help information for the command
	GetHelp() string

	// ExecuteStreaming runs the CLI command with real-time output streaming
	// outputChan receives output lines as they are generated
	// The channel is closed when the command completes
	ExecuteStreaming(ctx context.Context, args []string, outputChan chan<- string) error

	// SupportsStreaming indicates if this command supports real-time streaming
	SupportsStreaming() bool
}

StreamingCLICommandHandler extends CLICommandHandler to support real-time output streaming

type StreamingCommandWrapper added in v1.0.2

type StreamingCommandWrapper struct {
	// contains filtered or unexported fields
}

StreamingCommandWrapper wraps RPC calls for streaming CLI commands

func (*StreamingCommandWrapper) Execute added in v1.0.2

func (w *StreamingCommandWrapper) Execute(ctx context.Context, args []string) error

Execute provides fallback execution for streaming commands

func (*StreamingCommandWrapper) ExecuteStreaming added in v1.0.2

func (w *StreamingCommandWrapper) ExecuteStreaming(ctx context.Context, args []string, outputChan chan<- string) error

ExecuteStreaming provides real-time streaming execution

func (*StreamingCommandWrapper) GetHelp added in v1.0.2

func (w *StreamingCommandWrapper) GetHelp() string

GetHelp returns help for the streaming command

func (*StreamingCommandWrapper) SupportsStreaming added in v1.0.2

func (w *StreamingCommandWrapper) SupportsStreaming() bool

SupportsStreaming indicates this command supports streaming

type SudoChecker added in v1.0.2

type SudoChecker struct{}

SudoChecker provides methods to check sudo privileges and capabilities

func NewSudoChecker added in v1.0.2

func NewSudoChecker() *SudoChecker

NewSudoChecker creates a new SudoChecker instance

func (*SudoChecker) CheckSudoAvailability added in v1.0.2

func (sc *SudoChecker) CheckSudoAvailability() (*SudoInfo, error)

CheckSudoAvailability performs a safe check without calling sudo commands

func (*SudoChecker) CheckSudoPrivileges added in v1.0.2

func (sc *SudoChecker) CheckSudoPrivileges() (*SudoInfo, error)

CheckSudoPrivileges performs a comprehensive check of sudo privileges

func (*SudoChecker) GetSafeSudoStatus added in v1.0.2

func (sc *SudoChecker) GetSafeSudoStatus() string

GetSafeSudoStatus returns a human-readable status string without calling sudo

func (*SudoChecker) GetSudoStatus added in v1.0.2

func (sc *SudoChecker) GetSudoStatus() string

GetSudoStatus returns a human-readable status string

func (*SudoChecker) HasSudo added in v1.0.2

func (sc *SudoChecker) HasSudo() bool

HasSudo returns true if sudo is available and user can use it

func (*SudoChecker) PromptForSudo added in v1.0.2

func (sc *SudoChecker) PromptForSudo() error

PromptForSudo attempts to prompt for sudo privileges WARNING: This method is INTERACTIVE and will prompt the user for a password. It should only be used when the plugin explicitly needs to escalate privileges and the user has explicitly requested a privileged operation. For checking sudo availability, use CheckSudoPrivileges() or HasSudo() instead.

func (*SudoChecker) RequireSudo added in v1.0.2

func (sc *SudoChecker) RequireSudo() error

RequireSudo checks if sudo privileges are available and returns an error if not

func (*SudoChecker) TestSudoExecution added in v1.0.2

func (sc *SudoChecker) TestSudoExecution(command string, args ...string) error

TestSudoExecution tests if a command can be executed with sudo

type SudoInfo added in v1.0.2

type SudoInfo struct {
	HasSudo           bool   // Whether sudo is available
	IsRoot            bool   // Whether running as root user
	CanSudoWithoutPwd bool   // Whether can sudo without password
	SudoPath          string // Path to sudo binary
	CurrentUser       string // Current username
	SudoTimeLeft      int    // Minutes left in sudo cache (if any)
	ErrorMessage      string // Error message if sudo check failed
}

SudoInfo contains information about sudo privileges and status

type ToolChecker added in v1.0.2

type ToolChecker struct{}

ToolChecker provides methods to check if tools are installed on the system

func NewToolChecker added in v1.0.2

func NewToolChecker() *ToolChecker

NewToolChecker creates a new ToolChecker instance

func (*ToolChecker) CheckMultipleTools added in v1.0.2

func (tc *ToolChecker) CheckMultipleTools(toolNames []string) map[string]*ToolInfo

CheckMultipleTools checks multiple tools at once and returns a map of results

func (*ToolChecker) FindTool added in v1.0.2

func (tc *ToolChecker) FindTool(toolName string) (*ToolInfo, error)

FindTool locates a tool in the system and returns detailed information

func (*ToolChecker) IsInstalled added in v1.0.2

func (tc *ToolChecker) IsInstalled(toolName string) bool

IsInstalled checks if a tool is installed and accessible in the system PATH

func (*ToolChecker) RequireTool added in v1.0.2

func (tc *ToolChecker) RequireTool(toolName string) error

RequireTool checks if a tool is installed and returns an error if not

func (*ToolChecker) RequireTools added in v1.0.2

func (tc *ToolChecker) RequireTools(toolNames []string) error

RequireTools checks multiple tools and returns an error listing any missing tools

type ToolInfo added in v1.0.2

type ToolInfo struct {
	Name      string // Tool name
	Path      string // Full path to the executable
	Version   string // Version string (if detectable)
	Installed bool   // Whether the tool is installed
}

ToolInfo contains information about a detected tool

type ToolInstallCommand added in v1.0.2

type ToolInstallCommand struct {
	// Command to execute (can be a shell command, script path, or executable)
	Command string `yaml:"command"`
	// Arguments to pass to the command
	Args []string `yaml:"args,omitempty"`
	// Working directory for command execution
	WorkDir string `yaml:"work_dir,omitempty"`
	// Environment variables to set
	Env map[string]string `yaml:"env,omitempty"`
	// Whether this command requires sudo/elevated privileges
	RequiresSudo bool `yaml:"requires_sudo,omitempty"`
	// Whether to prime sudo cache before command execution (without running command as root)
	PrimeSudoCache bool `yaml:"prime_sudo_cache,omitempty"`
	// Shell to use for command execution (defaults to system shell)
	Shell string `yaml:"shell,omitempty"`
}

ToolInstallCommand represents a platform-specific installation command or script

type ToolInstallConfig added in v1.0.2

type ToolInstallConfig struct {
	// Tool name for display purposes
	ToolName string `yaml:"tool_name"`
	// Default version to install (optional, can be used by commands)
	Version string `yaml:"version,omitempty"`
	// Force update even if tool is already installed
	ForceUpdate bool `yaml:"force_update,omitempty"`
	// Platform-specific installation commands
	// Keys should be in format: "os-arch" (e.g., "linux-amd64", "darwin-arm64", "windows-amd64")
	InstallCommands map[string]ToolInstallCommand `yaml:"install_commands"`
	// Platform-specific version checking commands
	VersionCommands map[string]ToolVersionCommand `yaml:"version_commands,omitempty"`
	// Post-install verification command (optional)
	VerifyCommand *ToolInstallCommand `yaml:"verify_command,omitempty"`
}

ToolInstallConfig contains configuration for tool installation

type ToolInstallResult added in v1.0.2

type ToolInstallResult struct {
	Success            bool
	AlreadyInstalled   bool
	Version            string
	VersionRetrievable bool
	Error              error
	Platform           string
}

ToolInstallResult represents the result of a tool installation or check

type ToolInstaller added in v1.0.2

type ToolInstaller struct {
	// contains filtered or unexported fields
}

ToolInstaller provides cross-platform tool installation with custom scripts and commands

func NewToolInstaller added in v1.0.2

func NewToolInstaller(ctx context.Context, outputChan chan<- string, inputChan <-chan string) *ToolInstaller

NewToolInstaller creates a new tool installer instance

func (*ToolInstaller) CheckToolStatus added in v1.0.2

func (ti *ToolInstaller) CheckToolStatus(config *ToolInstallConfig) (*ToolInstallResult, error)

CheckToolStatus checks if a tool is installed and gets version information

func (*ToolInstaller) GetCurrentPlatform added in v1.0.2

func (ti *ToolInstaller) GetCurrentPlatform() string

GetCurrentPlatform returns the current platform string in "os-arch" format

func (*ToolInstaller) GetSupportedPlatforms added in v1.0.2

func (ti *ToolInstaller) GetSupportedPlatforms() []string

GetSupportedPlatforms returns a list of commonly supported platforms

func (*ToolInstaller) InstallTool added in v1.0.2

func (ti *ToolInstaller) InstallTool(config *ToolInstallConfig) (*ToolInstallResult, error)

InstallTool performs cross-platform tool installation using custom commands

type ToolInstallerInterface added in v1.0.2

type ToolInstallerInterface interface {
	// InstallTool performs cross-platform tool installation using custom commands
	InstallTool(config *ToolInstallConfig) (*ToolInstallResult, error)
	// CheckToolStatus checks if a tool is installed and gets version information
	CheckToolStatus(config *ToolInstallConfig) (*ToolInstallResult, error)
	// GetCurrentPlatform returns the current platform string in "os-arch" format
	GetCurrentPlatform() string
	// GetSupportedPlatforms returns a list of commonly supported platforms
	GetSupportedPlatforms() []string
}

ToolInstallerInterface provides methods for cross-platform tool installation with custom commands

type ToolVersionCommand added in v1.0.2

type ToolVersionCommand struct {
	// Command to check if tool is installed
	CheckCommand *ToolInstallCommand `yaml:"check_command,omitempty"`
	// Command to get current version
	VersionCommand *ToolInstallCommand `yaml:"version_command,omitempty"`
	// Whether version information is retrievable for this platform
	VersionRetrievable bool `yaml:"version_retrievable,omitempty"`
	// Custom version parser function (only available in Go code, not YAML)
	VersionParser func(string) string `yaml:"-"`
}

ToolVersionCommand represents a command to check version or installation status

type UnifiedProvider added in v1.0.2

type UnifiedProvider struct {
	// contains filtered or unexported fields
}

UnifiedProvider provides a single provider that handles multiple contexts based on parameters

func NewUnifiedProvider added in v1.0.2

func NewUnifiedProvider(name, description string) *UnifiedProvider

NewUnifiedProvider creates a new unified provider

func (*UnifiedProvider) GenerateEntries added in v1.0.2

func (p *UnifiedProvider) GenerateEntries(param string) ([]MenuEntry, error)

GenerateEntries returns the menu entries based on the parameter

func (*UnifiedProvider) GetDescription added in v1.0.2

func (p *UnifiedProvider) GetDescription() string

GetDescription returns the provider description

func (*UnifiedProvider) GetName added in v1.0.2

func (p *UnifiedProvider) GetName() string

GetName returns the provider name

func (*UnifiedProvider) HasMainMenu added in v1.0.2

func (p *UnifiedProvider) HasMainMenu() bool

HasMainMenu checks if this provider has a main menu handler

func (*UnifiedProvider) SupportsRefresh added in v1.0.2

func (p *UnifiedProvider) SupportsRefresh() bool

SupportsRefresh indicates if this provider supports real-time updates

func (*UnifiedProvider) WithConfigHandler added in v1.0.2

func (p *UnifiedProvider) WithConfigHandler(title string, handler func(param string) ([]MenuEntry, error)) *UnifiedProvider

WithConfigHandler adds a config handler for the unified provider

func (*UnifiedProvider) WithDataHandler added in v1.0.2

func (p *UnifiedProvider) WithDataHandler(title string, handler func(param string) ([]MenuEntry, error)) *UnifiedProvider

WithDataHandler adds a data handler for the unified provider

func (*UnifiedProvider) WithMenuHandler added in v1.0.2

func (p *UnifiedProvider) WithMenuHandler(title string, handler func(param string) ([]MenuEntry, error)) *UnifiedProvider

WithMenuHandler adds a menu handler for the unified provider

type UnifiedProviderBuilder added in v1.0.2

type UnifiedProviderBuilder struct {
	// contains filtered or unexported fields
}

UnifiedProviderBuilder provides a fluent interface for building unified providers

func (*UnifiedProviderBuilder) Done added in v1.0.2

Done completes the unified provider and returns to the main plugin builder

func (*UnifiedProviderBuilder) WithConfig added in v1.0.2

func (upb *UnifiedProviderBuilder) WithConfig(title string, handler func(param string) ([]MenuEntry, error)) *UnifiedProviderBuilder

WithConfig adds a config handler

func (*UnifiedProviderBuilder) WithData added in v1.0.2

func (upb *UnifiedProviderBuilder) WithData(title string, handler func(param string) ([]MenuEntry, error)) *UnifiedProviderBuilder

WithData adds a data handler

func (*UnifiedProviderBuilder) WithMainMenu added in v1.0.2

func (upb *UnifiedProviderBuilder) WithMainMenu(handler func(param string) ([]MenuEntry, error)) *UnifiedProviderBuilder

WithMainMenu adds the main menu handler (auto-registered)

func (*UnifiedProviderBuilder) WithMenu added in v1.0.2

func (upb *UnifiedProviderBuilder) WithMenu(title string, handler func(param string) ([]MenuEntry, error)) *UnifiedProviderBuilder

WithMenu adds a named menu handler

type ValidationError added in v1.0.2

type ValidationError struct {
	Parameter string
	Message   string
}

ValidationError represents a parameter validation error

func (ValidationError) Error added in v1.0.2

func (e ValidationError) Error() string

type VersionCheckResult added in v1.0.2

type VersionCheckResult struct {
	CurrentVersion  string
	LatestVersion   string
	UpdateAvailable bool
	Comparison      int // -1: current < latest, 0: equal, 1: current > latest
	Error           error
}

VersionCheckResult represents the result of a version check

Directories

Path Synopsis
Package output provides unified output adapters for MOPS plugins.
Package output provides unified output adapters for MOPS plugins.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL