Documentation
¶
Overview ¶
Package hive provides the service layer for orchestrating hive operations.
Index ¶
- func RenderUserCommandWindows(renderer *tmpl.Renderer, windows []config.WindowConfig, data map[string]any) ([]coretmux.RenderedWindow, error)
- func RenderWindows(renderer *tmpl.Renderer, windows []config.WindowConfig, data SpawnData) ([]coretmux.RenderedWindow, error)
- type App
- type BuildInfo
- type ContextService
- func (c *ContextService) CreateSymlink(ctxDir string) (bool, error)
- func (c *ContextService) Init(ctxDir string) ([]string, error)
- func (c *ContextService) Prune(ctxDir string, olderThan time.Duration) (int, error)
- func (c *ContextService) ResolveDir(ctx context.Context, repo string, shared bool) (string, error)
- type CreateOptions
- type DoctorService
- type FileCopier
- type HookRunner
- type MessageService
- func (m *MessageService) Acknowledge(ctx context.Context, consumerID string, messageIDs []string) error
- func (m *MessageService) GenerateTopic(prefix string) string
- func (m *MessageService) GetUnread(ctx context.Context, consumerID string, topic string) ([]messaging.Message, error)
- func (m *MessageService) ListTopics(ctx context.Context) ([]string, error)
- func (m *MessageService) Prune(ctx context.Context, olderThan time.Duration) (int, error)
- func (m *MessageService) Publish(ctx context.Context, msg messaging.Message, topics []string) error
- func (m *MessageService) Subscribe(ctx context.Context, topic string, since time.Time) ([]messaging.Message, error)
- type RecycleData
- type Recycler
- type SessionClient
- type SessionService
- func (s *SessionService) AddWindowsToTmuxSession(ctx context.Context, tmuxName, workDir string, windows []action.WindowSpec, ...) error
- func (s *SessionService) CreateSession(ctx context.Context, opts CreateOptions) (*session.Session, error)
- func (s *SessionService) CreateSessionWithWindows(ctx context.Context, req action.NewSessionRequest, windows []action.WindowSpec, ...) error
- func (s *SessionService) DeleteSession(ctx context.Context, id string) error
- func (s *SessionService) DetectRemote(ctx context.Context, dir string) (string, error)
- func (s *SessionService) DetectSession(ctx context.Context) (string, error)
- func (s *SessionService) GetSession(ctx context.Context, id string) (session.Session, error)
- func (s *SessionService) Git() git.Git
- func (s *SessionService) ListSessions(ctx context.Context) ([]session.Session, error)
- func (s *SessionService) OpenTmuxSession(ctx context.Context, name, path, remote, targetWindow string, background bool) error
- func (s *SessionService) Prune(ctx context.Context, all bool) (int, error)
- func (s *SessionService) RecycleSession(ctx context.Context, id string, w io.Writer) error
- func (s *SessionService) RenameSession(ctx context.Context, id, newName string) error
- func (s *SessionService) SilenceOutput() (restore func())
- type SpawnData
- type Spawner
- func (s *Spawner) AddWindowsToTmuxSession(ctx context.Context, tmuxName, workDir string, ...) error
- func (s *Spawner) OpenWindows(ctx context.Context, windows []config.WindowConfig, data SpawnData, ...) error
- func (s *Spawner) Spawn(ctx context.Context, commands []string, data SpawnData) error
- func (s *Spawner) SpawnWindows(ctx context.Context, windows []config.WindowConfig, data SpawnData, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenderUserCommandWindows ¶ added in v0.32.0
func RenderUserCommandWindows(renderer *tmpl.Renderer, windows []config.WindowConfig, data map[string]any) ([]coretmux.RenderedWindow, error)
RenderUserCommandWindows renders windows from a UserCommand using the provided template data map. Unlike RenderWindows, it accepts map[string]any to include .Form and session variables.
func RenderWindows ¶ added in v0.32.0
func RenderWindows(renderer *tmpl.Renderer, windows []config.WindowConfig, data SpawnData) ([]coretmux.RenderedWindow, error)
RenderWindows renders a slice of WindowConfig templates against SpawnData, producing fully-resolved RenderedWindow values ready for the tmux Client.
Types ¶
type App ¶
type App struct {
Sessions *SessionService
Messages *MessageService
Context *ContextService
Doctor *DoctorService
Bus *eventbus.EventBus
Terminal *terminal.Manager
Plugins *plugins.Manager
Config *config.Config
DB *db.DB
KV kv.KV
Renderer *tmpl.Renderer
Build BuildInfo
}
App is the central entry point for all hive operations. Commands and TUI consume App instead of cherry-picking raw dependencies.
func NewApp ¶
func NewApp( sessions *SessionService, msgStore messaging.Store, cfg *config.Config, bus *eventbus.EventBus, termMgr *terminal.Manager, pluginMgr *plugins.Manager, database *db.DB, kvStore kv.KV, renderer *tmpl.Renderer, pluginInfos []doctor.PluginInfo, ) *App
NewApp constructs an App from explicit dependencies.
type ContextService ¶
type ContextService struct {
// contains filtered or unexported fields
}
ContextService manages per-repository context directories.
func NewContextService ¶
func NewContextService(cfg *config.Config, gitClient git.Git) *ContextService
NewContextService creates a new ContextService.
func (*ContextService) CreateSymlink ¶
func (c *ContextService) CreateSymlink(ctxDir string) (bool, error)
CreateSymlink creates a symlink from the current directory to the context directory. Returns true if the symlink already existed and pointed to the correct target.
func (*ContextService) Init ¶
func (c *ContextService) Init(ctxDir string) ([]string, error)
Init creates the context directory and standard subdirectories. Returns the list of subdirectories that were newly created.
func (*ContextService) Prune ¶
Prune deletes files in the context directory older than the given duration. Returns the number of files removed.
func (*ContextService) ResolveDir ¶
ResolveDir determines the context directory for the given repo spec. If repo is "owner/repo", it resolves directly. If shared is true, returns the shared dir. Otherwise detects from the current directory's git remote.
type CreateOptions ¶
type CreateOptions struct {
Name string // Session name (used in path)
SessionID string // Session ID (auto-generated if empty)
Prompt string // Prompt to pass to spawned terminal (batch only)
Remote string // Git remote URL to clone (auto-detected if empty)
Source string // Source directory for file copying
UseBatchSpawn bool // Use batch_spawn commands instead of spawn
// SkipSpawn skips the configured spawn strategy (spawn: / batch_spawn: / windows:).
// The caller is responsible for launching any terminal or tmux session. Use this
// when the session directory is needed but terminal management happens elsewhere
// (e.g. CreateSessionWithWindows, which creates the tmux session itself).
SkipSpawn bool
}
CreateOptions configures session creation.
type DoctorService ¶
type DoctorService struct {
// contains filtered or unexported fields
}
DoctorService runs health checks on the hive setup.
func NewDoctorService ¶
func NewDoctorService(store session.Store, cfg *config.Config, pluginInfos []doctor.PluginInfo) *DoctorService
NewDoctorService creates a new DoctorService.
type FileCopier ¶
type FileCopier struct {
// contains filtered or unexported fields
}
FileCopier copies files from a source directory to a destination.
func NewFileCopier ¶
func NewFileCopier(log zerolog.Logger, stdout io.Writer) *FileCopier
NewFileCopier creates a new FileCopier.
type HookRunner ¶
type HookRunner struct {
// contains filtered or unexported fields
}
HookRunner executes repository-specific setup hooks.
func NewHookRunner ¶
func NewHookRunner(log zerolog.Logger, executor executil.Executor, stdout, stderr io.Writer) *HookRunner
NewHookRunner creates a new HookRunner.
type MessageService ¶
type MessageService struct {
// contains filtered or unexported fields
}
MessageService wraps messaging.Store with domain logic.
func NewMessageService ¶
func NewMessageService(store messaging.Store, cfg *config.Config, bus *eventbus.EventBus) *MessageService
NewMessageService creates a new MessageService.
func (*MessageService) Acknowledge ¶
func (m *MessageService) Acknowledge(ctx context.Context, consumerID string, messageIDs []string) error
Acknowledge marks messages as read by a consumer.
func (*MessageService) GenerateTopic ¶
func (m *MessageService) GenerateTopic(prefix string) string
GenerateTopic creates a new topic name using the configured prefix and a random suffix.
func (*MessageService) GetUnread ¶
func (m *MessageService) GetUnread(ctx context.Context, consumerID string, topic string) ([]messaging.Message, error)
GetUnread returns messages not yet acknowledged by consumer.
func (*MessageService) ListTopics ¶
func (m *MessageService) ListTopics(ctx context.Context) ([]string, error)
ListTopics returns all topic names.
type RecycleData ¶
type RecycleData struct {
DefaultBranch string
}
RecycleData contains template data for recycle commands.
type Recycler ¶
type Recycler struct {
// contains filtered or unexported fields
}
Recycler handles resetting a session environment for reuse.
func NewRecycler ¶
NewRecycler creates a new Recycler.
func (*Recycler) Recycle ¶
func (r *Recycler) Recycle(ctx context.Context, path string, commands []string, data RecycleData, w io.Writer) error
Recycle executes recycle commands sequentially in the session directory. Commands are rendered as Go templates with the provided data. Output is written to the provided writer. If w is nil, output is discarded.
type SessionClient ¶ added in v0.32.0
type SessionClient interface {
CreateSession(ctx context.Context, name, workDir string, windows []coretmux.RenderedWindow, background bool) error
OpenSession(ctx context.Context, name, workDir string, windows []coretmux.RenderedWindow, background bool, targetWindow string) error
AddWindows(ctx context.Context, name, workDir string, windows []coretmux.RenderedWindow) error
AttachOrSwitch(ctx context.Context, name string) error
}
SessionClient is the interface used by consumers that create/open tmux sessions.
type SessionService ¶
type SessionService struct {
// contains filtered or unexported fields
}
SessionService orchestrates hive session operations.
func NewSessionService ¶
func NewSessionService( sessions session.Store, gitClient git.Git, cfg *config.Config, bus *eventbus.EventBus, exec executil.Executor, renderer *tmpl.Renderer, log zerolog.Logger, stdout, stderr io.Writer, ) *SessionService
NewSessionService creates a new SessionService.
func (*SessionService) AddWindowsToTmuxSession ¶ added in v0.32.0
func (s *SessionService) AddWindowsToTmuxSession(ctx context.Context, tmuxName, workDir string, windows []action.WindowSpec, background bool) error
AddWindowsToTmuxSession adds windows to an existing tmux session, converting action.WindowSpec to coretmux.RenderedWindow. Satisfies the command.WindowSpawner interface.
func (*SessionService) CreateSession ¶
func (s *SessionService) CreateSession(ctx context.Context, opts CreateOptions) (*session.Session, error)
CreateSession creates a new session or recycles an existing one.
func (*SessionService) CreateSessionWithWindows ¶ added in v0.32.0
func (s *SessionService) CreateSessionWithWindows(ctx context.Context, req action.NewSessionRequest, windows []action.WindowSpec, background bool) error
CreateSessionWithWindows creates a new Hive session, optionally runs shCmd in its directory, then opens tmux windows in it. Non-zero shCmd exit aborts window creation. Satisfies the command.WindowSpawner interface.
func (*SessionService) DeleteSession ¶
func (s *SessionService) DeleteSession(ctx context.Context, id string) error
DeleteSession removes a session and its directory.
func (*SessionService) DetectRemote ¶
DetectRemote gets the git remote URL from the specified directory.
func (*SessionService) DetectSession ¶
func (s *SessionService) DetectSession(ctx context.Context) (string, error)
DetectSession returns the session ID for the current working directory. Returns empty string if not in a hive session.
func (*SessionService) GetSession ¶
GetSession returns a session by ID.
func (*SessionService) Git ¶
func (s *SessionService) Git() git.Git
Git returns the git client for use in background operations.
func (*SessionService) ListSessions ¶
ListSessions returns all sessions.
func (*SessionService) OpenTmuxSession ¶ added in v0.32.0
func (s *SessionService) OpenTmuxSession(ctx context.Context, name, path, remote, targetWindow string, background bool) error
OpenTmuxSession opens (or creates) a tmux session for the given session parameters. It resolves the spawn strategy, renders window templates, and delegates to the spawner.
func (*SessionService) Prune ¶
Prune removes recycled and corrupted sessions and their directories. If all is true, deletes ALL recycled sessions. If all is false, respects max_recycled limit per repository (keeps newest N).
func (*SessionService) RecycleSession ¶
RecycleSession marks a session for recycling and runs recycle commands. The session directory is not moved; only the DB record state changes. Output is written to w. If w is nil, output is discarded.
func (*SessionService) RenameSession ¶
func (s *SessionService) RenameSession(ctx context.Context, id, newName string) error
RenameSession changes the name (and slug) of an existing session.
func (*SessionService) SilenceOutput ¶ added in v0.32.0
func (s *SessionService) SilenceOutput() (restore func())
SilenceOutput redirects all output to io.Discard and returns a restore function that reverts to the previous writers. Call before starting the TUI to prevent hook and spawn output from corrupting the terminal display.
type SpawnData ¶
type SpawnData struct {
Path string // Absolute path to session directory
Name string // Session name (display name)
Prompt string // User-provided prompt (batch only)
Slug string // Session slug (URL-safe version of name)
ContextDir string // Path to context directory
Owner string // Repository owner
Repo string // Repository name
}
SpawnData is the template context for spawn commands.
type Spawner ¶
type Spawner struct {
// contains filtered or unexported fields
}
Spawner handles terminal spawning with template rendering.
func NewSpawner ¶
func NewSpawner(log zerolog.Logger, executor executil.Executor, renderer *tmpl.Renderer, tmuxClient SessionClient, stdout, stderr io.Writer) *Spawner
NewSpawner creates a new Spawner.
func (*Spawner) AddWindowsToTmuxSession ¶ added in v0.32.0
func (s *Spawner) AddWindowsToTmuxSession(ctx context.Context, tmuxName, workDir string, windows []coretmux.RenderedWindow, background bool) error
AddWindowsToTmuxSession adds pre-rendered windows to an existing tmux session. If background is false, switches to the session after adding windows.
func (*Spawner) OpenWindows ¶ added in v0.32.0
func (s *Spawner) OpenWindows(ctx context.Context, windows []config.WindowConfig, data SpawnData, background bool, targetWindow string) error
OpenWindows renders window templates and opens (or creates) a tmux session. If the session already exists, it attaches to it (optionally selecting targetWindow).
func (*Spawner) SpawnWindows ¶ added in v0.32.0
func (s *Spawner) SpawnWindows(ctx context.Context, windows []config.WindowConfig, data SpawnData, background bool) error
SpawnWindows renders window templates and creates a tmux session.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package plugins provides a plugin system for extending Hive with additional commands and status providers.
|
Package plugins provides a plugin system for extending Hive with additional commands and status providers. |
|
beads
Package beads provides a Beads issue tracker plugin for Hive.
|
Package beads provides a Beads issue tracker plugin for Hive. |
|
claude
Package claude provides Claude Code integration for Hive.
|
Package claude provides Claude Code integration for Hive. |
|
contextdir
Package contextdir provides commands for opening context directories.
|
Package contextdir provides commands for opening context directories. |
|
github
Package github provides a GitHub plugin for Hive.
|
Package github provides a GitHub plugin for Hive. |
|
lazygit
Package lazygit provides a lazygit plugin for Hive.
|
Package lazygit provides a lazygit plugin for Hive. |
|
neovim
Package neovim provides a Neovim plugin for Hive.
|
Package neovim provides a Neovim plugin for Hive. |
|
tmux
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. |
|
Package scripts embeds and extracts bundled helper scripts (hive-tmux, agent-send).
|
Package scripts embeds and extracts bundled helper scripts (hive-tmux, agent-send). |