services

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package services provides implementations for various service integrations including GitHub, GitLab, OpenAI, and SCM operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CosineSimilarity added in v0.5.0

func CosineSimilarity(v1, v2 []float32) float64

CosineSimilarity calculates the cosine similarity between two vectors

func EstimateTokenCount added in v0.5.0

func EstimateTokenCount(text string) int

EstimateTokenCount roughly estimates token count (4 chars ~= 1 token)

func GenerateIssueDescription added in v0.2.0

func GenerateIssueDescription(ctx context.Context, client *openai.Client, diff string, currentTitle string) (string, string, error)

GenerateIssueDescription generates a description for an issue using OpenAI with RAG

func GenerateIssueDescriptionWithOptions added in v0.5.0

func GenerateIssueDescriptionWithOptions(ctx context.Context, client *openai.Client, diff string, currentTitle string, forceRAG *bool) (string, string, error)

GenerateIssueDescriptionWithOptions generates an issue description with optional RAG override

func GenerateMRDescription added in v0.2.0

func GenerateMRDescription(ctx context.Context, client *openai.Client, diff string) (string, error)

GenerateMRDescription generates a description for a merge request using OpenAI with RAG

func GenerateMRDescriptionWithOptions added in v0.5.0

func GenerateMRDescriptionWithOptions(ctx context.Context, client *openai.Client, diff string, forceRAG *bool) (string, error)

GenerateMRDescriptionWithOptions generates a description with optional RAG override

func NewOpenAIClient added in v0.2.0

func NewOpenAIClient() (*openai.Client, error)

NewOpenAIClient creates and validates the OpenAI client

func OpenURL added in v0.4.0

func OpenURL(url string) error

OpenURL opens a URL in the default browser (inline implementation to avoid import cycle)

Types

type Chunk added in v0.5.0

type Chunk struct {
	Content  string
	Index    int
	FilePath string
	Lines    int
}

Chunk represents a segment of a diff with metadata

func ChunkDiff added in v0.5.0

func ChunkDiff(diff string) []Chunk

ChunkDiff splits a diff into manageable chunks Each chunk is ~500-1000 lines or represents a complete file if smaller

type CreateMergeRequestOptions added in v0.2.0

type CreateMergeRequestOptions struct {
	IsDraft            bool
	IssueLabels        []string
	MilestoneID        int
	RemoveSourceBranch bool
	Squash             bool
	AutoMerge          bool
}

CreateMergeRequestOptions contains the optional parameters for creating a merge request

type CreateMergeRequestParams added in v0.3.0

type CreateMergeRequestParams struct {
	Provider           SCMProvider
	GitRepo            GitPusher
	CurrentBranch      string
	Remote             string
	TargetBranch       string
	IssueNumber        int
	IsDraft            bool
	RemoveSourceBranch bool
	Squash             bool
	AutoMerge          bool
	// IssueProvider is optional - if set, used to fetch issue details (for cross-repo scenarios)
	IssueProvider SCMProvider
	// CrossRepoIssueRef is optional - if set, used in MR description instead of simple "#123"
	CrossRepoIssueRef string
}

CreateMergeRequestParams is a convenience struct for CreateMergeRequest parameters

type EmbeddingVector added in v0.5.0

type EmbeddingVector struct {
	Chunk     *Chunk
	Embedding []float32
}

EmbeddingVector represents a chunk with its embedding vector

func GenerateEmbeddings added in v0.5.0

func GenerateEmbeddings(ctx context.Context, client *openai.Client, chunks []Chunk) ([]EmbeddingVector, error)

GenerateEmbeddings creates embeddings for all chunks using OpenAI's API

type GitHubIssueProvider added in v0.2.0

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

GitHubIssueProvider adapts GithubProject to the IssueProvider interface

func NewGitHubIssueProvider added in v0.2.0

func NewGitHubIssueProvider(repo string) (*GitHubIssueProvider, error)

NewGitHubIssueProvider creates a new GitHub issue provider

func (*GitHubIssueProvider) CreateIssue added in v0.2.0

func (p *GitHubIssueProvider) CreateIssue(title, labels string, selfAssign bool, milestone string) (*IssueCreationResult, error)

CreateIssue implements the IssueProvider interface for GitHub Note: GitHub doesn't use the milestone parameter

