forge

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ForgejoSummarySchemaVersion = 1

	ReviewerSummaryKind = "looper.forgejo.reviewer_summary"
	FixerSummaryKind    = "looper.forgejo.fixer_summary"

	ReviewerSummaryMarker = "looper:forgejo-reviewer-summary"
	FixerSummaryMarker    = "looper:forgejo-fixer-summary"
)
View Source
const (
	TeaErrorMissing           = "tea_missing"
	TeaErrorLoginMissing      = "tea_login_missing"
	TeaErrorLoginHostMismatch = "tea_login_host_mismatch"
	TeaErrorAuthFailed        = "tea_auth_failed"
)
View Source
const (
	ProviderKindGitHub  = config.ProviderKindGitHub
	ProviderKindForgejo = config.ProviderKindForgejo
	ProviderKindPlane   = config.ProviderKindPlane
)
View Source
const (
	ReviewDiscoveryReviewRequest ReviewDiscoveryStrategy = "review_request"
	ReviewDiscoveryLabel         ReviewDiscoveryStrategy = "label"

	ReviewPublishNative      ReviewPublishStrategy = "native_review"
	ReviewPublishCommentOnly ReviewPublishStrategy = "comment_only"

	ThreadResolutionNative   ThreadResolutionStrategy = "native"
	ThreadResolutionDisabled ThreadResolutionStrategy = "disabled"

	ReviewCommentResolutionNative     ReviewCommentResolutionStrategy = "native"
	ReviewCommentResolutionManualOnly ReviewCommentResolutionStrategy = "manual_only"
	ReviewCommentResolutionDisabled   ReviewCommentResolutionStrategy = "disabled"

	WorkerClaimAssignSelf  WorkerClaimStrategy = "assign_self"
	WorkerClaimPreAssigned WorkerClaimStrategy = "pre_assigned"

	WebhookNative  WebhookStrategy = "native"
	WebhookPolling WebhookStrategy = "polling"
)
View Source
const TrustedEnvFileEnv = "LOOPER_TRUSTED_ENV_FILE"

TrustedEnvFileEnv is the process env key that points at a KEY=value file of secrets for trusted Looper CLI wrappers (for example `looper review submit`). Only the trusted looper shim may set this for its real-looper child; agent processes must never receive this variable.

View Source
const TrustedReviewConfigChildFD = 3

TrustedReviewConfigChildFD is the child file descriptor for the config snapshot pipe. Go's os/exec maps ExtraFiles[i] to FD 3+i, so the first ExtraFile is always FD 3 (after stdin/stdout/stderr).

View Source
const TrustedReviewConfigFDEnv = "LOOPER_TRUSTED_REVIEW_CONFIG_FD"

TrustedReviewConfigFDEnv identifies the inherited, read-only pipe containing the exact materialized config snapshot for a trusted review child. The pipe replaces a named temporary file so the same-UID agent cannot discover or rewrite the snapshot between proxy minting and review submission.

View Source
const TrustedReviewSockEnv = "LOOPER_TRUSTED_REVIEW_SOCK"

TrustedReviewSockEnv is the agent-facing env key for the trusted review-submit proxy socket. The path is not a secret: agents may use the socket only to invoke `looper review submit`, and the proxy never returns provider tokens. Pattern matches SSH_AUTH_SOCK: a capability channel, not a credential dump.

Variables

This section is empty.

Functions

func FormatTrustedReviewPRRef added in v0.10.6

func FormatTrustedReviewPRRef(repo string, prNumber int64) string

FormatTrustedReviewPRRef builds the canonical owner/repo#N form used to bind a review-submit proxy to a single pull request for one agent run.

func LoadTrustedReviewConfigSnapshot added in v0.11.0

func LoadTrustedReviewConfigSnapshot() (config.LoadedFileConfig, bool, error)

LoadTrustedReviewConfigSnapshot consumes the exact materialized snapshot supplied to a proxy child. It intentionally bypasses normal config file, environment, and CLI precedence: those layers were already resolved by the daemon when it captured the run. Provider credential variables remain in the child environment for the selected transport but cannot rewrite this config.

The descriptor is one-shot: this function closes it and clears TrustedReviewConfigFDEnv. A second call fails loud (missing descriptor or EBADF). Trusted CLI entrypoints must not load config twice; auto-upgrade skips trusted proxy children for that reason.

func LookupProviderToken added in v0.10.6

func LookupProviderToken(tokenEnv string) string

