github

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatReviewsPrompt

func FormatReviewsPrompt(comments []ReviewComment) string

FormatReviewsPrompt formats a list of review comments into a prompt suitable for sending to an AI coding agent.

func IssueBranchName

func IssueBranchName(number int, title string) string

IssueBranchName generates a Git branch name from an issue number and title. e.g. issue #42 "Add dark mode" → "issue-42-add-dark-mode"

func IssueTaskContent

func IssueTaskContent(issue *Issue) string

IssueTaskContent formats a GitHub issue as a TASK.md file for the AI agent.

Types

type BranchStatus

type BranchStatus struct {
	Pushed            bool
	RemoteDeleted     bool // branch was previously pushed but no longer exists in remote
	RemoteCheckFailed bool // git ls-remote failed; Pushed/RemoteDeleted are unreliable
	PRURL             string
	PRState           string // "open", "merged", "closed", ""
	MergeConflicts    bool
	CIStatus          string // "success", "failure", "pending", ""
}

BranchStatus holds the combined branch push and PR status for a workspace.

type Issue

type Issue struct {
	Number int
	Title  string
	Body   string
	Labels []string
}

Issue represents a GitHub issue

type PRManager

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

PRManager handles GitHub PR operations

func New

func New() *PRManager

New creates a new PR manager

func (*PRManager) CreatePR

func (pm *PRManager) CreatePR(branch, baseBranch, title, body string) (string, error)

CreatePR creates a GitHub pull request using gh CLI

func (*PRManager) FetchPRReviews

func (pm *PRManager) FetchPRReviews(branch string) ([]ReviewComment, error)

FetchPRReviews returns only actionable, unresolved review comments for the PR associated with the given branch. Returns an empty slice if no PR exists.

General reviews: only CHANGES_REQUESTED reviews with a non-empty body are included. APPROVED, DISMISSED, and COMMENTED-only reviews are skipped.

Inline code comments: only comments belonging to unresolved review threads are included, determined via the GitHub GraphQL API.

func (*PRManager) GetBranchAndPRStatus

func (pm *PRManager) GetBranchAndPRStatus(branch, repoDir string, wasPushed bool) (BranchStatus, error)

GetBranchAndPRStatus returns the combined remote branch existence and PR status for the given branch. repoDir is used as the working directory for git commands. wasPushed should reflect the previously known BranchPushed state so RemoteDeleted can be set correctly when the branch disappears from remote.

func (*PRManager) GetFullPRStatus

func (pm *PRManager) GetFullPRStatus(branch string) (url, state string, err error)

GetFullPRStatus returns the URL and state of a PR for the given branch. State is lowercased: "open", "merged", or "closed".

func (*PRManager) GetIssue

func (pm *PRManager) GetIssue(number int) (*Issue, error)

GetIssue fetches a GitHub issue by number using the gh CLI

func (*PRManager) GetPRCIStatus

func (pm *PRManager) GetPRCIStatus(branch string) (string, error)

GetPRCIStatus returns the combined CI check status for the PR on the given branch. Returns "success", "failure", "pending", or "" if no checks exist.

func (*PRManager) GetPRStatus

func (pm *PRManager) GetPRStatus(branch string) (string, error)

GetPRStatus checks if a PR exists for the given branch

func (*PRManager) IsInstalled

func (pm *PRManager) IsInstalled() bool

IsInstalled reports whether the gh CLI is available on PATH. The result is cached after the first check.

type ReviewComment

type ReviewComment struct {
	Author string
	Body   string
	State  string // "CHANGES_REQUESTED", "APPROVED", "COMMENTED"
	Path   string // file path for inline comments; empty for general reviews
	Line   int    // line number for inline comments; 0 for general reviews
}

ReviewComment represents a single review comment on a PR. General reviews have an empty Path and zero Line. Inline (code) comments have Path and Line set.

Jump to

Keyboard shortcuts

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