plugin

package
v0.1.25 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetaTruncated = "truncated"
	MetaMore      = "more"
)
View Source
const InternalPrefix = "mino."

Variables

This section is empty.

Functions

func ActionUIVisible

func ActionUIVisible(signal, name string) bool

func ApplyRoleContexts

func ApplyRoleContexts(ctx context.Context, bindings map[string]string) error

func BackupDestinationOwner

func BackupDestinationOwner(name string) (string, bool)

func BackupDestinations

func BackupDestinations() []string

func BuilderSignals

func BuilderSignals() map[string]bool

func CollectStatusContributions

func CollectStatusContributions(home, role string) []glyph.StatusContribution

func ContextTools

func ContextTools() []string

func FilterNames

func FilterNames() []string

func Guarded

func Guarded(pluginID string, register func())

Guarded runs one plugin's registration behind its own recover so a panic in that plugin's code becomes a diagnostic instead of truncating every plugin that would have registered after it. Compose a host's RegisterPlugins hook out of Guarded calls to get per-plugin containment.

func HasBuilder

func HasBuilder(signal string) bool

func HasCapability

func HasCapability(signal string, cap Capability) bool

func HasContextProvider

func HasContextProvider(tool string) bool

func HasDiagnostics

func HasDiagnostics() bool

func HasFilter

func HasFilter(name string) bool

func HasFilterEngine

func HasFilterEngine(name string) bool

func HasFilterKeywords

func HasFilterKeywords(name string) bool

func HasScheduledBuilder

func HasScheduledBuilder(signal string) bool

func HasStreamBuilder

func HasStreamBuilder(signal string) bool

func HasTheme

func HasTheme(key string) bool

func HasView

func HasView(viewID string) bool

func IsInternal

func IsInternal(id string) bool

func KnownRefs

func KnownRefs(kind Kind) map[string]bool

func KnownSignals

func KnownSignals() map[string]bool

func LookupFilterKeywords

func LookupFilterKeywords(name string) (map[string]string, bool)

func LookupStatusContribution

func LookupStatusContribution(pluginID, home, role string) (glyph.StatusContribution, bool)

func NoteDiagnostic

func NoteDiagnostic(pluginID string, kind Kind, ref, message string)

func OwnerID

func OwnerID(d Descriptor) string

func ParamSignals

func ParamSignals() []string

func Register

func Register(d Descriptor)

func RegisterAction

func RegisterAction(signal, name string, run ActionFunc, opts ...Option)

func RegisterBackupDestination

func RegisterBackupDestination(pluginID, name string, open BackupDestinationFunc)

func RegisterBuilders

func RegisterBuilders(signal string, b Builders)

RegisterBuilders is the standalone route: the caller registered its Descriptor separately, so the owning plugin is resolved from the signal.

func RegisterContext

func RegisterContext(parentID string, p ContextProvider)

func RegisterContextProvider

func RegisterContextProvider(p ContextProvider)

RegisterContextProvider installs a live provider for its tool. Like every other registration site it is first-write-wins: the incumbent keeps the tool and the later provider is skipped with a diagnostic, so a plugin can never take over a tool another plugin already owns.

func RegisterFilter

func RegisterFilter(parentID string, f NamedFilter)

func RegisterFilterEngine

func RegisterFilterEngine(parentID, name string, fn FilterFunc)

func RegisterFilterKeywords

func RegisterFilterKeywords(parentID, name string, fn KeywordsFunc)

func RegisterLoginProvider

func RegisterLoginProvider(p LoginProvider)

func RegisterQueryParams

func RegisterQueryParams(signal string, specs ...ParamSpec)

func RegisterSeeds

func RegisterSeeds(pluginID string, files []FileSeed)

func RegisterSignal

func RegisterSignal(d Descriptor, b Builders)

func RegisterStatusContribution

func RegisterStatusContribution(pluginID string, f StatusFactory)

func RegisterTheme

func RegisterTheme(parentID, key, displayName string, p theme.Palette)

func RegisterView

func RegisterView(parentID, viewID string, ctor func() deck.View, opts ...Option)

func RegistrationCheckpoint

