provider

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package provider defines the Provider interface and URL-based registry that selects a GitHub or GitLab adapter. Lands in M2.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultRunner

func DefaultRunner(ctx context.Context, stdin io.Reader, name string, args ...string) ([]byte, error)

DefaultRunner runs the command via os/exec and returns stdout. On a non-zero exit it returns an error including the exit code and a trimmed copy of stderr.

Types

type PRSummary

type PRSummary struct {
	Number    int
	Title     string
	Author    string
	URL       string // canonical, ready to hand to runReview
	UpdatedAt time.Time
	Draft     bool
}

PRSummary is one row in the inbox list. URL is the only field the review pipeline strictly needs; the rest are display-only.

type Provider

type Provider interface {
	Supports(rawURL string) bool
	Preflight(ctx context.Context) error
	Fetch(ctx context.Context, rawURL string) (*review.ReviewInput, error)

	// PreflightList is a stricter preflight required for List(). The
	// public-URL Fetch flow doesn't need auth, but listing typically
	// does. Implementations should verify `gh auth status` / `glab auth
	// status` (or equivalent) succeeds and return an actionable error
	// otherwise.
	PreflightList(ctx context.Context) error

	// List enumerates open PRs/MRs for the given repo. Returns at most
	// 30 results in v1 (no pagination).
	List(ctx context.Context, repo RepoCoord) ([]PRSummary, error)
}

Provider fetches review target data for one host family.

Callers must invoke Preflight before Fetch. Preflight verifies the runtime environment (required CLI present, authenticated) so the model is never invoked when the fetch path is doomed to fail.

type Registry

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

Registry dispatches a URL to the first Provider that supports it.

The order of providers passed to NewRegistry is the dispatch order; for v1 the order doesn't matter because GitHub and GitLab URLs don't overlap, but stable ordering keeps error messages deterministic.

func NewRegistry

func NewRegistry(ps ...Provider) *Registry

NewRegistry builds a Registry from a list of providers.

func (*Registry) ByHost

func (r *Registry) ByHost(host string) (Provider, error)

ByHost returns the provider that claims the given host, or an error if none does. Implementation: synthesize candidate PR/MR URLs and reuse each Provider's Supports method. Avoids adding a Host() method to the Provider interface just for this helper.

func (*Registry) Find

func (r *Registry) Find(rawURL string) (Provider, error)

Find returns the first provider that supports the URL, or an error listing the URL when nothing matches.

type RepoCoord

type RepoCoord struct {
	Host  string // "github.com", "gitlab.com", "gitlab.example.com"
	Owner string // "selyafi" or "my-group/sub-group" (GitLab nested)
	Name  string // "diffsmith"
}

RepoCoord identifies a repository hosted on a Git forge. Used by the inbox flow to enumerate PRs/MRs for a specific repo without first constructing a URL.

type Runner

type Runner func(ctx context.Context, stdin io.Reader, name string, args ...string) ([]byte, error)

Runner executes an external command and returns its stdout.

Modeled as a function type so tests inject canned responses without implementing an interface. Real implementations should use argv form (variadic args) — passing user-controlled values through `sh -c` is forbidden by docs/architecture.md § Process Execution.

Pass stdin as nil when the command takes no input. Adapters that pipe data to the child (e.g. codex via ADR 0007) provide a Reader here.

Directories

Path Synopsis
Package githubgh implements the GitHub provider adapter by shelling out to the `gh` CLI.
Package githubgh implements the GitHub provider adapter by shelling out to the `gh` CLI.
Package gitlabglab implements the GitLab provider adapter by shelling out to the `glab` CLI.
Package gitlabglab implements the GitLab provider adapter by shelling out to the `glab` CLI.

Jump to

Keyboard shortcuts

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