Documentation
¶
Overview ¶
Package github reads GitHub state through the gh CLI for loom's session cards and issue picker. It is standalone: no app, ui, or session imports. Every entry point fails closed — when gh is missing, unauthenticated, or offline the caller gets an error and renders nothing, never a guess.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckCLI ¶
func CheckCLI(r internalexec.Executor) error
CheckCLI reports whether gh is installed and authenticated. The messages are user-facing (they surface in the picker and the push error path).
func ParseShorthand ¶
ParseShorthand recognizes a prompt whose first token is "#<n>" and returns the number and the remaining text (trimmed). ok is false for anything else, including "#0".
func SeedPrompt ¶
SeedPrompt composes the agent's initial prompt from an issue: a preamble naming the issue and URL, the title as a heading, then the body verbatim.
Types ¶
type Snapshot ¶
type Snapshot struct {
PRs map[string]PR // keyed by head branch name
Issues map[int]Issue // keyed by issue number
FetchedAt time.Time
}
Snapshot is one repo's GitHub state at FetchedAt.
func Query ¶
func Query(ctx context.Context, repoDir string, linked []int, r internalexec.Executor) (Snapshot, error)
Query fetches repoDir's PRs (all states, reduced to one per head branch) and open issues. linked lists issue numbers loom sessions reference; any of them absent from the open list (i.e. closed) is backfilled with one `gh issue view` each — a backfill failure only omits that issue. A pr/issue list failure is fatal: the caller must drop its cached snapshot rather than keep a stale one.
type State ¶
type State struct {
Known bool
IssueNumber int
// IssueTitle is empty until a snapshot resolves the number, so ""
// means "not resolved yet", not "an issue with a blank title".
// IssueClosed is likewise only meaningful once the title is set.
IssueTitle string
IssueClosed bool
HasPR bool
PRNumber int
// PRState, Review and Checks are meaningless unless HasPR: they sit
// at their None zero values for a session with no PR, which is not
// a state any real PR can be in. Always branch on HasPR first.
PRState PRState
Review Review
Checks Checks
}
State is the per-session join of a Snapshot, ready for rendering. Known=false means the repo was not (successfully) queried and the UI must render nothing; Known=true with HasPR=false means "no PR" — the two must never be conflated.