Documentation
¶
Overview ¶
Package github provides GitHub API integration for maestro.
Index ¶
- func GetPullRequestChangesWithMCP(ctx context.Context, owner, repo string, prNumber int, ...) (*types.PRChanges, error)
- func Indent(s string, spaces int) string
- func ParseHunks(patch string, filePath string) ([]types.ChangeHunk, error)
- func ShouldSkipFile(filename string) bool
- func VerifyTokenPermissions(ctx context.Context, token, owner, repo string) error
- type CodeContext
- type DiffPosition
- type FileDiffInfo
- type Interface
- type MCPBashHelper
- func (h *MCPBashHelper) Close() error
- func (h *MCPBashHelper) ExecuteCommand(ctx context.Context, command string) (string, error)
- func (h *MCPBashHelper) ExecuteGHCommand(ctx context.Context, args ...string) (string, error)
- func (h *MCPBashHelper) ExecuteSgrepCommand(ctx context.Context, args ...string) (string, error)
- func (h *MCPBashHelper) SgrepIndex(ctx context.Context, path string) (string, error)
- func (h *MCPBashHelper) SgrepSearch(ctx context.Context, query string, limit int) (string, error)
- type PreviewOptions
- type Tools
- func (g *Tools) Client() *github.Client
- func (g *Tools) CompareCommits(ctx context.Context, owner, repo, base, head string, opts *github.ListOptions) (*github.CommitsComparison, *github.Response, error)
- func (g *Tools) CreatePullRequestReviewComment(ctx context.Context, owner, repo string, prNumber int, ...) (*github.PullRequestReview, *github.Response, error)
- func (g *Tools) CreateReviewComments(ctx context.Context, prNumber int, comments []types.PRReviewComment) error
- func (g *Tools) FilterReviewComments(ctx context.Context, prNumber int, comments []types.PRReviewComment) ([]types.PRReviewComment, error)
- func (g *Tools) GetAuthenticatedUser(ctx context.Context) string
- func (g *Tools) GetFileContent(ctx context.Context, filePath string) (string, error)
- func (g *Tools) GetLatestCommitSHA(ctx context.Context, branch string) (string, error)
- func (g *Tools) GetPullRequest(ctx context.Context, owner, repo string, prNumber int) (*github.PullRequest, *github.Response, error)
- func (g *Tools) GetPullRequestChanges(ctx context.Context, prNumber int) (*types.PRChanges, error)
- func (g *Tools) GetRepository(ctx context.Context, owner, repo string) (*github.Repository, *github.Response, error)
- func (g *Tools) GetRepositoryContents(ctx context.Context, owner, repo, path string, ...) (*github.RepositoryContent, []*github.RepositoryContent, *github.Response, ...)
- func (g *Tools) GetRepositoryInfo(ctx context.Context) types.RepositoryInfo
- func (g *Tools) ListLanguages(ctx context.Context, owner, repo string) (map[string]int, *github.Response, error)
- func (g *Tools) ListPullRequestComments(ctx context.Context, owner, repo string, prNumber int, ...) ([]*github.PullRequestComment, *github.Response, error)
- func (g *Tools) ListPullRequestReviews(ctx context.Context, owner, repo string, prNumber int, ...) ([]*github.PullRequestReview, *github.Response, error)
- func (g *Tools) MonitorPRComments(ctx context.Context, prNumber int, ...) error
- func (g *Tools) PreviewReview(ctx context.Context, console types.ConsoleInterface, prNumber int, ...) ([]types.PRReviewComment, bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPullRequestChangesWithMCP ¶
func GetPullRequestChangesWithMCP(ctx context.Context, owner, repo string, prNumber int, bashHelper *MCPBashHelper, localRepoPath string) (*types.PRChanges, error)
GetPullRequestChangesWithMCP retrieves PR changes using MCP bash helper instead of GitHub API. It explicitly scopes gh commands to the provided owner/repo to avoid cwd-dependent behavior. localRepoPath is the path to the cloned repo on disk for reading file contents.
func ParseHunks ¶
func ParseHunks(patch string, filePath string) ([]types.ChangeHunk, error)
ParseHunks parses diff hunks from a patch.
func ShouldSkipFile ¶
ShouldSkipFile determines if a file should be skipped for review.
Types ¶
type CodeContext ¶
CodeContext represents lines of code around a specific line.
func ExtractContext ¶
func ExtractContext(content string, line int, contextLines int) (*CodeContext, error)
ExtractContext gets lines of code around a specific line number.
type DiffPosition ¶
type DiffPosition struct {
Path string // File path
Line int // Line number in the new file
Position int // Position in the diff (required by GitHub API)
}
DiffPosition represents a position in a diff.
type FileDiffInfo ¶
type FileDiffInfo struct {
// contains filtered or unexported fields
}
FileDiffInfo holds diff information for a single file.
type Interface ¶
type Interface interface {
GetPullRequestChanges(ctx context.Context, prNumber int) (*types.PRChanges, error)
GetFileContent(ctx context.Context, path string) (string, error)
FilterReviewComments(ctx context.Context, prNumber int, comments []types.PRReviewComment) ([]types.PRReviewComment, error)
CreateReviewComments(ctx context.Context, prNumber int, comments []types.PRReviewComment) error
GetLatestCommitSHA(ctx context.Context, branch string) (string, error)
MonitorPRComments(ctx context.Context, prNumber int, callback func(comment *github.PullRequestComment)) error
PreviewReview(ctx context.Context, console types.ConsoleInterface, prNumber int, comments []types.PRReviewComment, metric types.MetricsCollector) ([]types.PRReviewComment, bool, error)
GetAuthenticatedUser(ctx context.Context) string
GetRepositoryInfo(ctx context.Context) types.RepositoryInfo
ListPullRequestComments(ctx context.Context, owner, repo string, prNumber int, opts *github.PullRequestListCommentsOptions) ([]*github.PullRequestComment, *github.Response, error)
ListPullRequestReviews(ctx context.Context, owner, repo string, prNumber int, opts *github.ListOptions) ([]*github.PullRequestReview, *github.Response, error)
CreatePullRequestReviewComment(ctx context.Context, owner, repo string, prNumber int, comment *github.PullRequestReviewRequest) (*github.PullRequestReview, *github.Response, error)
GetPullRequest(ctx context.Context, owner, repo string, prNumber int) (*github.PullRequest, *github.Response, error)
GetRepository(ctx context.Context, owner, repo string) (*github.Repository, *github.Response, error)
GetRepositoryContents(ctx context.Context, owner, repo, path string, opts *github.RepositoryContentGetOptions) (*github.RepositoryContent, []*github.RepositoryContent, *github.Response, error)
CompareCommits(ctx context.Context, owner, repo, base, head string, opts *github.ListOptions) (*github.CommitsComparison, *github.Response, error)
ListLanguages(ctx context.Context, owner, repo string) (map[string]int, *github.Response, error)
Client() *github.Client
}
Interface defines the interface for GitHub operations.
type MCPBashHelper ¶
type MCPBashHelper struct {
// contains filtered or unexported fields
}
MCPBashHelper provides a simple interface to execute bash commands via MCP.
func NewMCPBashHelper ¶
func NewMCPBashHelper() (*MCPBashHelper, error)
NewMCPBashHelper creates a new MCP bash helper.
func (*MCPBashHelper) Close ¶
func (h *MCPBashHelper) Close() error
Close closes the MCP connection and terminates the server.
func (*MCPBashHelper) ExecuteCommand ¶
ExecuteCommand executes a bash command and returns the output.
func (*MCPBashHelper) ExecuteGHCommand ¶
ExecuteGHCommand executes a gh CLI command.
func (*MCPBashHelper) ExecuteSgrepCommand ¶
ExecuteSgrepCommand executes an sgrep CLI command for semantic code search. sgrep provides fast local semantic search using embeddings and tree-sitter chunking.
func (*MCPBashHelper) SgrepIndex ¶
SgrepIndex indexes a directory for semantic search.
func (*MCPBashHelper) SgrepSearch ¶
SgrepSearch performs semantic code search using sgrep. Returns JSON results with file paths, line numbers, content, and relevance scores.
type PreviewOptions ¶
type PreviewOptions struct {
ShowColors bool // Use ANSI colors for formatting
ContextLines int // Number of context lines around changes
FilePathStyle string // How to display file paths (full, relative, basename)
ShowLineNumbers bool // Whether to show line numbers
}
PreviewOptions configures how review previews are displayed.
type Tools ¶
type Tools struct {
// contains filtered or unexported fields
}
Tools handles interactions with GitHub API.
func (*Tools) CompareCommits ¶
func (*Tools) CreatePullRequestReviewComment ¶
func (g *Tools) CreatePullRequestReviewComment(ctx context.Context, owner, repo string, prNumber int, comment *github.PullRequestReviewRequest) (*github.PullRequestReview, *github.Response, error)
CreatePullRequestReviewComment creates a review comment on a pull request.
func (*Tools) CreateReviewComments ¶
func (g *Tools) CreateReviewComments(ctx context.Context, prNumber int, comments []types.PRReviewComment) error
CreateReviewComments posts review comments back to GitHub.
func (*Tools) FilterReviewComments ¶
func (g *Tools) FilterReviewComments(ctx context.Context, prNumber int, comments []types.PRReviewComment) ([]types.PRReviewComment, error)
func (*Tools) GetAuthenticatedUser ¶
func (*Tools) GetFileContent ¶
GetFileContent retrieves the content of a specific file from the repository. This uses the GitHub API's GetContents endpoint to fetch file content.
func (*Tools) GetLatestCommitSHA ¶
func (*Tools) GetPullRequest ¶
func (*Tools) GetPullRequestChanges ¶
GetPullRequestChanges retrieves the changes from a pull request.
func (*Tools) GetRepository ¶
func (*Tools) GetRepositoryContents ¶
func (g *Tools) GetRepositoryContents(ctx context.Context, owner, repo, path string, opts *github.RepositoryContentGetOptions) (*github.RepositoryContent, []*github.RepositoryContent, *github.Response, error)
func (*Tools) GetRepositoryInfo ¶
func (g *Tools) GetRepositoryInfo(ctx context.Context) types.RepositoryInfo
func (*Tools) ListLanguages ¶
func (*Tools) ListPullRequestComments ¶
func (*Tools) ListPullRequestReviews ¶
func (g *Tools) ListPullRequestReviews(ctx context.Context, owner, repo string, prNumber int, opts *github.ListOptions) ([]*github.PullRequestReview, *github.Response, error)
ListPullRequestReviews retrieves all reviews for a pull request.
func (*Tools) MonitorPRComments ¶
func (*Tools) PreviewReview ¶
func (g *Tools) PreviewReview(ctx context.Context, console types.ConsoleInterface, prNumber int, comments []types.PRReviewComment, metric types.MetricsCollector) ([]types.PRReviewComment, bool, error)