plugin

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppContext

type AppContext interface {
	ConfigValue(key string) any
	ThemeName() string
	CurrentRepo() domain.RepoRef
	SendMessage(tea.Msg)
}

AppContext provides plugins access to application state during Init().

type HookHandler

type HookHandler func(ctx context.Context, data any) error

HookHandler is a function that handles a lifecycle event.

type HookManager

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

HookManager manages event hooks with thread-safe registration and emission.

func NewHookManager

func NewHookManager() *HookManager

NewHookManager creates a new HookManager.

func (*HookManager) Emit

func (hm *HookManager) Emit(ctx context.Context, point HookPoint, data any) error

Emit calls all handlers for a hook point in registration order. If any handler returns an error, emission stops and the error is returned.

func (*HookManager) On

func (hm *HookManager) On(point HookPoint, handler HookHandler)

On registers a handler for a hook point.

type HookPoint

type HookPoint string

HookPoint identifies a lifecycle event that plugins can hook into.

const (
	HookBeforeFetch  HookPoint = "before_fetch"
	HookAfterFetch   HookPoint = "after_fetch"
	HookBeforeRender HookPoint = "before_render"
	HookOnPRSelect   HookPoint = "on_pr_select"
	HookOnViewChange HookPoint = "on_view_change"
)

type KeyPlugin

type KeyPlugin interface {
	Plugin
	KeyBindings() []KeyRegistration
}

KeyPlugin provides custom key bindings.

type KeyRegistration

type KeyRegistration struct {
	Key    key.Binding    // The key binding
	View   string         // Which view this applies to ("" = global)
	Action func() tea.Cmd // Action to execute
}

KeyRegistration describes a custom key binding provided by a plugin.

type Plugin

type Plugin interface {
	Info() PluginInfo
	Init(app AppContext) tea.Cmd
}

Plugin is the base interface all plugins must implement.

type PluginInfo

type PluginInfo struct {
	Name        string   // unique identifier: "ghcli", "github-api"
	Version     string   // semver
	Description string   // human-readable
	Provides    []string // capabilities: "pr-reader", "pr-reviewer"
}

PluginInfo contains metadata about a plugin.

type Registry

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

Registry manages plugin lifecycle and capability discovery.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new plugin registry.

func (*Registry) GetReaders

func (r *Registry) GetReaders() []domain.PRReader

GetReaders returns all registered PRReader implementations.

func (*Registry) GetRepoManagers

func (r *Registry) GetRepoManagers() []domain.RepoManager

GetRepoManagers returns all registered RepoManager implementations. Future-ready: for plugin authors to provide custom repo management. Current MVP wiring uses direct injection via tui.WithRepoManager().

func (*Registry) GetReviewers

func (r *Registry) GetReviewers() []domain.PRReviewer

GetReviewers returns all registered PRReviewer implementations.

func (*Registry) GetWriters

func (r *Registry) GetWriters() []domain.PRWriter

GetWriters returns all registered PRWriter implementations.

func (*Registry) Hooks

func (r *Registry) Hooks() *HookManager

Hooks returns the hook manager.

func (*Registry) Register

func (r *Registry) Register(p Plugin) error

Register adds a plugin and auto-discovers its capabilities via type assertion.

func (*Registry) Unregister

func (r *Registry) Unregister(name string)

Unregister removes a plugin by name.

type ViewPlugin

type ViewPlugin interface {
	Plugin
	Views() []ViewRegistration
}

ViewPlugin provides custom UI views.

type ViewRegistration

type ViewRegistration struct {
	Name     string    // Unique view name
	Title    string    // Display title
	Position string    // "tab", "overlay", "pane"
	Model    tea.Model // BubbleTea model for the view
}

ViewRegistration describes a custom view provided by a plugin.

Jump to

Keyboard shortcuts

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