Documentation
¶
Overview ¶
Package plugins provides a plugin system for extending Hive with additional commands and status providers.
Index ¶
- type CommandSet
- type Job
- type Manager
- func (m *Manager) CloseAll()
- func (m *Manager) Collector() *StatusCollector
- func (m *Manager) EnabledPlugins() []Plugin
- func (m *Manager) Get(name string) Plugin
- func (m *Manager) InitAll(ctx context.Context) error
- func (m *Manager) RefreshAllStatus(ctx context.Context, sessions []*session.Session) map[string]map[string]Statusdeprecated
- func (m *Manager) Register(p Plugin)
- func (m *Manager) StartBackgroundWorker(ctx context.Context, pollInterval time.Duration) <-chan Result
- func (m *Manager) Stop()
- func (m *Manager) UpdateSessions(sessions []*session.Session)
- type Plugin
- type Result
- type Status
- type StatusCollector
- type StatusProvider
- type WorkerPool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandSet ¶ added in v0.49.0
type CommandSet struct {
// contains filtered or unexported fields
}
CommandSet is the canonical merged registry of user commands across system defaults, plugin contributions, and user-config overrides. It is concurrent- safe: writers from any goroutine push via SetPlugin; readers via Lookup or All. Merge precedence in reads is user > plugin > system.
Slots are kept separate so each source updates only its own commands while preserving the overall precedence ordering.
func NewCommandSet ¶ added in v0.49.0
func NewCommandSet(system, user map[string]config.UserCommand) *CommandSet
NewCommandSet constructs a CommandSet seeded with system and user commands. Either map may be nil (treated as empty). System and user are immutable after construction; if a config-reload story arrives later, add setters then.
func (*CommandSet) All ¶ added in v0.49.0
func (s *CommandSet) All() map[string]config.UserCommand
All returns a defensive copy of the fully merged command map.
func (*CommandSet) Lookup ¶ added in v0.49.0
func (s *CommandSet) Lookup(name string) (config.UserCommand, bool)
Lookup returns a single merged command by name, applying precedence (user > plugin > system). The boolean is false if no source defines name. Hot path: called per keystroke from the keybinding resolver. One RLock, up to three map lookups, no allocation.
func (*CommandSet) Plugin ¶ added in v0.49.0
func (s *CommandSet) Plugin(name string) map[string]config.UserCommand
Plugin returns a defensive copy of the named plugin's slot, or nil if the plugin has no slot.
func (*CommandSet) SetPlugin ¶ added in v0.49.0
func (s *CommandSet) SetPlugin(name string, cmds map[string]config.UserCommand)
SetPlugin replaces the named plugin's slot. Pass nil cmds to clear (removes the entry from plugins map).
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages plugin registration, lifecycle, and status fetching.
func NewManager ¶
func NewManager(pool *WorkerPool, commandSet *CommandSet) *Manager
NewManager creates a new plugin manager. The pool is injected so it can be shared with plugins that draw from the same concurrency budget as status refreshes. commandSet is the canonical command registry the manager seeds plugin slots into during InitAll; the manager does not own or expose it — callers keep the reference for lookups.
func (*Manager) CloseAll ¶
func (m *Manager) CloseAll()
CloseAll closes all registered plugins and stops background workers.
func (*Manager) Collector ¶
func (m *Manager) Collector() *StatusCollector
Collector returns the status collector for reading cached statuses.
func (*Manager) EnabledPlugins ¶
EnabledPlugins returns all registered (available) plugins.
func (*Manager) InitAll ¶
InitAll initializes all registered plugins. Errors are logged but do not stop initialization of other plugins. After each successful Init, the plugin's Commands() populate that plugin's slot in the shared CommandSet.
func (*Manager) RefreshAllStatus
deprecated
func (m *Manager) RefreshAllStatus(ctx context.Context, sessions []*session.Session) map[string]map[string]Status
RefreshAllStatus fetches status from all plugins for the given sessions. Returns a map of plugin name -> session ID -> status.
Deprecated: Use StartBackgroundWorker for non-blocking status fetching.
func (*Manager) Register ¶
Register adds a plugin if it is available. Plugins that are not available (missing dependencies) are silently skipped.
func (*Manager) StartBackgroundWorker ¶
func (m *Manager) StartBackgroundWorker(ctx context.Context, pollInterval time.Duration) <-chan Result
StartBackgroundWorker starts background workers that fetch plugin statuses. Returns a channel that receives results as they complete. Call Stop() to shut down the workers.
func (*Manager) Stop ¶
func (m *Manager) Stop()
Stop shuts down background workers and waits for them to finish.
func (*Manager) UpdateSessions ¶
UpdateSessions updates the session list. A plugin refresh is only triggered when sessions are added or removed to avoid unnecessary API calls (e.g. GitHub).
type Plugin ¶
type Plugin interface {
// Name returns the plugin name (e.g., "github", "claude").
Name() string
// Available returns true if the plugin's dependencies are met
// (e.g., gh CLI is installed). Called once at startup.
Available() bool
// Init initializes the plugin. Called once after registration
// if the plugin is available.
Init(ctx context.Context) error
// Close releases plugin resources.
Close() error
// Commands returns commands to register in the command palette.
// Uses Plugin<Cmd> naming convention (e.g., GithubOpenPR).
Commands() map[string]config.UserCommand
// StatusProvider returns the status provider for UI integration.
// May return nil if the plugin doesn't provide status.
StatusProvider() StatusProvider
}
Plugin defines the interface for Hive plugins.
type Status ¶
type Status struct {
Label string // e.g., "0/3", "PR#42", "main +2/-1"
Icon string // e.g., "●", "◆", "!"
Style lipgloss.Style // color/formatting
}
Status represents plugin status to display in the UI.
type StatusCollector ¶
type StatusCollector struct {
// contains filtered or unexported fields
}
StatusCollector provides thread-safe caching for plugin statuses. It stores statuses indexed by plugin name and session ID.
func NewStatusCollector ¶
func NewStatusCollector() *StatusCollector
NewStatusCollector creates a new status collector.
func (*StatusCollector) Clear ¶
func (c *StatusCollector) Clear()
Clear removes all cached statuses.
func (*StatusCollector) Get ¶
func (c *StatusCollector) Get(pluginName, sessionID string) (Status, bool)
Get retrieves a status for the given plugin and session.
func (*StatusCollector) GetAll ¶
func (c *StatusCollector) GetAll(pluginName string) map[string]Status
GetAll returns all statuses for a given plugin.
func (*StatusCollector) Set ¶
func (c *StatusCollector) Set(pluginName, sessionID string, status Status)
Set stores a status for the given plugin and session.
type StatusProvider ¶
type StatusProvider interface {
// RefreshStatus fetches fresh status data for a batch of sessions.
// Uses the shared worker pool for subprocess calls.
// Returns a map of session ID -> Status.
RefreshStatus(ctx context.Context, sessions []*session.Session, pool *WorkerPool) (map[string]Status, error)
// StatusCacheDuration returns how long status can be cached.
StatusCacheDuration() time.Duration
}
StatusProvider defines the interface for plugins that provide status information to display in the UI (tree view, preview header).
type WorkerPool ¶
type WorkerPool struct {
// contains filtered or unexported fields
}
WorkerPool limits concurrent subprocess execution across all plugins.
func NewWorkerPool ¶
func NewWorkerPool(size int) *WorkerPool
NewWorkerPool creates a new worker pool with the given size.
func (*WorkerPool) Acquire ¶
func (p *WorkerPool) Acquire()
Acquire blocks until a worker slot is available.
func (*WorkerPool) Release ¶
func (p *WorkerPool) Release()
Release returns a worker slot to the pool.
func (*WorkerPool) Run ¶
func (p *WorkerPool) Run(fn func())
Run executes fn with pool semaphore held.
func (*WorkerPool) RunContext ¶
func (p *WorkerPool) RunContext(ctx context.Context, fn func()) error
RunContext executes fn with pool semaphore held, respecting context cancellation. Returns ctx.Err() if context is cancelled while waiting to acquire.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package claude provides Claude Code integration for Hive.
|
Package claude provides Claude Code integration for Hive. |
|
Package contextdir provides commands for opening context directories.
|
Package contextdir provides commands for opening context directories. |
|
Package github provides a GitHub plugin for Hive.
|
Package github provides a GitHub plugin for Hive. |
|
Package lazygit provides a lazygit plugin for Hive.
|
Package lazygit provides a lazygit plugin for Hive. |
|
Package neovim provides a Neovim plugin for Hive.
|
Package neovim provides a Neovim plugin for Hive. |
|
Package tmux provides a tmux plugin for Hive with default session management commands.
|
Package tmux provides a tmux plugin for Hive with default session management commands. |