github

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 36 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package github is the GitHub source plugin: what its binary serves through the SDK, over its own store in the state directory the host gives it.

Index

Constants

View Source
const (
	// ActionBasics reads a pull request's basics: its answer is the
	// pull request as JSON.
	ActionBasics = "pr.basics"
	// ActionRefresh reads a pull request in full into the store and
	// reports it.
	ActionRefresh = "pr.refresh"
	// ActionAdopt takes a pull request over into the loop: the store keeps
	// it taken over, and the reviews its address rounds covered are
	// forgotten, so its triage starts from none of them. Its args are the
	// pull request's basics as the host read them, which the store keeps
	// until its next read when it holds none of it.
	ActionAdopt = "pr.adopt"
)

The actions the host calls.

View Source
const (
	EffectReviewed  = "pr.reviewed"
	EffectAddressed = "pr.addressed"
)

The effects plugin.toml declares.

View Source
const (
	JobFast = "fast"
	JobSlow = "slow"
)

The jobs plugin.toml declares, which Ingest runs.

View Source
const (
	// CommandClone clones a repository: clone <owner>/<name> <path>.
	CommandClone = "clone"
	// CommandAuth checks that gh is installed and logged in; it exits
	// ExitNoGH when gh is not installed.
	CommandAuth = "auth"
	// CommandReviewedRepos lists the repositories of the pull requests the
	// viewer reviewed since a date: reviewed-repos <yyyy-mm-dd>, one
	// owner/name a line, once per pull request.
	CommandReviewedRepos = "reviewed-repos"
	// CommandTeams lists the viewer's teams, one org/slug a line.
	CommandTeams = "teams"
)
View Source
const (
	ToolDraft   = "github_draft"
	ToolThreads = "github_threads"
)

The tools of the plugin's manifest.

View Source
const (
	ViewExplore       = "explore"
	ViewExploreRecent = "explore.recent"
	ViewChecks        = "checks"
	ViewBudget        = "budget"
	// ViewCandidate reads one pull request from GitHub as Explore shows
	// it, in any state; its query is a ChecksQuery.
	ViewCandidate = "candidate"
)

The views the host asks for: a search of GitHub for Explore, the recent searches, the failed steps of a pull request's failing checks and the API's budget.

View Source
const ActionNudgePrepare = "nudge.prepare"

ActionNudgePrepare is the nudge's prepare: it refuses a nudge when nobody but the viewer is to be asked or the same wait was nudged already, and fills whom it asks into the call's inputs.

View Source
const ExitNoGH = 127

ExitNoGH is the exit of a command that found no gh to run, the shell's "command not found".

Variables

Commands are the commands the plugin serves in CLI mode.

Functions

func PrepareNudge

func PrepareNudge(ctx context.Context, h src.Host, env NudgeEnv, u sdk.Unit, raw json.RawMessage) (json.RawMessage, error)

PrepareNudge is the nudge's prepare of u with the daemon's args, reading the unit's events and turns from h.

Types

type BriefParts

type BriefParts struct {
	ChangedFiles int      `json:"changed_files"`
	Files        []string `json:"files,omitempty"`
	Title        string   `json:"title,omitempty"`
	Body         string   `json:"body,omitempty"`
	Issue        string   `json:"issue,omitempty"`
	// Listed are the changed files as the prompt lists them, with their
	// additions and deletions.
	Listed []string `json:"listed,omitempty"`
	// DiffError is why GitHub served no diff; "" with one.
	DiffError string `json:"diff_error,omitempty"`
}

BriefParts are a pull request's parts of its brief input: what brief_runs.input stores, and the facts the prompt lays out besides the diff, which is the input's text.

type Budget

type Budget struct {
	Low       bool      `json:"low"`
	Remaining int       `json:"remaining"`
	Limit     int       `json:"limit"`
	ResetAt   time.Time `json:"reset_at,omitzero"`
}

Budget is the API's GraphQL bucket, which the searches and the sweeps spend; Low says it refuses background reads.

type Check

type Check struct {
	Name    string   `json:"name"`
	URL     string   `json:"url,omitempty"`
	Summary string   `json:"summary,omitempty"`
	Steps   []string `json:"steps,omitempty"`
}

Check is a failing check of a pull request, with the failed steps of its GitHub Actions job when they could be read.

type ChecksQuery

type ChecksQuery struct {
	Owner  string `json:"owner"`
	Repo   string `json:"repo"`
	Number int    `json:"number"`
}

ChecksQuery names the pull request a view reads.