func RegistrationCheckpoint() (pluginID string, seen uint64)

RegistrationCheckpoint reports the owner id of the most recent contribution offered to the registry and how many contributions have been offered so far. Compare seen across a registration callback to tell whether the plugin named by pluginID was the one that failed.

func ResetBackupDestinations

func ResetBackupDestinations()

func ResetContextProvidersForTest

func ResetContextProvidersForTest()

func ResetDiagnostics

func ResetDiagnostics()

func ResetLoginProviders

func ResetLoginProviders()

func ResetQueryParams

func ResetQueryParams()

func RunAction

func RunAction(ctx context.Context, signal, name string, params map[string]string) error

func ScheduledSignals

func ScheduledSignals() []string

func SeedPluginIDs

func SeedPluginIDs() []string

func ServiceAttached

func ServiceAttached() bool

func SetPluginEnabledFunc

func SetPluginEnabledFunc(fn func(id string) bool)

func SetServiceAttachedFunc

func SetServiceAttachedFunc(fn func() bool)

func SetSignalEnabledFunc

func SetSignalEnabledFunc(fn func(signal string) bool)

func Setting

func Setting(settings map[string]any, key, def string) string

func SettingBool

func SettingBool(settings map[string]any, key string, def bool) bool

func SettingDuration

func SettingDuration(settings map[string]any, key string, def time.Duration) time.Duration

func SettingInt

func SettingInt(settings map[string]any, key string, def int) int

func SettingList

func SettingList(settings map[string]any, key string) []string

func SettingsOf

func SettingsOf(bc BuildContext, namespace string) map[string]any

func SplitActionRef

func SplitActionRef(ref string) (signal, name string, ok bool)

func StatusContributionIDs

func StatusContributionIDs() []string

func SwitchContext

func SwitchContext(ctx context.Context, tool, name string) error

func UIVisible

func UIVisible(d Descriptor) bool

func ValidKind

func ValidKind(k Kind) bool

func ViewUIVisible

func ViewUIVisible(viewID string) bool

Types

type Action

type Action interface {
	Name() string
	Run(ctx context.Context, params map[string]string) error
}

type ActionFunc

type ActionFunc func(ctx context.Context, params map[string]string) error

type ActionSpec

type ActionSpec struct {
	Signal string
	Name   string
	Run    ActionFunc
}

func ActionsFor

func ActionsFor(signal string) []ActionSpec

func LookupAction

func LookupAction(signal, name string) (ActionSpec, bool)

type BackupDestination

type BackupDestination interface {
	Name() string
	Upload(ctx context.Context, name string, data []byte, contentType string) (Item, error)
	Prune(ctx context.Context, prefix string, keep int) ([]string, error)
}

type BackupDestinationFunc

type BackupDestinationFunc func(h Host) (BackupDestination, error)

func LookupBackupDestination

func LookupBackupDestination(name string) (BackupDestinationFunc, bool)

type BuildContext

type BuildContext interface {
	Params() map[string]string
	Home() string
	Role() string
}

type Builders

type Builders struct {
	Query     QueryFunc
	Stream    StreamFunc
	Scheduled ScheduledFunc
}

func LookupBuilders

func LookupBuilders(signal string) (Builders, bool)

type Capability

type Capability string
const (
	CapQuery     Capability = "query"
	CapAction    Capability = "action"
	CapStream    Capability = "stream"
	CapScheduled Capability = "scheduled"
	// CapCacheable marks a signal whose Fetch results are worth caching between runs.
	// Signals reading local state should omit it so writes show up immediately.
	CapCacheable Capability = "cacheable"
	CapDetail    Capability = "detail"
)

type Chip

type Chip struct {
	Label string
	Sev   glyph.Severity
}

func (Chip) MarshalJSON

func (c Chip) MarshalJSON() ([]byte, error)

func (*Chip) UnmarshalJSON

func (c *Chip) UnmarshalJSON(b []byte) error

type Context

type Context struct {
	Tool string
	Name string
}

func CurrentContext

func CurrentContext(ctx context.Context, tool string) (Context, bool)

func ListContexts

