sources

package
v0.55.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package sources defines the domain contract for browsing external systems (GitHub issues, and later Gitea/Grafana/etc.) and mapping a selected item into hive session-creation inputs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Capabilities

type Capabilities struct {
	FetchDetail bool
}

Capabilities declares optional source behavior.

type Detail

type Detail struct {
	Markdown *MarkdownDetail
}

Detail is an item's optional detail body, fetched via Source.FetchDetail. A nil Markdown means the item has no detail (a PR row, or a fetch that failed), so consumers render an empty body rather than panicking.

type FetchDetailParams

type FetchDetailParams struct {
	ID    string
	Scope string
	// URI is the stable item URI when the source supplies one; optional.
	URI string
}

FetchDetailParams carries the scope/URI alongside the ID so detail requests are self-contained and do not rely on IDs implicitly encoding their repository/org. This keeps the contract general for sources added later.

type Item

type Item struct {
	ID       string
	Title    string
	Subtitle string
	// URI is a stable identifier echoed back on FetchDetail; optional.
	URI    string
	Fields map[string]any
}

Item is a single browsable/selectable record returned by Search.

type Manifest

type Manifest struct {
	ID           string
	DisplayName  string
	Capabilities Capabilities
	Picker       PickerManifest
}

Manifest describes a source's identity and how the picker should display its items.

type MarkdownDetail

type MarkdownDetail struct {
	Content string
}

MarkdownDetail renders as markdown via the shared glamour renderer.

type PickerManifest

type PickerManifest struct {
	Search SearchManifest
}

PickerManifest configures how the TUI picker searches a source's items.

type Registry

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

Registry holds the set of sources configured for this hive instance in registration order, indexed by source id (e.g. "issues" or "prs") for lookup.

func NewRegistry

func NewRegistry() *Registry

NewRegistry constructs an empty Registry.

func (*Registry) All

func (r *Registry) All() []RegistryEntry

All returns all registered sources in registration order.

func (*Registry) Get

func (r *Registry) Get(id string) (Source, TemplateConfig, bool)

Get returns the source and template configuration registered under id.

func (*Registry) IDs

func (r *Registry) IDs() []string

IDs returns the ids of all registered sources in registration order.

func (*Registry) Register

func (r *Registry) Register(id string, source Source, templates TemplateConfig, displayName string) error

Register adds a source under id along with the template configuration used to render its selected items into session fields. displayName is shown in the picker tab bar; if empty, id is used. It returns an error if id is empty or already registered.

type RegistryEntry

type RegistryEntry struct {
	ID          string
	DisplayName string
	Source      Source
	Templates   TemplateConfig
}

RegistryEntry exposes a registered source's public fields for the picker.

type RenderedSession

type RenderedSession struct {
	Name   string
	Prompt string
	Tags   []string
}

RenderedSession is the result of rendering a TemplateConfig against a selected Item, ready to pass into hive.CreateOptions.

func RenderSessionTemplates

func RenderSessionTemplates(cfg TemplateConfig, item Item, detail Detail) (RenderedSession, error)

RenderSessionTemplates renders cfg's Name, Prompt, and Tags templates against item and detail, returning the rendered session fields. Each template is rendered independently so an error identifies which template failed.

type SearchManifest

type SearchManifest struct {
	// DebounceMS is the delay before a query change issues a remote search;
	// zero uses the picker's default debounce.
	DebounceMS int
}

SearchManifest configures how the picker issues search queries.

type SearchParams

type SearchParams struct {
	Query string
	Scope string
	// Cursor is an opaque pagination cursor; empty for the first page.
	// Remote sources may ignore it.
	Cursor string
}

SearchParams carries a search query and scope to a source.

type SearchResult

type SearchResult struct {
	Items []Item
	// NextCursor is opaque; empty when there are no further pages. This is a
	// seam for future pagination support and may always be left empty.
	NextCursor string
}

SearchResult is the response to a Search call.

type Source

type Source interface {
	// Name returns the source's stable identifier (e.g. "github").
	Name() string
	// Available reports whether the source's runtime dependencies
	// (binaries, auth, etc.) are satisfied.
	Available(ctx context.Context) bool
	// Initialize returns the source's display/picker manifest.
	Initialize(ctx context.Context) (Manifest, error)
	// Search returns items matching the given query/scope.
	Search(ctx context.Context, params SearchParams) (SearchResult, error)
	// FetchDetail returns the detail view for a single item.
	FetchDetail(ctx context.Context, params FetchDetailParams) (Detail, error)
}

Source browses an external system and returns items hive can display and map into sessions. Implementations may run in-process (e.g. GitHub via the gh CLI).

type TemplateConfig

type TemplateConfig struct {
	Name   string
	Prompt string
	Tags   []string
}

TemplateConfig holds the user-configured Go templates for mapping a selected source item into session creation inputs.

Directories

Path Synopsis
Package ghcli implements hive's built-in sources backed by the gh CLI.
Package ghcli implements hive's built-in sources backed by the gh CLI.

Jump to

Keyboard shortcuts

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