type Data

type Data struct {
	PR            pr.PR         `json:"pr"`
	Detail        *store.Detail `json:"detail,omitempty"`
	DetailVersion int           `json:"detail_version,omitempty"`
	DetailReadAt  time.Time     `json:"detail_read_at,omitzero"`
	Tracked       bool          `json:"tracked,omitempty"`
	// Row is the source part of the pull request's row payload.
	Row *row.Payload `json:"row,omitempty"`
	// Adopted says the pull request is taken over into the loop.
	Adopted bool `json:"adopted,omitempty"`
	// Plan is the planner's part.
	Plan *PlanData `json:"plan,omitempty"`
}

Data is a pull request's snapshot data: its row, its detail and whether the user tracks it.

type ExploreQuery

type ExploreQuery struct {
	Query string `json:"query"`
}

ExploreQuery is what Explore asks for.

type NudgeEnv

type NudgeEnv struct {
	Viewer string
	Ignore []string
	Now    time.Time
	Texts  nudge.Texts
}

NudgeEnv is what the nudge's prepare reads besides the host: the viewer, who a nudge never mentions, the time and the profile's texts.

type Payload

type Payload struct {
	URL, Owner, Repo  string
	Number            int
	Title, Author     string
	State             string
	Association       string
	Head, Base        string
	Labels            []string
	CrossRepository   bool
	Visibility        string
	Prior             *PriorReview
	ReviewRequested   bool
	LastReviewVerdict string
}

Payload is the data a turn's templates read of a pull request, under the payload root plugin.toml names: its basics as GitHub reads them now and your prior review, anchored to the head the loop's last record covered.

type PlanData

type PlanData struct {
	Rank  plan.Rank  `json:"rank"`
	Board plan.Board `json:"board"`
}

PlanData is the planner's part of a pull request's snapshot data: where its rounds rank and what the board reads of its workspaces.

type Plugin

type Plugin struct {
	// GH nil is gh on the PATH.
	GH gh.Runner
	// API are the API client's options; the zero value is GitHub's API at
	// the host gh names, with gh's token. The plugin sets its meter and
	// user agent.
	API api.Options
	// Now nil is the clock.
	Now func() time.Time
	// Git nil reads the checkouts with the git binary.
	Git plan.Git
	// contains filtered or unexported fields
}

Plugin is the GitHub source plugin as the SDK serves it.

func (*Plugin) Action

func (p *Plugin) Action(ctx context.Context, req src.ActionRequest) (json.RawMessage, error)

Action runs one of the actions the host calls.

func (*Plugin) ApplyEffect

func (p *Plugin) ApplyEffect(ctx context.Context, req src.EffectRequest) error

ApplyEffect applies an effect of the plugin's turns, and a draft's pr.nudged, which the publisher recorded as it posted.

func (*Plugin) Basis added in v0.5.0

func (p *Plugin) Basis(ctx context.Context, u sdk.Unit, _ string) (string, error)

Basis is u's head commit as GitHub has it now, never the store's: what a review on u would be written against.

func (*Plugin) BriefDescribe

func (p *Plugin) BriefDescribe(ctx context.Context, in src.BriefInput) (string, error)

BriefDescribe is in, one line, as the prompt's header names it.

func (*Plugin) BriefInput

func (p *Plugin) BriefInput(ctx context.Context, u sdk.Unit) (src.BriefInput, error)

BriefInput reads what a brief of a pull request reads now: its title, description, first closing issue and changed files, then its diff, under the priority the host's call carries.

func (*Plugin) BriefRevision

func (p *Plugin) BriefRevision(ctx context.Context, u sdk.Unit) (src.BriefRevision, error)

BriefRevision is what the stored pull request is at: its head and its description's edit time, its changed files, and the attempt key the brief runs have stored since version 4.

func (*Plugin) BriefStale

func (p *Plugin) BriefStale(_ context.Context, req src.BriefStaleRequest) (bool, error)

BriefStale is the queue's rule: a failed attempt is due when the pull request moved or its backoff passed, a brief when the pull request moved: its description edited a quiet while ago, or a head that added more than a few files.

func (*Plugin) BriefWant

func (p *Plugin) BriefWant(context.Context, sdk.Unit) (bool, error)

BriefWant is false: the host's queue writes a pull request's brief, not the plugin.

func (*Plugin) CallTool added in v0.5.0

func (p *Plugin) CallTool(ctx context.Context, call src.ToolCall) (src.ToolResult, error)

CallTool runs one of the manifest's tools for the session call.Session.