type GitHubMRDescriptionProvider added in v0.2.0

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

GitHubMRDescriptionProvider adapts GithubProject to the MRDescriptionProvider interface

func NewGitHubMRDescriptionProvider added in v0.2.0

func NewGitHubMRDescriptionProvider(repo string) (*GitHubMRDescriptionProvider, error)

NewGitHubMRDescriptionProvider creates a new GitHub MR description provider

func (*GitHubMRDescriptionProvider) GetIssueDetails added in v0.2.0

func (p *GitHubMRDescriptionProvider) GetIssueDetails(issueNumber int) (*IssueDetailsResult, error)

GetIssueDetails returns an issue by its number

func (*GitHubMRDescriptionProvider) GetOpenRequestsByBranch added in v0.6.5

func (p *GitHubMRDescriptionProvider) GetOpenRequestsByBranch(branchName string) ([]MRDescriptionResult, error)

GetOpenRequestsByBranch returns the open pull requests for a specific head branch

func (*GitHubMRDescriptionProvider) GetOpenRequestsForIssue added in v0.2.0

func (p *GitHubMRDescriptionProvider) GetOpenRequestsForIssue(issueNumber int) ([]MRDescriptionResult, error)

GetOpenRequestsForIssue returns the open pull requests for an issue

func (*GitHubMRDescriptionProvider) GetRequestDiff added in v0.2.0

func (p *GitHubMRDescriptionProvider) GetRequestDiff(requestID int) (string, error)

GetRequestDiff gets the diff for a pull request

func (*GitHubMRDescriptionProvider) UpdateIssueDescription added in v0.2.0

func (p *GitHubMRDescriptionProvider) UpdateIssueDescription(issueNumber int, description string) error

UpdateIssueDescription updates the description of an issue

func (*GitHubMRDescriptionProvider) UpdateIssueTitle added in v0.2.0

func (p *GitHubMRDescriptionProvider) UpdateIssueTitle(issueNumber int, title string) error

UpdateIssueTitle updates the title of an issue

func (*GitHubMRDescriptionProvider) UpdateRequestDescription added in v0.2.0

func (p *GitHubMRDescriptionProvider) UpdateRequestDescription(requestID int, description string) error

UpdateRequestDescription updates the description of a pull request

type GitHubProvider added in v0.2.0

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

GitHubProvider adapts GithubProject to the SCMProvider interface

func NewGitHubProvider added in v0.2.0

func NewGitHubProvider(repo string) (*GitHubProvider, error)

NewGitHubProvider creates a new GitHub provider

func (*GitHubProvider) AddLabelsToIssue added in v0.4.0

func (p *GitHubProvider) AddLabelsToIssue(issueNumber int, labels []string) error

AddLabelsToIssue implements the SCMProvider interface

func (*GitHubProvider) CreateIssue added in v0.3.0

func (p *GitHubProvider) CreateIssue(params IssueParams) (*IssueResult, error)

CreateIssue implements the SCMProvider interface

func (*GitHubProvider) CreateMergeRequest added in v0.2.0

func (p *GitHubProvider) CreateMergeRequest(params MergeRequestParams) (*RequestResult, error)

CreateMergeRequest implements the SCMProvider interface

func (*GitHubProvider) GetCrossRepoIssueRef added in v0.6.1

func (p *GitHubProvider) GetCrossRepoIssueRef(issueNumber int) string

GetCrossRepoIssueRef returns a cross-repo issue reference for GitHub

func (*GitHubProvider) GetIssue added in v0.2.0

func (p *GitHubProvider) GetIssue(issueNumber int) (*IssueResult, error)

GetIssue implements the SCMProvider interface

func (*GitHubProvider) GetOpenRequests added in v0.2.0

func (p *GitHubProvider) GetOpenRequests(issueNumber int) ([]RequestResult, error)

GetOpenRequests returns the open pull requests related to an issue

func (*GitHubProvider) GetOpenRequestsByBranch added in v0.6.5

func (p *GitHubProvider) GetOpenRequestsByBranch(branchName string) ([]RequestResult, error)

GetOpenRequestsByBranch returns the open pull requests for a specific head branch

func (*GitHubProvider) GetURL added in v0.2.0