LookupProviderToken resolves a provider tokenEnv name from the process environment first, then from LOOPER_TRUSTED_ENV_FILE when present.

func MatchTeaLoginHost added in v0.10.6

func MatchTeaLoginHost(loginURL, providerBaseURL string) bool

MatchTeaLoginHost reports whether the tea login URL matches the provider base URL.

func ParseUniqueFixerSummaryComment

func ParseUniqueFixerSummaryComment(comments []Comment) (Comment, FixerSummary, error)

func ParseUniqueReviewerSummaryComment

func ParseUniqueReviewerSummaryComment(comments []Comment) (Comment, ReviewerSummary, error)

func ProxyReviewSubmit added in v0.10.6

func ProxyReviewSubmit(argv []string, stdin []byte, cwd string) error

ProxyReviewSubmit forwards a review-submit invocation to the trusted proxy. On success it writes the proxy stdout/stderr to the current process streams and returns a process-style exit error when the proxied command failed. The daemon-side listener enforces the per-run allowed PR binding; this client only checks the command shape before dialing.

func RenderFixerSummary

func RenderFixerSummary(summary FixerSummary) (string, error)

func RenderReviewerSummary

func RenderReviewerSummary(summary ReviewerSummary) (string, error)

func ResolveTeaPath added in v0.10.6

func ResolveTeaPath(provider config.ProviderConfig, lookPath func(string) (string, error)) (string, error)

ResolveTeaPath returns an absolute tea executable path from config or PATH.

func StartTrustedReviewProxy added in v0.10.6

func StartTrustedReviewProxy(realLooper string, trustedEnv map[string]string, allowedPRRef, allowedCwd string, configSnapshot config.Config, policy TrustedReviewProxyPolicy, tracker processcontainment.LiveTracker) (sockPath string, cleanup func(), err error)

StartTrustedReviewProxy listens on a private Unix socket and runs `looper review submit` in a daemon-side child with the run-captured credential environment injected. Agents receive only the socket path (via TrustedReviewSockEnv), never a secret-bearing wrapper path, config snapshot path, or LOOPER_TRUSTED_ENV_FILE.

trustedEnv may be empty for tea-backed Forgejo providers that have no tokenEnv. The proxy still binds PR/CWD/policy/config so agents cannot retarget review submit; tea credentials resolve from the daemon process environment.

allowedPRRef must be the daemon-selected pull request in owner/repo#N form. The proxy rejects any review-submit argv that targets a different PR so a prompt-injected agent cannot publish under tokens for another PR.

allowedCwd must be the daemon-selected working directory for that run. Child processes always use this CWD; request-supplied cwd is ignored so a compromised agent cannot retarget provider-qualified project resolution.

configSnapshot is the complete materialized config captured by the run. The proxy sanitizes and retains its encoded bytes in memory, then supplies them to each child through an inherited pipe. The agent receives neither a path nor the snapshot bytes and therefore cannot rewrite the child's authority.

policy is the daemon-selected effective review-events policy, expected PR head, and manual-run identity for the run (including loop-metadata overrides). Agent argv may still include local flags for the prompted command shape, but the proxy always rewrites them to this bound authority before spawning the credential-injected child.