func (*Plugin) Checkout

func (p *Plugin) Checkout(ctx context.Context, u sdk.Unit) (src.Checkout, bool, error)

Checkout is the repository, head and base a pull request's work checks out, as the store last read them.

func (*Plugin) Health

func (p *Plugin) Health(context.Context) (sdk.Health, error)

Health is loading until the store is open and every stored pull request was reported.

func (*Plugin) Identity

func (p *Plugin) Identity(ctx context.Context) (src.Identity, error)

Identity is the viewer: the login the store keeps, else the one GitHub's API names once started, or gh in CLI mode, which the store then keeps; and the scope teams the viewer is in.

func (*Plugin) Ingest

func (p *Plugin) Ingest(ctx context.Context, req src.IngestRequest) (src.IngestResult, error)

Ingest runs one of the manifest's jobs, then reports what it changed.

func (*Plugin) Landed

func (p *Plugin) Landed(context.Context, src.Draft) (sdk.Unit, bool, error)

func (*Plugin) Locate

func (p *Plugin) Locate(ctx context.Context, dir string) (sdk.Unit, bool, error)

Locate is the pull request of the branch the checkout at dir has, as gh reads it.

func (*Plugin) Notify

func (p *Plugin) Notify(ctx context.Context, units []sdk.Unit, topics []sdk.Topic) error

Notify links the workspaces again when the host's listing moved, reads the configuration again when it changed, and reports again the pull requests whose rows read what changed: their events and turns, the viewer, the configuration.

func (*Plugin) Payload

func (p *Plugin) Payload(ctx context.Context, req src.PayloadRequest) (src.PayloadResult, error)

Payload is a pull request as a turn reads it.

func (*Plugin) Place

func (p *Plugin) Place(ctx context.Context, d src.Draft) (src.Placed, error)

func (*Plugin) Placement

func (p *Plugin) Placement(context.Context, sdk.Unit, string) (src.Placements, error)

Placement is where a pull request's work runs: the plugin names none, and the host's workspaces place it.

func (*Plugin) Plan

func (p *Plugin) Plan(ctx context.Context, u sdk.Unit, st src.RoundState) (src.Plan, error)

Plan is the rounds the planner plans on u over st, the host's round state of u: each with the marks the host writes when it sends or skips it.

func (*Plugin) Proposals

func (p *Plugin) Proposals(ctx context.Context, now time.Time) (src.Proposed, error)

Proposals are the github-nudge rule's drafts: one per stalled open pull request whose nudge would go now, and its withdrawal on each open one no longer stalled. None before the store knows the viewer.

func (*Plugin) Publish

func (p *Plugin) Publish(ctx context.Context, d src.Draft) (src.Evidence, error)

func (*Plugin) Resolve

func (p *Plugin) Resolve(_ context.Context, address string) (sdk.Unit, bool, error)

Resolve is the pull request a page address or a key names.

func (*Plugin) RunCLI

func (p *Plugin) RunCLI(ctx context.Context, req src.CLIRequest, stdout, stderr io.Writer) (int, error)

RunCLI runs one of the commands plugin.toml declares, with gh.

func (*Plugin) Start

func (p *Plugin) Start(ctx context.Context, req src.StartRequest) error

Start opens the plugin's store in its state directory, importing what the host exported once, and reports every stored pull request; the plugin is loading until it has.

func (*Plugin) Stop

func (p *Plugin) Stop(context.Context) error

Stop ends the first report and closes the store.

func (*Plugin) Track

func (p *Plugin) Track(ctx context.Context, req src.TrackRequest) (src.Tracked, error)

Track reads a pull request in full and follows it once the host, which admitted the read, asks to.

func (*Plugin) Untrack

func (p *Plugin) Untrack(ctx context.Context, u sdk.Unit) error

Untrack stops tracking a pull request.

func (*Plugin) Validate

func (p *Plugin) Validate(ctx context.Context, d src.Draft) error

func (*Plugin) Verify

func (p *Plugin) Verify(ctx context.Context, d src.Draft, startedAt time.Time) (src.Evidence, bool, error)

func (*Plugin) View

func (p *Plugin) View(ctx context.Context, req src.ViewRequest) (json.RawMessage, error)

View serves one of the plugin's views.

func (*Plugin) Where

func (p *Plugin) Where(ctx context.Context, d src.Draft) (string, error)

func (*Plugin) Within added in v0.5.0

func (p *Plugin) Within(ctx context.Context, u sdk.Unit, target string) (bool, error)