func (p *GitHubProvider) GetURL() string

GetURL returns the GitHub URL for the repo

func (*GitHubProvider) RemoveLabelsFromIssue added in v0.4.0

func (p *GitHubProvider) RemoveLabelsFromIssue(issueNumber int, labels []string) error

RemoveLabelsFromIssue implements the SCMProvider interface

func (*GitHubProvider) UpdateIssueStatus added in v0.4.1

func (p *GitHubProvider) UpdateIssueStatus(issueNumber int, status string) error

UpdateIssueStatus implements the SCMProvider interface (no-op for GitHub)

type GitLabIssueProvider added in v0.2.0

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

GitLabIssueProvider adapts GitlabProject to the IssueProvider interface

func NewGitLabIssueProvider added in v0.2.0

func NewGitLabIssueProvider(repo string) (*GitLabIssueProvider, error)

NewGitLabIssueProvider creates a new GitLab issue provider

func (*GitLabIssueProvider) CreateIssue added in v0.2.0

func (p *GitLabIssueProvider) CreateIssue(title, labels string, selfAssign bool, milestone string) (*IssueCreationResult, error)

CreateIssue implements the IssueProvider interface for GitLab

type GitLabMRDescriptionProvider added in v0.2.0

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

GitLabMRDescriptionProvider adapts GitlabProject to the MRDescriptionProvider interface

func NewGitLabMRDescriptionProvider added in v0.2.0

func NewGitLabMRDescriptionProvider(repo string) (*GitLabMRDescriptionProvider, error)

NewGitLabMRDescriptionProvider creates a new GitLab MR description provider

func (*GitLabMRDescriptionProvider) GetIssueDetails added in v0.2.0

func (p *GitLabMRDescriptionProvider) GetIssueDetails(issueNumber int) (*IssueDetailsResult, error)

GetIssueDetails returns an issue by its number

func (*GitLabMRDescriptionProvider) GetOpenRequestsByBranch added in v0.6.5

func (p *GitLabMRDescriptionProvider) GetOpenRequestsByBranch(branchName string) ([]MRDescriptionResult, error)

GetOpenRequestsByBranch returns the open merge requests for a specific source branch

func (*GitLabMRDescriptionProvider) GetOpenRequestsForIssue added in v0.2.0

func (p *GitLabMRDescriptionProvider) GetOpenRequestsForIssue(issueNumber int) ([]MRDescriptionResult, error)

GetOpenRequestsForIssue returns the open merge requests for an issue

func (*GitLabMRDescriptionProvider) GetRequestDiff added in v0.2.0

func (p *GitLabMRDescriptionProvider) GetRequestDiff(requestID int) (string, error)

GetRequestDiff gets the diff for a merge request

func (*GitLabMRDescriptionProvider) UpdateIssueDescription added in v0.2.0

func (p *GitLabMRDescriptionProvider) UpdateIssueDescription(issueNumber int, description string) error

UpdateIssueDescription updates the description of an issue

func (*GitLabMRDescriptionProvider) UpdateIssueTitle added in v0.2.0

func (p *GitLabMRDescriptionProvider) UpdateIssueTitle(issueNumber int, title string) error

UpdateIssueTitle updates the title of an issue

func (*GitLabMRDescriptionProvider) UpdateRequestDescription added in v0.2.0

func (p *GitLabMRDescriptionProvider) UpdateRequestDescription(requestID int, description string) error

UpdateRequestDescription updates the description of a merge request

type GitLabProvider added in v0.2.0

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

GitLabProvider adapts GitlabProject to the SCMProvider interface

func NewGitLabProvider added in v0.2.0

func NewGitLabProvider(repo string) (*GitLabProvider, error)

NewGitLabProvider creates a new GitLab provider

func (*GitLabProvider) AddLabelsToIssue added in v0.4.0

func (p *GitLabProvider) AddLabelsToIssue(issueNumber int, labels []string) error

AddLabelsToIssue implements the SCMProvider interface

func (*GitLabProvider) CreateIssue added in v0.3.0

func (p *GitLabProvider) CreateIssue(params IssueParams) (*IssueResult, error)

CreateIssue implements the SCMProvider interface

func (*GitLabProvider) CreateMergeRequest added in v0.2.0

