issues

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package issues provides a generic interface for fetching issues from multiple sources (GitHub, Asana, etc.) to create Plural sessions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetIssueNumber

func GetIssueNumber(issue Issue) int

GetIssueNumber returns the issue number as an int (for backwards compatibility). Returns 0 if the ID is not a valid number.

Types

type AsanaConfigProvider

type AsanaConfigProvider interface {
	HasAsanaProject(repoPath string) bool
}

AsanaConfigProvider defines the configuration interface required by AsanaProvider.

type AsanaProject

type AsanaProject struct {
	GID  string
	Name string
}

AsanaProject represents an Asana project with its GID and name.

type AsanaProvider

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

AsanaProvider implements Provider for Asana Tasks using the Asana REST API.

func NewAsanaProvider

func NewAsanaProvider(cfg AsanaConfigProvider) *AsanaProvider

NewAsanaProvider creates a new Asana task provider.

func NewAsanaProviderWithClient

func NewAsanaProviderWithClient(cfg AsanaConfigProvider, client *http.Client, apiBase string) *AsanaProvider

NewAsanaProviderWithClient creates a new Asana task provider with a custom HTTP client and API base URL (for testing).

func (*AsanaProvider) FetchIssues

func (p *AsanaProvider) FetchIssues(ctx context.Context, repoPath, projectID string) ([]Issue, error)

FetchIssues retrieves incomplete tasks from the Asana project. The projectID should be the Asana project GID.

func (*AsanaProvider) FetchProjects

func (p *AsanaProvider) FetchProjects(ctx context.Context) ([]AsanaProject, error)

FetchProjects retrieves all projects accessible to the user. If the user belongs to a single workspace, project names are returned directly. If multiple workspaces exist, names are prefixed with "WorkspaceName / ProjectName".

func (*AsanaProvider) GenerateBranchName

func (p *AsanaProvider) GenerateBranchName(issue Issue) string

GenerateBranchName returns a branch name for the given Asana task. Format: "task-{slug}" where slug is derived from the task name.

func (*AsanaProvider) GetPRLinkText

func (p *AsanaProvider) GetPRLinkText(issue Issue) string

GetPRLinkText returns empty string for Asana tasks. Asana doesn't support auto-closing tasks via PR merge.

func (*AsanaProvider) IsConfigured

func (p *AsanaProvider) IsConfigured(repoPath string) bool

IsConfigured returns true if Asana is configured for the given repo. Requires both ASANA_PAT env var and a project GID mapped to the repo.

func (*AsanaProvider) Name

func (p *AsanaProvider) Name() string

Name returns the human-readable name of this provider.

func (*AsanaProvider) Source

func (p *AsanaProvider) Source() Source

Source returns the source type for this provider.

type GitHubProvider

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

GitHubProvider implements Provider for GitHub Issues using the gh CLI.

func NewGitHubProvider

func NewGitHubProvider(gitService *git.GitService) *GitHubProvider

NewGitHubProvider creates a new GitHub issue provider.

func (*GitHubProvider) FetchIssues

func (p *GitHubProvider) FetchIssues(ctx context.Context, repoPath, projectID string) ([]Issue, error)

FetchIssues retrieves open GitHub issues for the given repository. The projectID parameter is ignored for GitHub (uses gh CLI with repoPath).

func (*GitHubProvider) GenerateBranchName

func (p *GitHubProvider) GenerateBranchName(issue Issue) string

GenerateBranchName returns a branch name for the given GitHub issue. Format: "issue-{number}"

func (*GitHubProvider) GetPRLinkText

func (p *GitHubProvider) GetPRLinkText(issue Issue) string

GetPRLinkText returns the text to add to PR body to link/close the issue. Format: "Fixes #{number}"

func (*GitHubProvider) IsConfigured

func (p *GitHubProvider) IsConfigured(repoPath string) bool

IsConfigured returns true - GitHub is always available via gh CLI. The gh CLI is checked as a prerequisite when the app starts.

func (*GitHubProvider) Name

func (p *GitHubProvider) Name() string

Name returns the human-readable name of this provider.

func (*GitHubProvider) Source

func (p *GitHubProvider) Source() Source

Source returns the source type for this provider.

type Issue

type Issue struct {
	ID     string // Unique identifier ("123" for GitHub, "1234567890123" for Asana)
	Title  string
	Body   string
	URL    string
	Source Source
}

Issue represents a generic issue/task from any supported source.

type LinearConfigProvider

type LinearConfigProvider interface {
	HasLinearTeam(repoPath string) bool
}

LinearConfigProvider defines the configuration interface required by LinearProvider.

type LinearProvider

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