Within says whether target lies inside u's pull request: the pull request, one of its review comments or one of its review threads.

func (*Plugin) WriteState

func (p *Plugin) WriteState(context.Context, src.StateWrite) (src.Evidence, error)

type PriorReview

type PriorReview struct {
	Verdict, Head, Endorsed string
	At                      time.Time
}

PriorReview is your latest submitted review: the head it covered, when, its newest verdict that is not a comment, and whether you stand behind the loop's record of it.

Directories

Path Synopsis
api
Package github reads pull requests over GitHub's HTTPS API, batching every pull request of a sweep into aliased GraphQL queries.
Package github reads pull requests over GitHub's HTTPS API, batching every pull request of a sweep into aliased GraphQL queries.
apitest
Package apitest serves an api.Client from gh fakes, as the plugin's tests write them, and records what it meters.
Package apitest serves an api.Client from gh fakes, as the plugin's tests write them, and records what it meters.
Package change holds the rules that decide what a change to a pull request calls for: a follow-up, a triage round, a board move.
Package change holds the rules that decide what a change to a pull request calls for: a follow-up, a triage round, a board move.
cmd
wloop-plugin-github command
Command wloop-plugin-github is the GitHub source plugin's binary, which the host runs as a child process.
Command wloop-plugin-github is the GitHub source plugin's binary, which the host runs as a child process.
Package collect keeps the plugin's store in step with GitHub: a cheap fast sweep that reads only what changed and a slow sweep that rebuilds the scope and catches what the searches no longer return.
Package collect keeps the plugin's store in step with GitHub: a cheap fast sweep that reads only what changed and a slow sweep that rebuilds the scope and catches what the searches no longer return.
Package explore turns what the user types in Explore into one GitHub search for open pull requests to help on.
Package explore turns what the user types in Explore into one GitHub search for open pull requests to help on.
Package gh shells out to the gh command line, which owns GitHub's authentication.
Package gh shells out to the gh command line, which owns GitHub's authentication.
Package git reads local checkouts with the git binary, as the planner asks.
Package git reads local checkouts with the git binary, as the planner asks.
Package nudge is the GitHub plugin's nudge: whom a nudge asks on a pull request, when it refuses, and the nudge drafts its github-nudge rule proposes on stalled pull requests.
Package nudge is the GitHub plugin's nudge: whom a nudge asks on a pull request, when it refuses, and the nudge drafts its github-nudge rule proposes on stalled pull requests.
Package plan is the GitHub plugin's round planner: over the plugin's pull requests and the host's round state, books, events and workspaces, it decides which automatic rounds are due, why, and what each covers.
Package plan is the GitHub plugin's round planner: over the plugin's pull requests and the host's round state, books, events and workspaces, it decides which automatic rounds are due, why, and what each covers.
Package pr is the GitHub plugin's pull request: its reference and the row the plugin's store keeps of it.
Package pr is the GitHub plugin's pull request: its reference and the row the plugin's store keeps of it.
Package publish posts the GitHub plugin's approved drafts on their pull request: an issue comment, a review, a reply in a review thread, a thread's resolution or a request for reviews.
Package publish posts the GitHub plugin's approved drafts on their pull request: an issue comment, a review, a reply in a review thread, a thread's resolution or a request for reviews.
Package row derives what the plugin reports of a pull request from the pull request and its events alone: its situation, the source part of its row's payload, its views and facets, its card, its items, its link signals and its workflow facts.
Package row derives what the plugin reports of a pull request from the pull request and its events alone: its situation, the source part of its row's payload, its views and facets, its card, its items, its link signals and its workflow facts.
Package scope turns the configured sources into the people, teams and repositories the inventory follows, and the searches that find them.
Package scope turns the configured sources into the people, teams and repositories the inventory follows, and the searches that find them.
Package situation derives who a pull request is waiting on, and since when, from the pull request and its events alone.
Package situation derives who a pull request is waiting on, and since when, from the pull request and its events alone.
Package store is the GitHub plugin's own database, in the state directory the host gives it: the pull requests it reads, their sightings and details, the workspaces' fetches, its meta values and the overrides it keeps of what the user set.
Package store is the GitHub plugin's own database, in the state directory the host gives it: the pull requests it reads, their sightings and details, the workspaces' fetches, its meta values and the overrides it keeps of what the user set.
Package workday counts time in working days, Monday to Friday, as the host counts a working-days value.
Package workday counts time in working days, Monday to Friday, as the host counts a working-days value.

Jump to

Keyboard shortcuts

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