func (p *GitLabProvider) CreateMergeRequest(params MergeRequestParams) (*RequestResult, error)

CreateMergeRequest implements the SCMProvider interface

func (*GitLabProvider) GetCrossRepoIssueRef added in v0.6.1

func (p *GitLabProvider) GetCrossRepoIssueRef(issueNumber int) string

GetCrossRepoIssueRef returns a cross-repo issue reference for GitLab

func (*GitLabProvider) GetIssue added in v0.2.0

func (p *GitLabProvider) GetIssue(issueNumber int) (*IssueResult, error)

GetIssue implements the SCMProvider interface

func (*GitLabProvider) GetOpenRequests added in v0.2.0

func (p *GitLabProvider) GetOpenRequests(issueNumber int) ([]RequestResult, error)

GetOpenRequests returns the open merge requests related to an issue

func (*GitLabProvider) GetOpenRequestsByBranch added in v0.6.5

func (p *GitLabProvider) GetOpenRequestsByBranch(branchName string) ([]RequestResult, error)

GetOpenRequestsByBranch returns the open merge requests for a specific source branch

func (*GitLabProvider) GetURL added in v0.2.0

func (p *GitLabProvider) GetURL() string

GetURL returns the GitLab URL for the repo

func (*GitLabProvider) RemoveLabelsFromIssue added in v0.4.0

func (p *GitLabProvider) RemoveLabelsFromIssue(issueNumber int, labels []string) error

RemoveLabelsFromIssue implements the SCMProvider interface

func (*GitLabProvider) UpdateIssueStatus added in v0.4.1

func (p *GitLabProvider) UpdateIssueStatus(issueNumber int, status string) error

UpdateIssueStatus implements the SCMProvider interface

type GitPusher added in v0.9.1

type GitPusher interface {
	Push(remoteName string, branchName string) error
}

GitPusher is the subset of git repository behavior that CreateMergeRequest needs. *git.Repository satisfies it; tests can supply a fake.

type GithubIssue

type GithubIssue struct {
	Number         int
	Title          string
	Labels         []string
	HTMLURL        string
	MilestoneTitle string
}

GithubIssue represents a GitHub issue

type GithubProject

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

GithubProject represents a GitHub repository

func NewGithubProject

func NewGithubProject(repoName string) (*GithubProject, error)

NewGithubProject creates a new GitHub project client

func (*GithubProject) AddLabelsToIssue added in v0.4.0

func (p *GithubProject) AddLabelsToIssue(issueNumber int, labels []string) error

AddLabelsToIssue adds labels to an existing issue

func (*GithubProject) CreateIssue

func (p *GithubProject) CreateIssue(title, labels string, selfAssign bool, milestoneTitle ...string) (*GithubIssue, error)

CreateIssue creates a new issue in the repository

func (*GithubProject) CreatePullRequest

func (p *GithubProject) CreatePullRequest(title, sourceBranch, targetBranch string, issueNumber int, isDraft bool, autoMerge bool, issueLabels []string, descriptionOverride string) (*GithubPullRequest, error)

CreatePullRequest creates a new pull request in the repository

func (*GithubProject) EnableAutoMerge added in v0.8.0

func (p *GithubProject) EnableAutoMerge(prNodeID string) error

EnableAutoMerge enables auto-merge for a pull request via GitHub's GraphQL API

func (*GithubProject) GetIssue

func (p *GithubProject) GetIssue(issueNumber int) (*GithubIssue, error)

GetIssue returns an issue by its number

func (*GithubProject) GetOpenPullRequestsByBranch added in v0.6.5

func (p *GithubProject) GetOpenPullRequestsByBranch(branchName string) ([]*GithubPullRequest, error)

GetOpenPullRequestsByBranch returns all open pull requests for a specific head branch

func (*GithubProject) GetOpenPullRequestsForIssue

func (p *GithubProject) GetOpenPullRequestsForIssue(issueNumber int) ([]*GithubPullRequest, error)

GetOpenPullRequestsForIssue returns all open pull requests related to an issue

func (*GithubProject) GetPullRequestDiff added in v0.2.0

func (p *GithubProject) GetPullRequestDiff(prNumber int) (string, error)

GetPullRequestDiff returns the diff of a pull request