LinearProvider implements Provider for Linear Issues using the Linear GraphQL API.

func NewLinearProvider

func NewLinearProvider(cfg LinearConfigProvider) *LinearProvider

NewLinearProvider creates a new Linear issue provider.

func NewLinearProviderWithClient

func NewLinearProviderWithClient(cfg LinearConfigProvider, client *http.Client, apiBase string) *LinearProvider

NewLinearProviderWithClient creates a new Linear issue provider with a custom HTTP client and API base URL (for testing).

func (*LinearProvider) FetchIssues

func (p *LinearProvider) FetchIssues(ctx context.Context, repoPath, projectID string) ([]Issue, error)

FetchIssues retrieves active issues from the Linear team. The projectID should be the Linear team ID.

func (*LinearProvider) FetchTeams

func (p *LinearProvider) FetchTeams(ctx context.Context) ([]LinearTeam, error)

FetchTeams retrieves all teams accessible to the user.

func (*LinearProvider) GenerateBranchName

func (p *LinearProvider) GenerateBranchName(issue Issue) string

GenerateBranchName returns a branch name for the given Linear issue. Format: "linear-{identifier}" where identifier is lowercased (e.g., "linear-eng-123").

func (*LinearProvider) GetPRLinkText

func (p *LinearProvider) GetPRLinkText(issue Issue) string

GetPRLinkText returns the text to add to PR body to link/close the Linear issue. Linear supports auto-close via identifier mentions (e.g., "Fixes ENG-123").

func (*LinearProvider) IsConfigured

func (p *LinearProvider) IsConfigured(repoPath string) bool

IsConfigured returns true if Linear is configured for the given repo. Requires both LINEAR_API_KEY env var and a team ID mapped to the repo.

func (*LinearProvider) Name

func (p *LinearProvider) Name() string

Name returns the human-readable name of this provider.

func (*LinearProvider) Source

func (p *LinearProvider) Source() Source

Source returns the source type for this provider.

type LinearTeam

type LinearTeam struct {
	ID   string
	Name string
}

LinearTeam represents a Linear team with its ID and name.

type Provider

type Provider interface {
	// Name returns the human-readable name of this provider (e.g., "GitHub Issues", "Asana Tasks")
	Name() string

	// Source returns the source type for this provider
	Source() Source

	// FetchIssues retrieves open issues/tasks for the given repository.
	// The projectID parameter is provider-specific:
	//   - GitHub: ignored (uses gh CLI with repoPath as working directory)
	//   - Asana: the Asana project GID
	//   - Linear: the Linear team ID
	FetchIssues(ctx context.Context, repoPath, projectID string) ([]Issue, error)

	// IsConfigured returns true if this provider is configured and usable for the given repo.
	// For GitHub: always true (gh CLI is a prerequisite)
	// For Asana: true if ASANA_PAT env var is set AND repo has a mapped project
	// For Linear: true if LINEAR_API_KEY env var is set AND repo has a mapped team
	IsConfigured(repoPath string) bool

	// GenerateBranchName returns a branch name for the given issue.
	// For GitHub: "issue-{number}"
	// For Asana: "task-{slug}" where slug is derived from task name
	// For Linear: "linear-{identifier}" where identifier is lowercased (e.g., "linear-eng-123")
	GenerateBranchName(issue Issue) string

	// GetPRLinkText returns the text to add to PR body to link/close the issue.
	// For GitHub: "Fixes #123"
	// For Asana: "" (Asana doesn't support auto-close via commit message)
	// For Linear: "Fixes ENG-123" (Linear supports auto-close via identifier mentions)
	GetPRLinkText(issue Issue) string
}

Provider defines the interface for fetching issues from different sources.

type ProviderRegistry

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

ProviderRegistry holds all available issue providers.

func NewProviderRegistry

func NewProviderRegistry(providers ...Provider) *ProviderRegistry

NewProviderRegistry creates a new registry with the given providers.

func (*ProviderRegistry) AllProviders

func (r *ProviderRegistry) AllProviders() []Provider

AllProviders returns all registered providers.

func (*ProviderRegistry) GetConfiguredProviders

func (r *ProviderRegistry) GetConfiguredProviders(repoPath string) []Provider

GetConfiguredProviders returns all providers that are configured for the given repo.

func (*ProviderRegistry) GetProvider

func (r *ProviderRegistry) GetProvider(source Source) Provider

GetProvider returns the provider for the given source, or nil if not found.

type Source

type Source string

Source identifies the origin of an issue (GitHub, Asana, Linear, etc.)

const (
	SourceGitHub Source = "github"
	SourceAsana  Source = "asana"
	SourceLinear Source = "linear"
)

Jump to

Keyboard shortcuts

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