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 ¶
- Variables
- func BackendNames() []string
- type Backend
- type Capabilities
- type Detail
- type FetchDetailParams
- type Item
- type Manifest
- type MarkdownDetail
- type PickerManifest
- type Registry
- type RegistryEntry
- type RenderedSession
- type SearchManifest
- type SearchParams
- type SearchResult
- type Source
- type TemplateConfig
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidBackend = fmt.Errorf("not a valid Backend, try [%s]", strings.Join(_BackendNames, ", "))
Functions ¶
func BackendNames ¶ added in v0.56.0
func BackendNames() []string
BackendNames returns a list of possible string values of Backend.
Types ¶
type Backend ¶ added in v0.56.0
type Backend string
Backend identifies which forge driver services a source for a given repo. It is derived from the repo's git remote host (see DetectBackend).
ENUM(github, gitea)
func DetectBackend ¶ added in v0.56.0
DetectBackend resolves the forge backend for a git remote host.
Resolution order (first match wins):
- An explicit override in overrides (host -> backend), for ambiguous, mirrored, or self-hosted setups the heuristics cannot classify.
- Well-known public hosts (github.com, codeberg.org).
- A hostname heuristic ("gitea"/"forgejo" -> gitea, "github" -> github).
- Default: github. The gh CLI supports GitHub Enterprise hosts, so an unrecognized host is most safely treated as GitHub Enterprise; users point Gitea hosts at the gitea backend via overrides.
func ParseBackend ¶ added in v0.56.0
ParseBackend attempts to convert a string to a Backend.
func (*Backend) AppendText ¶ added in v0.56.0
AppendText appends the textual representation of itself to the end of b (allocating a larger slice if necessary) and returns the updated slice.
Implementations must not retain b, nor mutate any bytes within b[:len(b)].
func (Backend) IsValid ¶ added in v0.56.0
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (Backend) MarshalText ¶ added in v0.56.0
MarshalText implements the text marshaller method.
func (*Backend) UnmarshalText ¶ added in v0.56.0
UnmarshalText implements the text unmarshaller method.
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
// Dir is the local repository working directory, when one is known; see
// SearchParams.Dir.
Dir 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 (id, backend) so a source id can be serviced by a different driver depending on the repo's forge.
func (*Registry) All ¶
func (r *Registry) All(backend Backend) []RegistryEntry
All returns the registered sources for backend in registration order.
func (*Registry) Get ¶
Get returns the source and template configuration registered under (id, backend).
func (*Registry) IDs ¶
IDs returns the distinct ids of all registered sources in registration order, deduplicated across backends.
func (*Registry) Register ¶
func (r *Registry) Register(id string, backend Backend, source Source, templates TemplateConfig, displayName string) error
Register adds a source under (id, backend). displayName defaults to id. It returns an error if id is empty, source is nil, or the (id, backend) pair is 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 ¶
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
// Dir is the local repository working directory, when one is known. CLI
// backends run their binary here so it can resolve the target host/login
// from the checkout's git remote (e.g. tea's login, gh's GHE host).
// Empty when there is no local checkout.
Dir 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 ¶
TemplateConfig holds the user-configured Go templates for mapping a selected source item into session creation inputs.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cliengine is the shared execution engine behind hive's CLI-backed sources (GitHub via gh, Gitea/Forgejo via tea).
|
Package cliengine is the shared execution engine behind hive's CLI-backed sources (GitHub via gh, Gitea/Forgejo via tea). |
|
Package ghcli implements hive's built-in GitHub sources as cliengine drivers backed by the gh CLI.
|
Package ghcli implements hive's built-in GitHub sources as cliengine drivers backed by the gh CLI. |
|
Package teacli implements hive's built-in Gitea/Forgejo sources as cliengine drivers backed by the tea CLI.
|
Package teacli implements hive's built-in Gitea/Forgejo sources as cliengine drivers backed by the tea CLI. |