func (*GithubProject) RemoveLabelsFromIssue added in v0.4.0

func (p *GithubProject) RemoveLabelsFromIssue(issueNumber int, labels []string) error

RemoveLabelsFromIssue removes labels from an existing issue

func (*GithubProject) UpdateIssueDescription added in v0.2.0

func (p *GithubProject) UpdateIssueDescription(issueNumber int, description string) error

UpdateIssueDescription updates the description of an issue

func (*GithubProject) UpdateIssueTitle added in v0.2.0

func (p *GithubProject) UpdateIssueTitle(issueNumber int, title string) error

UpdateIssueTitle updates the title of an issue

func (*GithubProject) UpdatePullRequestDescription added in v0.2.0

func (p *GithubProject) UpdatePullRequestDescription(prNumber int, description string) error

UpdatePullRequestDescription updates the description of a pull request

type GithubPullRequest

type GithubPullRequest struct {
	Number  int
	Title   string
	HTMLURL string
	IsDraft bool
	NodeID  string
}

GithubPullRequest represents a GitHub pull request

type GitlabIssue

type GitlabIssue struct {
	IID            int
	Title          string
	Labels         []string
	MilestoneID    int
	MilestoneTitle string
	WebURL         string
}

GitlabIssue represents a GitLab issue

type GitlabMergeRequest

type GitlabMergeRequest struct {
	IID     int
	Title   string
	WebURL  string
	IsDraft bool
}

GitlabMergeRequest represents a GitLab merge request

type GitlabProject

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

GitlabProject represents a GitLab repository

func NewGitlabProject

func NewGitlabProject(repoName string) (*GitlabProject, error)

NewGitlabProject creates a new GitLab project client

func (*GitlabProject) AddLabelsToIssue added in v0.4.0

func (p *GitlabProject) AddLabelsToIssue(issueIID int, labels []string) error

AddLabelsToIssue adds labels to an existing issue

func (*GitlabProject) CreateIssue

func (p *GitlabProject) CreateIssue(title, labels string, selfAssign bool, milestoneTitle ...string) (*GitlabIssue, error)

CreateIssue creates a new issue in the repository

func (*GitlabProject) CreateMergeRequest

func (p *GitlabProject) CreateMergeRequest(title, sourceBranch, targetBranch string, issueIID int, options CreateMergeRequestOptions, descriptionOverride string) (*GitlabMergeRequest, error)

CreateMergeRequest creates a new merge request in the repository

func (*GitlabProject) EnableAutoMerge added in v0.8.0

func (p *GitlabProject) EnableAutoMerge(mrIID int) error

EnableAutoMerge sets the MR to merge automatically when its pipeline succeeds

func (*GitlabProject) GetIssue

func (p *GitlabProject) GetIssue(issueNumber int) (*GitlabIssue, error)

GetIssue returns an issue by its number

func (*GitlabProject) GetMergeRequestDiff added in v0.2.0

func (p *GitlabProject) GetMergeRequestDiff(mrIID int) (string, error)

GetMergeRequestDiff returns the diff of a merge request

func (*GitlabProject) GetMilestoneID

func (p *GitlabProject) GetMilestoneID(title string) (int, error)

GetMilestoneID returns the ID of a milestone by title

func (*GitlabProject) GetOpenMergeRequestsByBranch added in v0.6.5

func (p *GitlabProject) GetOpenMergeRequestsByBranch(branchName string) ([]*GitlabMergeRequest, error)

GetOpenMergeRequestsByBranch returns all open merge requests for a specific source branch

func (*GitlabProject) GetOpenMergeRequestsForIssue

func (p *GitlabProject) GetOpenMergeRequestsForIssue(issueID int) ([]*GitlabMergeRequest, error)

GetOpenMergeRequestsForIssue returns all open merge requests related to an issue

func (*GitlabProject) RemoveLabelsFromIssue added in v0.4.0

func (p *GitlabProject) RemoveLabelsFromIssue(issueIID int, labels []string) error

RemoveLabelsFromIssue removes labels from an existing issue

func (*GitlabProject) UpdateIssueDescription added in v0.2.0

func (p *GitlabProject) UpdateIssueDescription(issueIID int, description string) error

UpdateIssueDescription updates the description of an issue