func ListContexts(ctx context.Context) []Context

type ContextProvider

type ContextProvider interface {
	Tool() string
	Switch(ctx context.Context, name string) error
	Current(ctx context.Context) (name string, ok bool, err error)
}

type Credential

type Credential struct {
	AccessToken  string
	RefreshToken string
	Scope        string
	Expiry       time.Time
}

type CredentialStore

type CredentialStore interface {
	Get(ctx context.Context, service string) (Credential, bool, error)
	Put(ctx context.Context, service string, c Credential) error
	Delete(ctx context.Context, service string) error
}

func CredentialsOf

func CredentialsOf(bc BuildContext) CredentialStore

type Descriptor

type Descriptor struct {
	ID                 string
	Kind               Kind
	Capabilities       []Capability
	Signal             string
	Ref                string
	Parent             string
	ServiceOnly        bool
	Credentials        []string
	SettingsNamespaces []string
}

func All

func All() []Descriptor

func AllOfKind

func AllOfKind(kind Kind) []Descriptor

func ByKind

func ByKind(kind Kind, ref string) (Descriptor, bool)

func BySignal

func BySignal(signal string) (Descriptor, bool)

func Lookup

func Lookup(id string) (Descriptor, bool)

func Primaries

func Primaries() []Descriptor

type DetailSection

type DetailSection struct {
	Title string            `json:"title"`
	Icon  string            `json:"icon,omitempty"`
	Rows  [][2]string       `json:"rows,omitempty"`
	Lines []string          `json:"lines,omitempty"`
	Body  string            `json:"body,omitempty"`
	Meta  map[string]string `json:"meta,omitempty"`
}

type Detailer

type Detailer interface {
	Name() string
	Detail(ctx context.Context, item Item) (ItemDetail, error)
}

type Diagnostic

type Diagnostic struct {
	PluginID string
	Kind     Kind
	Ref      string
	Message  string
}

func Diagnostics

func Diagnostics() []Diagnostic

func DiagnosticsFor

func DiagnosticsFor(pluginID string) []Diagnostic

func (Diagnostic) String

func (d Diagnostic) String() string

type Error

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

func NewError

func NewError(msg string) *Error

func NewErrorf

func NewErrorf(format string, args ...any) *Error

func WrapError

func WrapError(cause error, msg string) *Error

func WrapErrorf

func WrapErrorf(cause error, format string, args ...any) *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) Hint

func (e *Error) Hint() string

func (*Error) Message

func (e *Error) Message() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

func (*Error) WithHint

func (e *Error) WithHint(format string, args ...any) *Error

type Event

type Event struct {
	Source  string
	Section Section
	At      time.Time
}

type FileSeed

type FileSeed struct {
	RelPath string
	Content []byte
}

func SeedsFor

func SeedsFor(pluginID string) []FileSeed

type FilterFunc

type FilterFunc func(items []Item) []Item

func LookupFilterEngine

func LookupFilterEngine(name string) (FilterFunc, bool)

type FilterRule

type FilterRule struct {
	Field   string `yaml:"field" json:"field"`
	Include string `yaml:"include,omitempty" json:"include,omitempty"`
	Exclude string `yaml:"exclude,omitempty" json:"exclude,omitempty"`
}

type Host

type Host interface {
	Home() string
	Role() string
	Settings(namespace string) map[string]any
	Credentials() CredentialStore
}

func HostOf

func HostOf(bc BuildContext) (Host, bool)

type Item

type Item struct {
	Kind      string            `json:"kind"`
	Title     string            `json:"title"`
	Subtitle  string            `json:"subtitle,omitempty"`
	Body      string            `json:"body,omitempty"`
	URL       string            `json:"url,omitempty"`
	Timestamp time.Time         `json:"timestamp"`
	Meta      map[string]string `json:"meta,omitempty"`
}

type ItemDetail

type ItemDetail struct {
	Kind     string            `json:"kind,omitempty"`
	Title    string            `json:"title"`
	URL      string            `json:"url,omitempty"`
	Chips    []Chip            `json:"chips,omitempty"`
	Rows     [][2]string       `json:"rows,omitempty"`
	Body     string            `json:"body,omitempty"`
	Sections []DetailSection   `json:"sections,omitempty"`
	Meta     map[string]string `json:"meta,omitempty"`
}

