Documentation
¶
Overview ¶
Package scm provides a single DataSource connector backed by go-scm for all SCM providers (GitHub, GitLab, Bitbucket). It lists pull requests and repo metadata (name, URL, description, language) for each repo in scope and returns them as NormalizedItems for vectorization. One adapter serves all providers.
Index ¶
- func AllTools(s Service) []tool.Tool
- func NewCreatePRCommentTool(s Service) tool.CallableTool
- func NewCreatePullRequestTool(s Service) tool.CallableTool
- func NewGetPullRequestTool(s Service) tool.CallableTool
- func NewListPRChangesTool(s Service) tool.CallableTool
- func NewListPRCommentsTool(s Service) tool.CallableTool
- func NewListPRCommitsTool(s Service) tool.CallableTool
- func NewListPullRequestsTool(s Service) tool.CallableTool
- func NewListReposTool(s Service) tool.CallableTool
- func NewMergePRTool(s Service) tool.CallableTool
- type ChangeSummary
- type CommentSummary
- type CommitSummary
- type Config
- type CreatePRCommentRequest
- type CreatePullRequestRequest
- type GetPullRequestRequest
- type ListPullRequestsRequest
- type ListReposResponse
- type PRNumberRequest
- type PullRequestSummary
- type SCMConnector
- type Service
- type ToolProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCreatePRCommentTool ¶
func NewCreatePRCommentTool(s Service) tool.CallableTool
func NewCreatePullRequestTool ¶
func NewCreatePullRequestTool(s Service) tool.CallableTool
func NewGetPullRequestTool ¶
func NewGetPullRequestTool(s Service) tool.CallableTool
func NewListPRChangesTool ¶
func NewListPRChangesTool(s Service) tool.CallableTool
func NewListPRCommentsTool ¶
func NewListPRCommentsTool(s Service) tool.CallableTool
func NewListPRCommitsTool ¶
func NewListPRCommitsTool(s Service) tool.CallableTool
func NewListPullRequestsTool ¶
func NewListPullRequestsTool(s Service) tool.CallableTool
func NewListReposTool ¶
func NewListReposTool(s Service) tool.CallableTool
func NewMergePRTool ¶
func NewMergePRTool(s Service) tool.CallableTool
Types ¶
type ChangeSummary ¶
type ChangeSummary struct {
Path string `json:"path"`
Added bool `json:"added,omitempty"`
Deleted bool `json:"deleted,omitempty"`
Renamed bool `json:"renamed,omitempty"`
}
ChangeSummary is a simplified file-change response.
type CommentSummary ¶
type CommentSummary struct {
ID int `json:"id"`
Body string `json:"body"`
Author string `json:"author"`
}
CommentSummary is a simplified comment response.
type CommitSummary ¶
type CommitSummary struct {
Sha string `json:"sha"`
Message string `json:"message"`
Author string `json:"author"`
}
CommitSummary is a simplified commit response.
type Config ¶
type Config struct {
Provider string `yaml:"Provider,omitempty" toml:"Provider,omitempty"` // github, gitlab, etc.
Token string `yaml:"Token,omitempty" toml:"Token,omitempty"`
BaseURL string `yaml:"BaseURL,omitempty" toml:"BaseURL,omitempty"` // for enterprise instances
}
Config holds configuration for SCM providers
type CreatePRCommentRequest ¶
type CreatePullRequestRequest ¶
type CreatePullRequestRequest struct {
Repo string `json:"repo" jsonschema:"description=Repository name (e.g. owner/name),required"`
Title string `json:"title" jsonschema:"description=PR Title,required"`
Body string `json:"body" jsonschema:"description=PR Description"`
Head string `json:"head" jsonschema:"description=Source branch,required"`
Base string `json:"base" jsonschema:"description=Target branch,required"`
}
type GetPullRequestRequest ¶
type ListPullRequestsRequest ¶
type ListReposResponse ¶
type ListReposResponse struct {
Repositories []string `json:"repositories"`
}
type PRNumberRequest ¶
type PullRequestSummary ¶
type PullRequestSummary struct {
Number int `json:"number"`
Title string `json:"title"`
State string `json:"state"`
Source string `json:"source"`
Target string `json:"target"`
Author string `json:"author"`
}
PullRequestSummary is a simplified PR response for listing.
type SCMConnector ¶
type SCMConnector struct {
// contains filtered or unexported fields
}
SCMConnector implements datasource.DataSource for any go-scm provider (GitHub, GitLab, Bitbucket). It is parameterized by sourceName so one implementation serves all; scope.ReposForSCM(sourceName) supplies the repo list per provider.
func NewGitHubConnector ¶
func NewGitHubConnector(svc Service) *SCMConnector
NewGitHubConnector returns a DataSource for GitHub using the shared go-scm adapter.
func NewSCMConnector ¶
func NewSCMConnector(svc Service, sourceName string) *SCMConnector
NewSCMConnector returns a DataSource that uses the go-scm Service to list repo metadata and pull requests. sourceName is the datasource identifier (e.g. "github", "gitlab"); scope.ReposForSCM(sourceName) defines which repos to include.
func (*SCMConnector) ListItems ¶
func (c *SCMConnector) ListItems(ctx context.Context, scope datasource.Scope) ([]datasource.NormalizedItem, error)
ListItems lists repo metadata and pull requests for each repo in scope for this SCM source. Uses scope.ReposForSCM(c.sourceName) so one connector works for all go-scm providers. Item IDs use sourceName (e.g. "github:repo:owner/repo").
func (*SCMConnector) Name ¶
func (c *SCMConnector) Name() string
Name returns the source identifier (e.g. "github", "gitlab").
type Service ¶
type Service interface {
ListRepos(ctx context.Context, opts go_scm.ListOptions) ([]*go_scm.Repository, error)
// FindRepo returns a single repository by name (e.g. owner/repo). Used for data ingestion to get description, link, language.
FindRepo(ctx context.Context, repo string) (*go_scm.Repository, error)
ListPullRequests(ctx context.Context, repo string, opts go_scm.PullRequestListOptions) ([]*go_scm.PullRequest, error)
GetPullRequest(ctx context.Context, repo string, id int) (*go_scm.PullRequest, error)
CreatePullRequest(ctx context.Context, repo string, input *go_scm.PullRequestInput) (*go_scm.PullRequest, error)
ListPullRequestChanges(ctx context.Context, repo string, number int, opts go_scm.ListOptions) ([]*go_scm.Change, error)
ListPullRequestComments(ctx context.Context, repo string, number int, opts go_scm.ListOptions) ([]*go_scm.Comment, error)
CreatePullRequestComment(ctx context.Context, repo string, number int, input *go_scm.CommentInput) (*go_scm.Comment, error)
ListPullRequestCommits(ctx context.Context, repo string, number int, opts go_scm.ListOptions) ([]*go_scm.Commit, error)
MergePullRequest(ctx context.Context, repo string, number int) error
// Validate performs a lightweight health check to verify that the
// provider's token is valid and the endpoint is reachable.
Validate(ctx context.Context) error
}
Service defines the capabilities of the SCM provider.
type ToolProvider ¶
type ToolProvider struct {
// contains filtered or unexported fields
}
ToolProvider wraps an SCM Service and satisfies the tools.ToolProviders interface so SCM tools can be passed directly to tools.NewRegistry. Without this, SCM tool construction would be inlined in the registry.
func NewToolProvider ¶
func NewToolProvider(svc Service) *ToolProvider
NewToolProvider creates a ToolProvider from an already-initialised SCM service. Callers are responsible for creating and validating the service beforehand.
func (*ToolProvider) GetTools ¶
func (p *ToolProvider) GetTools() []tool.Tool
GetTools returns all SCM tools wired to the underlying service.