func (*GitlabProject) UpdateIssueStatus added in v0.4.1

func (p *GitlabProject) UpdateIssueStatus(issueIID int, status string) error

UpdateIssueStatus updates the status of an issue using GraphQL

func (*GitlabProject) UpdateIssueTitle added in v0.2.0

func (p *GitlabProject) UpdateIssueTitle(issueIID int, title string) error

UpdateIssueTitle updates the title of an issue

func (*GitlabProject) UpdateMergeRequestDescription added in v0.2.0

func (p *GitlabProject) UpdateMergeRequestDescription(mrIID int, description string) error

UpdateMergeRequestDescription updates the description of a merge request

type GraphQLRequest added in v0.4.1

type GraphQLRequest struct {
	Query     string         `json:"query"`
	Variables map[string]any `json:"variables"`
}

GraphQL structures for issue status update

type GraphQLResponse added in v0.4.1

type GraphQLResponse struct {
	Data   any `json:"data"`
	Errors []struct {
		Message string `json:"message"`
	} `json:"errors"`
}

type IssueCreationResult added in v0.2.0

type IssueCreationResult struct {
	Number int    // Issue number (GitHub) or IID (GitLab)
	Title  string // Issue title
	URL    string // Issue URL
}

IssueCreationResult represents the result of creating an issue

type IssueDetailsResult added in v0.2.0

type IssueDetailsResult struct {
	Number int
	IID    int // For GitLab compatibility
	Title  string
	WebURL string
}

IssueDetailsResult represents issue details

type IssueParams added in v0.3.0

type IssueParams struct {
	Title          string
	Labels         string
	SelfAssign     bool
	MilestoneTitle string
}

IssueParams holds parameters for creating an issue

type IssueProvider added in v0.2.0

type IssueProvider interface {
	// CreateIssue creates a new issue and returns its details
	CreateIssue(title, labels string, selfAssign bool, milestone string) (*IssueCreationResult, error)
}

IssueProvider represents a provider for creating issues

type IssueResult added in v0.2.0

type IssueResult struct {
	Number         int
	Title          string
	Labels         []string
	MilestoneID    int
	MilestoneTitle string
}

IssueResult represents an issue from either system

type MRDescriptionProvider added in v0.2.0

type MRDescriptionProvider interface {
	// GetOpenRequestsForIssue returns the open merge/pull requests for an issue
	GetOpenRequestsForIssue(issueNumber int) ([]MRDescriptionResult, error)

	// GetOpenRequestsByBranch returns the open merge/pull requests for a specific source branch
	// This is useful in cross-repo scenarios where the issue doesn't exist in the code repo
	GetOpenRequestsByBranch(branchName string) ([]MRDescriptionResult, error)

	// GetRequestDiff gets the diff for a merge/pull request
	GetRequestDiff(requestID int) (string, error)

	// GetIssueDetails returns an issue by its number
	GetIssueDetails(issueNumber int) (*IssueDetailsResult, error)

	// UpdateRequestDescription updates the description of a merge/pull request
	UpdateRequestDescription(requestID int, description string) error

	// UpdateIssueDescription updates the description of an issue
	UpdateIssueDescription(issueNumber int, description string) error

	// UpdateIssueTitle updates the title of an issue
	UpdateIssueTitle(issueNumber int, title string) error
}

MRDescriptionProvider represents a provider for merge/pull request descriptions

type MRDescriptionResult added in v0.2.0

type MRDescriptionResult struct {
	ID     int
	IID    int // For GitLab compatibility
	Title  string
	WebURL string
}

MRDescriptionResult represents a merge/pull request result

type MRInfo added in v0.2.0

type MRInfo struct {
	OpenRequests []MRDescriptionResult
	SelectedID   int
	Diff         string
	WebURL       string
	IssueURL     string
}

MRInfo holds information about a merge/pull request

func GetMRInfo added in v0.2.0

func GetMRInfo(provider MRDescriptionProvider, issueNumber int) (*MRInfo, error)

GetMRInfo retrieves information about the merge/pull request

func GetMRInfoByBranch added in v0.6.5

func GetMRInfoByBranch(provider MRDescriptionProvider, branchName string, issueNumber int) (*MRInfo, error)

