Documentation
¶
Overview ¶
Package plugin provides the public API for tinct plugins.
Package plugin provides the public API for tinct plugins.
Package plugin provides the public API for tinct plugins. External plugins should import this package instead of internal packages.
Package plugin provides the public API for tinct plugins.
Package plugin provides the public API for tinct plugins.
Index ¶
- Constants
- Variables
- type AlternateThemeData
- type CategorisedColour
- type FlagHelp
- type InputOptions
- type InputPlugin
- type InputPluginRPC
- type InputPluginRPCClient
- type InputPluginRPCServer
- type OutputPlugin
- type OutputPluginRPC
- type OutputPluginRPCClient
- func (c *OutputPluginRPCClient) Generate(_ context.Context, palette PaletteData) (map[string][]byte, error)
- func (c *OutputPluginRPCClient) GetFlagHelp() []FlagHelp
- func (c *OutputPluginRPCClient) GetMetadata() (PluginInfo, error)
- func (c *OutputPluginRPCClient) PostExecute(_ context.Context, files []string) error
- func (c *OutputPluginRPCClient) PreExecute(_ context.Context) (bool, string, error)
- type OutputPluginRPCServer
- func (s *OutputPluginRPCServer) Generate(palette PaletteData, resp *map[string][]byte) error
- func (s *OutputPluginRPCServer) GetFlagHelp(_ any, resp *[]FlagHelp) error
- func (s *OutputPluginRPCServer) GetMetadata(_ any, resp *PluginInfo) error
- func (s *OutputPluginRPCServer) PostExecute(files []string, resp *string) error
- func (s *OutputPluginRPCServer) PreExecute(_ any, resp ...) error
- type PaletteData
- type PluginInfo
- type PluginType
- type RGBColour
- type RPCError
Constants ¶
const ( // ProtocolVersion defines the current plugin API version. // Format: MAJOR.MINOR.PATCH. // - Increment MAJOR for breaking changes (incompatible API changes). // - Increment MINOR for backward-compatible additions. // - Increment PATCH for backward-compatible bug fixes. ProtocolVersion = "0.1.0" // MinCompatibleVersion is the oldest protocol version this tinct version can work with. MinCompatibleVersion = "0.0.1" )
Variables ¶
var Handshake = plugin.HandshakeConfig{ ProtocolVersion: 0, MagicCookieKey: "TINCT_PLUGIN", MagicCookieValue: "tinct_color_palette", }
Handshake is the handshake configuration for go-plugin protocol. This ensures that plugins using go-plugin can only connect to compatible hosts.
Functions ¶
This section is empty.
Types ¶
type AlternateThemeData ¶ added in v0.1.0
type AlternateThemeData struct {
Colours map[string]CategorisedColour `json:"colours"`
AllColours []CategorisedColour `json:"all_colours"`
ThemeType string `json:"theme_type"`
}
AlternateThemeData contains the palette data for the alternate theme variant.
type CategorisedColour ¶
type CategorisedColour struct {
RGB RGBColour `json:"rgb"`
Hex string `json:"hex"`
Role string `json:"role,omitempty"`
Luminance float64 `json:"luminance,omitempty"`
IsLight bool `json:"is_light,omitempty"`
Hue float64 `json:"hue,omitempty"`
Saturation float64 `json:"saturation,omitempty"`
Index int `json:"index,omitempty"`
}
CategorisedColour represents a color with metadata for RPC transfer.
type FlagHelp ¶
type FlagHelp struct {
Name string `json:"name"` // Flag name (e.g., "prompt", "model")
Shorthand string `json:"shorthand"` // Short flag (e.g., "p")
Type string `json:"type"` // Type (e.g., "string", "int", "bool")
Default string `json:"default"` // Default value as string
Description string `json:"description"` // Help text
Required bool `json:"required"` // Is this flag required?
}
FlagHelp represents help information for a single plugin flag. This type is part of the plugin protocol and is used by both internal and external plugins.
type InputOptions ¶
type InputOptions struct {
Verbose bool `json:"verbose"`
DryRun bool `json:"dry_run"`
ColourOverrides []string `json:"colour_overrides,omitempty"`
PluginArgs map[string]any `json:"plugin_args,omitempty"`
}
InputOptions holds options for input plugin generation.
type InputPlugin ¶
type InputPlugin interface {
// Generate creates a palette from plugin-specific inputs.
Generate(ctx context.Context, opts InputOptions) ([]color.Color, error)
// GetMetadata returns plugin metadata.
GetMetadata() PluginInfo
// WallpaperPath returns the path to a wallpaper image, if available.
// Returns empty string if no wallpaper is available.
WallpaperPath() string
// GetFlagHelp returns help information for plugin flags.
GetFlagHelp() []FlagHelp
}
InputPlugin is the interface that input plugins must implement for go-plugin RPC.
type InputPluginRPC ¶
type InputPluginRPC struct {
plugin.Plugin
Impl InputPlugin
}
InputPluginRPC implements the go-plugin Plugin interface for input plugins.
type InputPluginRPCClient ¶
type InputPluginRPCClient struct {
// contains filtered or unexported fields
}
InputPluginRPCClient is the RPC client implementation for input plugins.
func (*InputPluginRPCClient) Generate ¶
func (c *InputPluginRPCClient) Generate(_ context.Context, opts InputOptions) ([]color.Color, error)
Generate calls the remote Generate method.
func (*InputPluginRPCClient) GetFlagHelp ¶
func (c *InputPluginRPCClient) GetFlagHelp() []FlagHelp
GetFlagHelp calls the remote GetFlagHelp method.
func (*InputPluginRPCClient) GetMetadata ¶
func (c *InputPluginRPCClient) GetMetadata() (PluginInfo, error)
GetMetadata calls the remote GetMetadata method.
func (*InputPluginRPCClient) WallpaperPath ¶
func (c *InputPluginRPCClient) WallpaperPath() string
WallpaperPath calls the remote WallpaperPath method.
type InputPluginRPCServer ¶
type InputPluginRPCServer struct {
Impl InputPlugin
}
InputPluginRPCServer is the RPC server implementation for input plugins.
func (*InputPluginRPCServer) Generate ¶
func (s *InputPluginRPCServer) Generate(opts InputOptions, resp *[]byte) error
Generate implements the RPC method for palette generation.
func (*InputPluginRPCServer) GetFlagHelp ¶
func (s *InputPluginRPCServer) GetFlagHelp(_ any, resp *[]FlagHelp) error
GetFlagHelp implements the RPC method for fetching flag help.
func (*InputPluginRPCServer) GetMetadata ¶
func (s *InputPluginRPCServer) GetMetadata(_ any, resp *PluginInfo) error
GetMetadata implements the RPC method for fetching plugin metadata.
func (*InputPluginRPCServer) WallpaperPath ¶
func (s *InputPluginRPCServer) WallpaperPath(_ any, resp *string) error
WallpaperPath implements the RPC method for fetching wallpaper path.
type OutputPlugin ¶
type OutputPlugin interface {
// Generate creates output file(s) from the given theme data.
Generate(ctx context.Context, palette PaletteData) (map[string][]byte, error)
// PreExecute runs before Generate() for validation checks.
PreExecute(ctx context.Context) (skip bool, reason string, err error)
// PostExecute runs after successful Generate() and file writing.
PostExecute(ctx context.Context, writtenFiles []string) error
// GetMetadata returns plugin metadata.
GetMetadata() PluginInfo
// GetFlagHelp returns help information for plugin flags.
GetFlagHelp() []FlagHelp
}
OutputPlugin is the interface that output plugins must implement for go-plugin RPC.
type OutputPluginRPC ¶
type OutputPluginRPC struct {
plugin.Plugin
Impl OutputPlugin
}
OutputPluginRPC implements the go-plugin Plugin interface for output plugins.
type OutputPluginRPCClient ¶
type OutputPluginRPCClient struct {
// contains filtered or unexported fields
}
OutputPluginRPCClient is the RPC client implementation for output plugins.
func (*OutputPluginRPCClient) Generate ¶
func (c *OutputPluginRPCClient) Generate(_ context.Context, palette PaletteData) (map[string][]byte, error)
Generate calls the remote Generate method.
func (*OutputPluginRPCClient) GetFlagHelp ¶
func (c *OutputPluginRPCClient) GetFlagHelp() []FlagHelp
GetFlagHelp calls the remote GetFlagHelp method.
func (*OutputPluginRPCClient) GetMetadata ¶
func (c *OutputPluginRPCClient) GetMetadata() (PluginInfo, error)
GetMetadata calls the remote GetMetadata method.
func (*OutputPluginRPCClient) PostExecute ¶
func (c *OutputPluginRPCClient) PostExecute(_ context.Context, files []string) error
PostExecute calls the remote PostExecute method.
func (*OutputPluginRPCClient) PreExecute ¶
PreExecute calls the remote PreExecute method.
type OutputPluginRPCServer ¶
type OutputPluginRPCServer struct {
Impl OutputPlugin
}
OutputPluginRPCServer is the RPC server implementation for output plugins.
func (*OutputPluginRPCServer) Generate ¶
func (s *OutputPluginRPCServer) Generate(palette PaletteData, resp *map[string][]byte) error
Generate implements the RPC method for output generation.
func (*OutputPluginRPCServer) GetFlagHelp ¶
func (s *OutputPluginRPCServer) GetFlagHelp(_ any, resp *[]FlagHelp) error
GetFlagHelp implements the RPC method for fetching flag help.
func (*OutputPluginRPCServer) GetMetadata ¶
func (s *OutputPluginRPCServer) GetMetadata(_ any, resp *PluginInfo) error
GetMetadata implements the RPC method for fetching plugin metadata.
func (*OutputPluginRPCServer) PostExecute ¶
func (s *OutputPluginRPCServer) PostExecute(files []string, resp *string) error
PostExecute implements the RPC method for post-execution hooks.
func (*OutputPluginRPCServer) PreExecute ¶
func (s *OutputPluginRPCServer) PreExecute(_ any, resp *struct { Skip bool Reason string Error string }) error
PreExecute implements the RPC method for pre-execution hooks.
type PaletteData ¶
type PaletteData struct {
Colours map[string]CategorisedColour `json:"colours"`
AllColours []CategorisedColour `json:"all_colours"`
ThemeType string `json:"theme_type"`
PluginArgs map[string]any `json:"plugin_args,omitempty"`
DryRun bool `json:"dry_run"`
Verbose bool `json:"verbose"`
// DualTheme support (optional, for plugins that support both light and dark)
// If present, contains the alternate theme variant (light if primary is dark, vice versa)
AlternateTheme *AlternateThemeData `json:"alternate_theme,omitempty"`
}
PaletteData is the palette data sent to output plugins.
type PluginInfo ¶
type PluginInfo struct {
Name string `json:"name"`
Type string `json:"type"` // "input" or "output"
Version string `json:"version"`
ProtocolVersion string `json:"protocol_version"`
Description string `json:"description"`
PluginProtocol string `json:"plugin_protocol"` // "json-stdio" or "go-plugin"
}
PluginInfo contains metadata about a plugin.
type PluginType ¶
type PluginType string
PluginType defines the type of plugin communication protocol.
const ( // PluginTypeGoPlugin indicates the plugin uses HashiCorp go-plugin RPC protocol. PluginTypeGoPlugin PluginType = "go-plugin" // PluginTypeJSON indicates the plugin uses simple JSON over stdin/stdout. PluginTypeJSON PluginType = "json-stdio" )