type KV

type KV = stream.KV

func KVOf

func KVOf(bc BuildContext) KV

type KeywordsFunc

type KeywordsFunc func() map[string]string

type Kind

type Kind string
const (
	KindSignal  Kind = "signal"
	KindFilter  Kind = "filter"
	KindAction  Kind = "action"
	KindView    Kind = "view"
	KindTheme   Kind = "theme"
	KindContext Kind = "context"
)
const KindBackup Kind = "backup"
const KindLogin Kind = "login"

func KnownKinds

func KnownKinds() []Kind

type LoginField

type LoginField struct {
	Key    string
	Label  string
	Secret bool
	Sealed bool
	Value  func(Host) string
}

type LoginProvider

type LoginProvider struct {
	PluginID string
	Key      string
	Label    string
	Signals  []string
	Fields   []LoginField
	Authed   func(Host) bool
	Login    func(ctx context.Context, h Host, creds map[string]string, w io.Writer) error
}

func LoginProviders

func LoginProviders() []LoginProvider

func LookupLoginProvider

func LookupLoginProvider(key string) (LoginProvider, bool)

type NamedFilter

type NamedFilter struct {
	Name     string            `yaml:"name" json:"name"`
	Rules    []FilterRule      `yaml:"rules,omitempty" json:"rules,omitempty"`
	Aliases  map[string]string `yaml:"aliases,omitempty" json:"aliases,omitempty"`
	Keywords map[string]string `yaml:"keywords,omitempty" json:"keywords,omitempty"`
}

func LookupFilter

func LookupFilter(name string) (NamedFilter, bool)

type Option

type Option func(*Descriptor)

func WithServiceOnly

func WithServiceOnly() Option

type ParamSpec

type ParamSpec struct {
	Key     string
	Desc    string
	Example string
	Values  []string
	Delim   string
}

func QueryParams

func QueryParams(signal string) []ParamSpec

type Query

type Query interface {
	Name() string
	Fetch(ctx context.Context) ([]Section, error)
}

func BuildQuery

func BuildQuery(signal string, bc BuildContext) (Query, error)

type QueryFunc

type QueryFunc func(ctx BuildContext) (Query, error)

type Scheduled

type Scheduled interface {
	Name() string
	// Next reports when the job should next run. A zero due means nothing is
	// scheduled; a due at or before now runs immediately.
	Next(ctx context.Context, now time.Time) (due time.Time, err error)
	Fetch(ctx context.Context) ([]Section, error)
}

func BuildScheduled

func BuildScheduled(signal string, bc BuildContext) (Scheduled, error)

type ScheduledFunc

type ScheduledFunc func(ctx BuildContext) (Scheduled, error)

type Section

type Section struct {
	Signal string            `json:"signal"`
	Title  string            `json:"title"`
	Items  []Item            `json:"items"`
	Meta   map[string]string `json:"meta,omitempty"`
	Err    error             `json:"-"`
}

func (Section) ErrString

func (s Section) ErrString() string

func (Section) MarshalJSON

func (s Section) MarshalJSON() ([]byte, error)

func (*Section) UnmarshalJSON

func (s *Section) UnmarshalJSON(b []byte) error

type StatusEntry

type StatusEntry struct {
	PluginID string
	Contrib  glyph.StatusContribution
}

func CollectStatusEntries

func CollectStatusEntries(home, role string) []StatusEntry

type StatusFactory

type StatusFactory func(home, role string) glyph.StatusContribution

type Stream

type Stream interface {
	Name() string
	Stream(ctx context.Context) (<-chan Event, error)
	LatencyFloor() time.Duration
}

func BuildStream

func BuildStream(signal string, bc BuildContext) (Stream, error)

type StreamFunc

type StreamFunc func(ctx BuildContext) (Stream, error)

type TokenSource

type TokenSource interface {
	GetToken(ctx context.Context, service string) (accessToken, scope string, ok bool, err error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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