GetMRInfoByBranch gets information about merge/pull requests for a specific branch This is useful in cross-repo scenarios where the issue doesn't exist in the code repo

type MergeRequestParams added in v0.3.0

type MergeRequestParams struct {
	Title              string
	SourceBranch       string
	TargetBranch       string
	IssueNumber        int
	IsDraft            bool
	Labels             []string
	MilestoneID        int
	RemoveSourceBranch bool
	Squash             bool
	AutoMerge          bool
	Description        string // Optional description - if empty, will use default "Closes #X" format
}

MergeRequestParams holds parameters for creating a merge request

type RequestResult added in v0.2.0

type RequestResult struct {
	ID      int
	Title   string
	URL     string
	IsDraft bool
	Squash  bool
}

RequestResult represents a merge/pull request result

func CreateMergeRequest added in v0.2.0

func CreateMergeRequest(params CreateMergeRequestParams) (*RequestResult, error)

CreateMergeRequest contains the common flow for creating a merge/pull request

type SCMProvider added in v0.2.0

type SCMProvider interface {
	// CreateMergeRequest creates a merge/pull request and returns its details
	CreateMergeRequest(params MergeRequestParams) (*RequestResult, error)

	// CreateIssue creates a new issue in the repository
	CreateIssue(params IssueParams) (*IssueResult, error)

	// GetOpenRequests returns the open merge/pull requests for an issue
	GetOpenRequests(issueNumber int) ([]RequestResult, error)

	// GetOpenRequestsByBranch returns the open merge/pull requests for a specific source branch
	// This is useful in cross-repo scenarios where the issue doesn't exist in the code repo
	GetOpenRequestsByBranch(branchName string) ([]RequestResult, error)

	// GetIssue returns an issue by its number
	GetIssue(issueNumber int) (*IssueResult, error)

	// AddLabelsToIssue adds labels to an existing issue
	AddLabelsToIssue(issueNumber int, labels []string) error

	// RemoveLabelsFromIssue removes labels from an existing issue
	RemoveLabelsFromIssue(issueNumber int, labels []string) error

	// UpdateIssueStatus updates the status of an issue (GitLab only, no-op for GitHub)
	UpdateIssueStatus(issueNumber int, status string) error

	// GetURL returns the URL for the created request
	GetURL() string

	// GetCrossRepoIssueRef returns a cross-repo issue reference string
	// For GitHub: returns "owner/repo#123"
	// For GitLab: returns "group/project#123"
	GetCrossRepoIssueRef(issueNumber int) string
}

SCMProvider represents a source code management system (GitHub, GitLab, etc.)

type SearchResult added in v0.5.0

type SearchResult struct {
	Vector     *EmbeddingVector
	Similarity float64
}

SearchResult represents a search result with similarity score

type VectorStore added in v0.5.0

type VectorStore struct {
	Vectors []EmbeddingVector
}

VectorStore holds embeddings and provides similarity search

func NewVectorStore added in v0.5.0

func NewVectorStore(vectors []EmbeddingVector) *VectorStore

NewVectorStore creates a new vector store with the given embeddings

func (*VectorStore) Search added in v0.5.0

func (vs *VectorStore) Search(queryEmbedding []float32, topK int) []SearchResult

Search finds the top-K most similar chunks to the query embedding

type WorkflowStatus added in v0.9.0

type WorkflowStatus struct {
	Branch        string
	IssueNumber   int
	IssueTitle    string
	IssueLabels   []string
	Milestone     string
	MRURL         string
	MRNumber      int
	MRIsDraft     bool
	SuggestedNext string
	MRLookupErr   error
}

WorkflowStatus represents the current state of a ticket branch in the tix workflow.

func GetWorkflowStatus added in v0.9.0

func GetWorkflowStatus(codeProvider SCMProvider, issueProvider SCMProvider, branch string, issueNumber int, readyLabel string) (*WorkflowStatus, error)

GetWorkflowStatus resolves the current state of a ticket branch. codeProvider is used for MR lookup (the repo where the MR lives). issueProvider is used for issue lookup (may be the same as codeProvider). readyLabel is the configured label that marks an issue ready for review ("" means not configured). MR lookup failure is treated as a soft error — the function returns the issue info with MRLookupErr set.

Jump to

Keyboard shortcuts

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