tracker, when non-nil, registers each Supervisor-owned review-submit child handle so daemon shutdown can wait for confirmed drain and retain storage on Kill/Drain failure (ADR-0015 / #577).

func TeaPathBaseName added in v0.10.6

func TeaPathBaseName(path string) string

TeaPathBaseName returns only the binary basename for safe logging/display.

func TrustedReviewProxyChildConfigured added in v0.11.2

func TrustedReviewProxyChildConfigured() bool

TrustedReviewProxyChildConfigured reports whether this process is a daemon-spawned trusted review-submit child (credential-bearing, snapshot via inherited FD). Callers must not run ambient CLI side effects such as auto-upgrade that would consume the one-shot config descriptor.

func TrustedReviewSockConfigured added in v0.10.6

func TrustedReviewSockConfigured() bool

TrustedReviewSockConfigured reports whether this process should proxy `review submit` through the daemon-side trusted socket.

func ValidateFixerResultsForReviewerSummary

func ValidateFixerResultsForReviewerSummary(reviewer ReviewerSummary, fixer FixerSummary) error

func ValidateFixerSummary

func ValidateFixerSummary(summary FixerSummary) error

func ValidateReviewerSummary

func ValidateReviewerSummary(summary ReviewerSummary) error

func WriteTrustedEnvFile added in v0.10.6

func WriteTrustedEnvFile(env map[string]string) (string, error)

WriteTrustedEnvFile materializes provider secrets into a 0600 temp file and returns its path. Callers must remove the file when the agent run ends.

func WriteTrustedLooperWrapper added in v0.10.6

func WriteTrustedLooperWrapper(realLooper string, env map[string]string) (wrapperPath string, cleanup func(), err error)

WriteTrustedLooperWrapper materializes provider secrets and a looper shim that injects LOOPER_TRUSTED_ENV_FILE only into the real looper child process. Callers should expose wrapperPath as the agent-facing looper CLI path and must never put LOOPER_TRUSTED_ENV_FILE into the agent process environment. cleanup removes the temp directory holding the shim and secret file.

Types

type AccessState added in v0.10.4

type AccessState string
const (
	AccessReadable     AccessState = "readable"
	AccessWritable     AccessState = "writable"
	AccessReadOnly     AccessState = "read_only"
	AccessInsufficient AccessState = "insufficient"
	AccessUnknown      AccessState = "unknown"
)

type AuthenticationState added in v0.10.4

type AuthenticationState string
const (
	AuthenticationValid                AuthenticationState = "valid"
	AuthenticationInvalid              AuthenticationState = "invalid"
	AuthenticationForbidden            AuthenticationState = "forbidden"
	AuthenticationMissingToken         AuthenticationState = "missing_token"
	AuthenticationTeaMissing           AuthenticationState = "tea_missing"
	AuthenticationTeaLoginMissing      AuthenticationState = "tea_login_missing"
	AuthenticationTeaLoginHostMismatch AuthenticationState = "tea_login_host_mismatch"
	AuthenticationTeaAuthFailed        AuthenticationState = "tea_auth_failed"
	AuthenticationUnknown              AuthenticationState = "unknown"
)

type BranchRef

type BranchRef struct {
	Name string
	SHA  string
}

type Capabilities

type Capabilities struct {
	Issues                  bool
	PullRequests            bool
	Labels                  bool
	Assignees               bool
	Comments                bool
	Identity                bool
	Diffs                   bool
	NativeReviews           bool
	ReviewRequests          bool
	AutoMerge               bool
	Webhooks                bool
	ReviewCommentResolution ReviewCommentResolutionStrategy
	Dependencies            bool

	ReviewDiscovery  ReviewDiscoveryStrategy
	ReviewPublish    ReviewPublishStrategy
	ThreadResolution ThreadResolutionStrategy
	WorkerClaim      WorkerClaimStrategy
	Webhook          WebhookStrategy
}

func StaticCapabilities

func StaticCapabilities(kind ProviderKind) (Capabilities, bool)

type CapabilityReport added in v0.10.4

type CapabilityReport struct {
	Configured      ProbeState `json:"configured"`
	ConfiguredScope string     `json:"configuredScope,omitempty"`
	Observed        ProbeState `json:"observed"`
	Effective       ProbeState `json:"effective"`
	Degraded        bool       `json:"degraded"`
	Reason          string     `json:"reason,omitempty"`
}

type Comment

type Comment struct {
	ID        int64
	Body      string
	HTMLURL   string
	UpdatedAt string
	User      Identity
}

type CompareBranchesInput

type CompareBranchesInput struct {
	Base string
	Head string
}

type CompareBranchesResult

type CompareBranchesResult struct {
	Status       string
	AheadBy      int
	BehindBy     int
	TotalCommits int
}

type CreateCommentInput

type CreateCommentInput struct {
	IssueNumber int64
	Body        string
}

type CreatePullRequestInput

type CreatePullRequestInput struct {
	Title string
	Body  string
	Head  string
	Base  string
}

type CreatePullRequestReviewInput added in v0.10.6

type CreatePullRequestReviewInput struct {
	Number   int64
	Body     string
	Event    string
	CommitID string
	Comments []PullRequestReviewCommentInput
}

type EvidenceReachability

type EvidenceReachability string
const (
	EvidenceReachabilityUnknown     EvidenceReachability = ""
	EvidenceReachabilityVerified    EvidenceReachability = "verified"
	EvidenceReachabilityUnverified  EvidenceReachability = "unverified"
	EvidenceReachabilityUnreachable EvidenceReachability = "unreachable"
)

type FixerEvidence

type FixerEvidence struct {
	HeadSHA   string               `json:"head_sha,omitempty"`
	Reachable EvidenceReachability `json:"reachable,omitempty"`
}

type FixerItemResult

type FixerItemResult string
const (
	FixerItemResultFixed    FixerItemResult = "fixed"
	FixerItemResultDeclined FixerItemResult = "declined"
	FixerItemResultDeferred FixerItemResult = "deferred"
)

type FixerResult

type FixerResult struct {
	ReviewItemID string          `json:"review_item_id"`
	Result       FixerItemResult `json:"result"`
	Explanation  string          `json:"explanation"`
}

type FixerSummary

type FixerSummary struct {
	Kind                  string        `json:"kind"`
	SchemaVersion         int           `json:"schema_version"`
	FixRoundID            int           `json:"fix_round_id"`
	ConsumedReviewRoundID int           `json:"consumed_review_round_id"`
	ObservedHeadSHA       string        `json:"observed_head_sha,omitempty"`
	Evidence              FixerEvidence `json:"evidence,omitempty"`
	Results               []FixerResult `json:"results"`
}

func NewFixerSummary

func NewFixerSummary(fixRoundID, consumedReviewRoundID int, results []FixerResult) FixerSummary

func ParseFixerSummary

func ParseFixerSummary(body string) (FixerSummary, error)

type ForgejoClient

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

func NewForgejoClient

func NewForgejoClient(ref RepositoryRef, token string, options ...ForgejoOption) (*ForgejoClient, error)

func NewForgejoClientFromConfig

func NewForgejoClientFromConfig(provider config.ProviderConfig, repo string, options ...ForgejoOption) (*ForgejoClient, error)

NewForgejoClientFromConfig builds a Forgejo client for token-env or tea auth. Tea-backed mode validates the explicit login against the provider base URL and routes API calls through `tea api --login <login>` without reading tokens.

func (*ForgejoClient) AddIssueAssignees

func (forgejo *ForgejoClient) AddIssueAssignees(ctx context.Context, issueNumber int64, assignees []string) error

func (*ForgejoClient) AddIssueLabels

func (forgejo *ForgejoClient) AddIssueLabels(ctx context.Context, issueNumber int64, labels []string) ([]Label, error)

func (*ForgejoClient) AddPullRequestReviewers added in v0.10.6

func (forgejo *ForgejoClient) AddPullRequestReviewers(ctx context.Context, number int64, reviewers []string) error

func (*ForgejoClient) Capabilities

func (forgejo *ForgejoClient) Capabilities() Capabilities

func (*ForgejoClient) CheckRepository added in v0.10.5

func (forgejo *ForgejoClient) CheckRepository(ctx context.Context) error

CheckRepository verifies that the configured token can access the bound repository without returning or logging repository metadata.

func (*ForgejoClient) CompareBranches

func (forgejo *ForgejoClient) CompareBranches(ctx context.Context, input CompareBranchesInput) (CompareBranchesResult, error)

func (*ForgejoClient) CreateIssueComment

func (forgejo *ForgejoClient) CreateIssueComment(ctx context.Context, input CreateCommentInput) (Comment, error)

func (*ForgejoClient) CreatePullRequest

func (forgejo *ForgejoClient) CreatePullRequest(ctx context.Context, input CreatePullRequestInput) (PullRequest, error)

func (*ForgejoClient) CreatePullRequestReview added in v0.10.6

func (forgejo *ForgejoClient) CreatePullRequestReview(ctx context.Context, input CreatePullRequestReviewInput) (PullRequestReview, error)

func (*ForgejoClient) CurrentUser

func (forgejo *ForgejoClient) CurrentUser(ctx context.Context) (Identity, error)

func (*ForgejoClient) Kind

func (forgejo *ForgejoClient) Kind() ProviderKind

func (*ForgejoClient) ListIssueComments

func (forgejo *ForgejoClient) ListIssueComments(ctx context.Context, issueNumber int64) ([]Comment, error)

func (*ForgejoClient) ListOpenIssues

func (forgejo *ForgejoClient) ListOpenIssues(ctx context.Context, input ListIssuesInput) ([]Issue, error)

func (*ForgejoClient) ListOpenPullRequests

func (forgejo *ForgejoClient) ListOpenPullRequests(ctx context.Context, input ListPullRequestsInput) ([]PullRequest, error)

func (*ForgejoClient) ListPullRequestReviewComments added in v0.10.2

func (forgejo *ForgejoClient) ListPullRequestReviewComments(ctx context.Context, number int64) ([]PullRequestReviewComment, error)

func (*ForgejoClient) ListPullRequestReviewers added in v0.10.6

func (forgejo *ForgejoClient) ListPullRequestReviewers(ctx context.Context, number int64) ([]Identity, error)

func (*ForgejoClient) ListPullRequestReviews added in v0.10.6

func (forgejo *ForgejoClient) ListPullRequestReviews(ctx context.Context, number int64) ([]PullRequestReview, error)

func (*ForgejoClient) ListReviewRequestedPullRequests added in v0.10.6

func (forgejo *ForgejoClient) ListReviewRequestedPullRequests(ctx context.Context, reviewer string, limit int) ([]PullRequest, error)

func (*ForgejoClient) PullRequestDiff

func (forgejo *ForgejoClient) PullRequestDiff(ctx context.Context, number int64) (string, error)

func (*ForgejoClient) RemoveIssueAssignees

func (forgejo *ForgejoClient) RemoveIssueAssignees(ctx context.Context, issueNumber int64, assignees []string) error

func (*ForgejoClient) RemoveIssueLabel

func (forgejo *ForgejoClient) RemoveIssueLabel(ctx context.Context, issueNumber int64, label string) error

func (*ForgejoClient) Repository

func (forgejo *ForgejoClient) Repository() RepositoryRef

func (*ForgejoClient) ResolvePullRequestReviewComment added in v0.10.2

func (forgejo *ForgejoClient) ResolvePullRequestReviewComment(ctx context.Context, number int64, commentID int64) error

func (*ForgejoClient) UpdateIssueComment

func (forgejo *ForgejoClient) UpdateIssueComment(ctx context.Context, input UpdateCommentInput) (Comment, error)

func (*ForgejoClient) UpdatePullRequest

func (forgejo *ForgejoClient) UpdatePullRequest(ctx context.Context, input UpdatePullRequestInput) (PullRequest, error)

func (*ForgejoClient) ViewIssue

func (forgejo *ForgejoClient) ViewIssue(ctx context.Context, number int64) (Issue, error)

func (*ForgejoClient) ViewPullRequest

func (forgejo *ForgejoClient) ViewPullRequest(ctx context.Context, number int64) (PullRequest, error)

type ForgejoHTTPError added in v0.10.2

type ForgejoHTTPError struct {
	Method     string
	Path       string
	StatusCode int
	Message    string
}

func (*ForgejoHTTPError) Error added in v0.10.2

func (err *ForgejoHTTPError) Error() string

func (*ForgejoHTTPError) HTTPStatusCode added in v0.10.2

func (err *ForgejoHTTPError) HTTPStatusCode() int

type ForgejoOption

type ForgejoOption func(*ForgejoClient)

func WithHTTPClient

func WithHTTPClient(client *http.Client) ForgejoOption

func WithLookPath added in v0.10.6

func WithLookPath(lookPath func(string) (string, error)) ForgejoOption

WithLookPath injects executable lookup used when resolving tea from PATH.

func WithTeaRunner added in v0.10.6

func WithTeaRunner(runner TeaCommandRunner) ForgejoOption

WithTeaRunner injects a tea CLI runner (tests and advanced wiring).

func WithTimeout

func WithTimeout(timeout time.Duration) ForgejoOption

type ForgejoProbeProject added in v0.10.4

type ForgejoProbeProject struct {
	ID   string
	Repo string
}

type ForgejoProjectHealth added in v0.10.4

type ForgejoProjectHealth struct {
	ProjectID    string                      `json:"projectId"`
	Repository   string                      `json:"repository"`
	Access       AccessState                 `json:"access"`
	Readable     *bool                       `json:"readable,omitempty"`
	Writable     *bool                       `json:"writable,omitempty"`
	StatusCode   int                         `json:"statusCode,omitempty"`
	Capabilities map[string]CapabilityReport `json:"capabilities"`
}

type ForgejoProviderHealth added in v0.10.4

type ForgejoProviderHealth struct {
	ProviderID     string                      `json:"providerId"`
	Kind           ProviderKind                `json:"kind"`
	Reachability   ReachabilityState           `json:"reachability"`
	Authentication AuthenticationState         `json:"authentication"`
	Identity       *Identity                   `json:"identity,omitempty"`
	Version        string                      `json:"version,omitempty"`
	VersionState   ProbeState                  `json:"versionState"`
	StatusCode     int                         `json:"statusCode,omitempty"`
	Capabilities   map[string]CapabilityReport `json:"capabilities"`
	Projects       []ForgejoProjectHealth      `json:"projects"`
}

func ProbeForgejoProvider added in v0.10.4

func ProbeForgejoProvider(ctx context.Context, provider config.ProviderConfig, projects []ForgejoProbeProject, options ...ForgejoOption) ForgejoProviderHealth

ProbeForgejoProvider performs bounded, read-only requests. The returned structure deliberately contains no endpoint, token environment name, token, tea token material, or raw error text so status output remains safe to share.

type ForgejoReviewCommentResolverField added in v0.10.2

type ForgejoReviewCommentResolverField struct {
	Present bool
	Value   *Identity
}

type Identity

type Identity struct {
	Login string `json:"login"`
	ID    int64  `json:"id"`
}

type Issue

type Issue struct {
	Number    int64
	Title     string
	Body      string
	State     string
	HTMLURL   string
	UpdatedAt string
	User      Identity
	Labels    []Label
	Assignees []Identity
}

type Label

type Label struct {
	ID   int64
	Name string
}

type ListIssuesInput

type ListIssuesInput struct {
	State    string
	Labels   []string
	Assignee string
	Limit    int
}

type ListPullRequestsInput

type ListPullRequestsInput struct {
	State  string
	Labels []string
	Limit  int
}

type PlaneClient

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

PlaneClient is a task-source provider backed by a Plane project. It reads work-items (issues), labels, comments, and assignees from Plane's REST API. It deliberately does NOT implement pull-request / diff / review operations: those belong to the project's GitHub code repo and are handled by the GitHub path in the scheduler adapters (see internal/runtime/scheduler.go).

func NewPlaneClient

func NewPlaneClient(ref RepositoryRef, workspace, projectID, token string, options ...PlaneOption) (*PlaneClient, error)

NewPlaneClient builds a Plane task-source client. codeRepo (ref.Repo) is the GitHub repository (owner/name) where pull requests are opened for work done on these work-items; it is retained only for Repository() reporting.

func NewPlaneClientFromConfig

func NewPlaneClientFromConfig(provider config.ProviderConfig, codeRepo string, options ...PlaneOption) (*PlaneClient, error)

NewPlaneClientFromConfig builds a Plane client from a provider config. codeRepo is the project's GitHub code repo (project.Repo). The Plane API key is read from the env var named by provider.TokenEnv.

func (*PlaneClient) AddIssueAssignees

func (plane *PlaneClient) AddIssueAssignees(ctx context.Context, issueNumber int64, assignees []string) error

AddIssueAssignees merges assignee ids (Plane user UUIDs) onto a work-item.

func (*PlaneClient) AddIssueLabels

func (plane *PlaneClient) AddIssueLabels(ctx context.Context, issueNumber int64, labels []string) ([]Label, error)

AddIssueLabels attaches label names to a work-item, creating any that do not yet exist. Plane PATCH replaces the whole label set, so the current labels are read and merged (never clobbered). Returns the resulting label set by name.

func (*PlaneClient) Capabilities

func (plane *PlaneClient) Capabilities() Capabilities

func (*PlaneClient) CreateIssueComment

func (plane *PlaneClient) CreateIssueComment(ctx context.Context, input CreateCommentInput) (Comment, error)

CreateIssueComment posts an HTML comment onto a work-item. Plane comment ids are UUIDs and cannot be represented in looper's int64 Comment.ID, so the returned Comment.ID is 0 and HTMLURL points at the work-item web page.

func (*PlaneClient) CurrentUser

func (plane *PlaneClient) CurrentUser(ctx context.Context) (Identity, error)

func (*PlaneClient) Kind

func (plane *PlaneClient) Kind() ProviderKind

func (*PlaneClient) ListIssueComments

func (plane *PlaneClient) ListIssueComments(ctx context.Context, issueNumber int64) ([]Comment, error)

ListIssueComments returns the work-item comments (oldest first). Comment.ID is 0 because Plane comment ids are UUIDs (see CreateIssueComment).

func (*PlaneClient) ListOpenIssues

func (plane *PlaneClient) ListOpenIssues(ctx context.Context, input ListIssuesInput) ([]Issue, error)

ListOpenIssues returns Plane work-items mapped onto looper's Issue type. When input.Labels is non-empty the results are filtered client-side to those that carry ALL requested label names (label UUIDs are resolved to names first).

func (*PlaneClient) ProjectID

func (plane *PlaneClient) ProjectID() string

func (*PlaneClient) RemoveIssueLabel

func (plane *PlaneClient) RemoveIssueLabel(ctx context.Context, issueNumber int64, label string) error

RemoveIssueLabel detaches a single label (by name) from a work-item.

func (*PlaneClient) Repository

func (plane *PlaneClient) Repository() RepositoryRef

func (*PlaneClient) ViewIssue

func (plane *PlaneClient) ViewIssue(ctx context.Context, number int64) (Issue, error)

ViewIssue resolves a work-item by its per-project sequence_id (looper's Issue number) and maps it onto the Issue type.

func (*PlaneClient) Workspace

func (plane *PlaneClient) Workspace() string

Workspace and ProjectID expose the Plane coordinates the client reads from.

type PlaneOption

type PlaneOption func(*PlaneClient)

func WithPlaneHTTPClient

func WithPlaneHTTPClient(client *http.Client) PlaneOption

WithPlaneHTTPClient injects an *http.Client (used by tests to avoid network).

func WithPlaneTimeout

func WithPlaneTimeout(timeout time.Duration) PlaneOption

WithPlaneTimeout overrides the HTTP client timeout.

func WithPlaneUserAgent

func WithPlaneUserAgent(userAgent string) PlaneOption

WithPlaneUserAgent overrides the default User-Agent header.

type ProbeState added in v0.10.4

type ProbeState string
const (
	ProbeStateSupported   ProbeState = "supported"
	ProbeStateUnsupported ProbeState = "unsupported"
	ProbeStateUnknown     ProbeState = "unknown"
)

func ProbeForgejoReviewCommentResolution added in v0.10.4

func ProbeForgejoReviewCommentResolution(ctx context.Context, provider config.ProviderConfig, repo string, options ...ForgejoOption) (ProbeState, error)

type Provider

type Provider interface {
	Kind() ProviderKind
	Repository() RepositoryRef
	Capabilities() Capabilities
	CurrentUser(ctx context.Context) (Identity, error)
}

type ProviderKind

type ProviderKind = config.ProviderKind

type PullRequest

type PullRequest struct {
	Number    int64
	Title     string
	Body      string
	State     string
	IsDraft   bool
	HTMLURL   string
	UpdatedAt string
	User      Identity
	Head      BranchRef
	Base      BranchRef
	Labels    []Label
	Assignees []Identity
	Reviewers []Identity
}

type PullRequestReview added in v0.10.6

type PullRequestReview struct {
	ID       int64
	State    string
	Body     string
	CommitID string
	HTMLURL  string
	User     Identity
	Comments []PullRequestReviewComment
}

type PullRequestReviewComment added in v0.10.2

type PullRequestReviewComment struct {
	ID                  int64
	Body                string
	HTMLURL             string
	UpdatedAt           string
	User                Identity
	Path                string
	CommitID            string
	OriginalCommitID    string
	Position            int
	OriginalPosition    int
	DiffHunk            string
	PullRequestReviewID int64
	Resolver            ForgejoReviewCommentResolverField
}

type PullRequestReviewCommentInput added in v0.10.6

type PullRequestReviewCommentInput struct {
	Body        string `json:"body"`
	Path        string `json:"path,omitempty"`
	Line        int64  `json:"-"`
	Side        string `json:"-"`
	StartLine   int64  `json:"-"`
	StartSide   string `json:"-"`
	OldPosition int64  `json:"old_position,omitempty"`
	NewPosition int64  `json:"new_position,omitempty"`
	ExtraLines  int64  `json:"extra_lines_count,omitempty"`
}

type ReachabilityState added in v0.10.4

type ReachabilityState string
const (
	ReachabilityReachable   ReachabilityState = "reachable"
	ReachabilityUnreachable ReachabilityState = "unreachable"
)

type Registry

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

func NewRegistry

func NewRegistry(providers ...Provider) (*Registry, error)

func (*Registry) Get

func (registry *Registry) Get(id string) (Provider, bool)

type RepositoryRef

type RepositoryRef struct {
	ProviderID string
	Kind       ProviderKind
	BaseURL    string
	Repo       string
}

type ReviewCommentResolutionStrategy added in v0.10.4

type ReviewCommentResolutionStrategy string

type ReviewDiscoveryStrategy

type ReviewDiscoveryStrategy string

type ReviewItem

type ReviewItem struct {
	ReviewItemID    string           `json:"review_item_id"`
	Status          ReviewItemStatus `json:"status"`
	Title           string           `json:"title"`
	Body            string           `json:"body"`
	Files           []string         `json:"files,omitempty"`
	Supersedes      []string         `json:"supersedes,omitempty"`
	SupersededBy    string           `json:"superseded_by,omitempty"`
	LastSeenRoundID int              `json:"last_seen_round_id"`
}

type ReviewItemStatus

type ReviewItemStatus string
const (
	ReviewItemStatusOpen       ReviewItemStatus = "open"
	ReviewItemStatusResolved   ReviewItemStatus = "resolved"
	ReviewItemStatusSuperseded ReviewItemStatus = "superseded"
)

type ReviewPublishStrategy

type ReviewPublishStrategy string

type ReviewerSummary

type ReviewerSummary struct {
	Kind               string       `json:"kind"`
	SchemaVersion      int          `json:"schema_version"`
	ReviewRoundID      int          `json:"review_round_id"`
	LatestFixerRoundID int          `json:"latest_fixer_round_id,omitempty"`
	Items              []ReviewItem `json:"items"`
}

func NewReviewerSummary

func NewReviewerSummary(reviewRoundID int, items []ReviewItem) ReviewerSummary

func ParseReviewerSummary

func ParseReviewerSummary(body string) (ReviewerSummary, error)

type TeaAuthError added in v0.10.6

type TeaAuthError struct {
	Code    string
	Message string
}

TeaAuthError is a typed, actionable failure for tea-backed Forgejo auth. Code values are stable health/status tokens: tea_missing, tea_login_missing, tea_login_host_mismatch, tea_auth_failed.

func (*TeaAuthError) Error added in v0.10.6

func (err *TeaAuthError) Error() string

type TeaCommandRunner added in v0.10.6

type TeaCommandRunner interface {
	Run(ctx context.Context, teaPath string, args []string, stdin string, timeout time.Duration) (shell.Result, error)
}

TeaCommandRunner executes tea CLI invocations. Tests inject a fake runner.

type TeaLogin added in v0.10.6

type TeaLogin struct {
	Name    string         `json:"name"`
	URL     string         `json:"url"`
	SSHHost string         `json:"ssh_host"`
	User    string         `json:"user"`
	Default teaDefaultFlag `json:"default"`
}

TeaLogin describes a tea CLI login entry from `tea logins list -o json`. Tokens are never present in this output and must never be requested. Default accepts both JSON bool and string forms: tea 0.14.x emits "default":"true", while some builds emit a real boolean.

func FindTeaLogin added in v0.10.6

func FindTeaLogin(logins []TeaLogin, name string) (TeaLogin, error)

FindTeaLogin returns the login with the given name, or tea_login_missing.

func ListTeaLogins added in v0.10.6

func ListTeaLogins(ctx context.Context, teaPath string, runner TeaCommandRunner) ([]TeaLogin, error)

ListTeaLogins runs `tea logins list -o json` and returns login metadata only. It never reads tea's config file or tokens.

func MatchingTeaLogins added in v0.10.6

func MatchingTeaLogins(ctx context.Context, baseURL, teaPath string, runner TeaCommandRunner) ([]TeaLogin, error)

MatchingTeaLogins returns tea logins whose URL matches baseURL (for discovery UX).

func ValidateTeaLoginForProvider added in v0.10.6

func ValidateTeaLoginForProvider(ctx context.Context, provider config.ProviderConfig, runner TeaCommandRunner, lookPath func(string) (string, error)) (teaPath string, login TeaLogin, err error)

ValidateTeaLoginForProvider lists tea logins and requires an explicit login whose URL matches the provider base URL. Never uses tea's default login.

type ThreadResolutionStrategy

type ThreadResolutionStrategy string

type TrustedReviewProxyPolicy added in v0.10.6

type TrustedReviewProxyPolicy struct {
	Clean            string // COMMENT or APPROVE
	Blocking         string // COMMENT or REQUEST_CHANGES
	ExpectedCommitID string
	ReviewerManual   bool
	ReviewerRunID    string
}

TrustedReviewProxyPolicy is the daemon-selected review authority bound into a trusted review-submit proxy for one agent run. Agent-supplied review-event, expected-head, and manual-run identity flags are stripped and replaced with these values before the child runs.

type UnsupportedCapabilityError added in v0.10.6

type UnsupportedCapabilityError struct {
	Capability string
	State      ProbeState
}

func (*UnsupportedCapabilityError) Error added in v0.10.6

func (err *UnsupportedCapabilityError) Error() string

type UpdateCommentInput

type UpdateCommentInput struct {
	CommentID int64
	Body      string
}

type UpdatePullRequestInput

type UpdatePullRequestInput struct {
	Number int64
	Title  *string
	Body   *string
}

type WebhookStrategy

type WebhookStrategy string

type WorkerClaimStrategy

type WorkerClaimStrategy string

Jump to

Keyboard shortcuts

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