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. The child inherits diffsmith's working directory. Use this for provider CLIs (gh/glab) that operate on explicit URLs and for any caller that genuinely needs the real cwd.
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 ¶
NewRegistry builds a Registry from a list of providers.
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 ¶
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.
func IsolatedRunner ¶ added in v0.2.0
func IsolatedRunner() Runner
IsolatedRunner returns a Runner that executes each command in a fresh, empty temp directory (removed once the command returns). It exists for the model adapters (diffsmith-4tz): reviewer CLIs like codex/gemini/ claude autoload project context from their working directory — codex discovers .agents/skills/*/SKILL.md and may *activate* a project skill (e.g. one whose workflow posts review comments), gemini/claude onboard from AGENTS.md / CLAUDE.md. Running them in a neutral temp dir neutralizes that autoload, which protects diffsmith's no-auto-post guarantee and keeps reviews deterministic. The whole diff is piped via stdin, so reviewers need no access to the caller's cwd.
Only the working directory is isolated; user-level config and auth (~/.codex, ~/.gemini, ~/.claude) live under $HOME and are found via the environment, not cwd, so they keep working.
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. |