github

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

README

github

GitHub App tools — code search, issue search, file content, commit history, blame, and single issue/PR retrieval — for the gollem LLM agent framework.

github.com/gollem-dev/tools/github

Tools

Name Description
github_code_search Search code across GitHub repositories.
github_issue_search Search issues and pull requests.
github_get_content Get file content from a repository.
github_list_commits List commits for a repository.
github_get_blame Get git blame information for a file.
github_get_issue Fetch a single issue with body, labels, and all comments.
github_get_pull_request Fetch a single PR with body, labels, comments, reviews, and optionally the file diff.

Usage

ts, err := github.New(123456, 7890123, pemString)
if err != nil {
	return err
}
if err := ts.Ping(ctx); err != nil { // optional preflight
	return err
}

Authentication is via a GitHub App installation: the tool mints installation access tokens from the App ID, installation ID, and the App's PEM private key.

Options

Option Required Default
WithLogger(*slog.Logger) no slog.Default()

Testing

Mock tests run unconditionally. The live-service test runs only when the TEST_GITHUB_* variables are set:

TEST_GITHUB_APP_ID=... TEST_GITHUB_APP_INSTALLATION_ID=... \
	TEST_GITHUB_APP_PRIVATE_KEY="$(cat key.pem)" \
	TEST_GITHUB_REPO=owner/repo go test ./...

The github_get_issue and github_get_pull_request live subtests additionally require TEST_GITHUB_ISSUE_NUMBER and TEST_GITHUB_PR_NUMBER respectively; each subtest skips when its variable is unset.

Documentation

Overview

Package github provides a gollem.ToolSet for GitHub code/issue search, file content retrieval, commit history listing, and git blame.

Package github provides a gollem.ToolSet for GitHub code/issue search, file content retrieval, commit history listing, and git blame.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlameRange

type BlameRange struct {
	StartLine     int       `json:"start_line"`
	EndLine       int       `json:"end_line"`
	CommitSHA     string    `json:"commit_sha"`
	CommitMessage string    `json:"commit_message"`
	Author        string    `json:"author"`
	Date          time.Time `json:"date"`
}

BlameRange represents a contiguous set of lines attributed to a single commit.

type CodeSearchResult

type CodeSearchResult struct {
	Repository string   `json:"repository"`
	Path       string   `json:"path"`
	HTMLURL    string   `json:"html_url"`
	Matches    []string `json:"matches"`
}

CodeSearchResult represents a single code search result.

type CommitResult

type CommitResult struct {
	SHA     string    `json:"sha"`
	Message string    `json:"message"`
	Author  string    `json:"author"`
	Date    time.Time `json:"date"`
	HTMLURL string    `json:"html_url"`
}

CommitResult represents a single commit in the list-commits response.

type ContentResult

type ContentResult struct {
	Repository string `json:"repository"`
	Path       string `json:"path"`
	Content    string `json:"content"`
	SHA        string `json:"sha"`
	HTMLURL    string `json:"html_url"`
	Size       int    `json:"size"`
}

ContentResult represents file content retrieved from a repository.

type IssueComment added in v0.2.0

type IssueComment struct {
	Author    string    `json:"author"`
	Body      string    `json:"body"`
	CreatedAt time.Time `json:"created_at"`
	URL       string    `json:"url"`
}

IssueComment represents a single comment on an issue or pull request.

type IssueDetailResult added in v0.2.0

type IssueDetailResult struct {
	Number    int            `json:"number"`
	Title     string         `json:"title"`
	Body      string         `json:"body"`
	Author    string         `json:"author"`
	State     string         `json:"state"`
	URL       string         `json:"url"`
	Labels    []string       `json:"labels"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	ClosedAt  *time.Time     `json:"closed_at,omitempty"`
	Comments  []IssueComment `json:"comments"`
}

IssueDetailResult represents a single issue fetched with full body and comments.

type IssueSearchResult

type IssueSearchResult struct {
	Repository string    `json:"repository"`
	Number     int       `json:"number"`
	Title      string    `json:"title"`
	State      string    `json:"state"`
	HTMLURL    string    `json:"html_url"`
	User       string    `json:"user"`
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
	IsPR       bool      `json:"is_pr"`
	Body       string    `json:"body,omitempty"`
	Labels     []string  `json:"labels,omitempty"`
}

IssueSearchResult represents a single issue or pull-request search result.

type Option

type Option func(*ToolSet)

Option configures a ToolSet.

func WithLogger

func WithLogger(logger *slog.Logger) Option

WithLogger sets the logger. A nil logger keeps the default (slog.Default()).

type PullRequestDetailResult added in v0.2.0

type PullRequestDetailResult struct {
	Number    int                 `json:"number"`
	Title     string              `json:"title"`
	Body      string              `json:"body"`
	Author    string              `json:"author"`
	State     string              `json:"state"`
	URL       string              `json:"url"`
	Labels    []string            `json:"labels"`
	Merged    bool                `json:"merged"`
	Draft     bool                `json:"draft"`
	BaseRef   string              `json:"base_ref"`
	HeadRef   string              `json:"head_ref"`
	CreatedAt time.Time           `json:"created_at"`
	UpdatedAt time.Time           `json:"updated_at"`
	ClosedAt  *time.Time          `json:"closed_at,omitempty"`
	Comments  []IssueComment      `json:"comments"`
	Reviews   []PullRequestReview `json:"reviews"`
	Files     []PullRequestFile   `json:"files,omitempty"`
}

PullRequestDetailResult represents a single pull request fetched with body, comments, reviews, and optionally the file diff.

type PullRequestFile added in v0.2.0

type PullRequestFile struct {
	Path           string `json:"path"`
	Status         string `json:"status"`
	Additions      int    `json:"additions"`
	Deletions      int    `json:"deletions"`
	Patch          string `json:"patch"`
	PatchTruncated bool   `json:"patch_truncated"`
}

PullRequestFile represents a single changed file in a pull request.

type PullRequestReview added in v0.2.0

type PullRequestReview struct {
	Author    string    `json:"author"`
	Body      string    `json:"body"`
	State     string    `json:"state"`
	CreatedAt time.Time `json:"created_at"`
}

PullRequestReview represents a single review on a pull request.

type ToolSet

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

ToolSet implements gollem.ToolSet for GitHub. Fields are unexported; configure via Option.

func New

func New(appID int64, installationID int64, privateKey string, opts ...Option) (*ToolSet, error)

New constructs the ToolSet with the three required credentials as positional arguments. appID and installationID must be non-zero; privateKey must be a non-empty PEM string. Optional settings (e.g. WithLogger) are passed as opts. New performs only in-memory validation and transport construction; use Ping to verify connectivity.

func (*ToolSet) Ping

func (t *ToolSet) Ping(ctx context.Context) error

Ping verifies connectivity and credentials by fetching a short-lived installation token from the GitHub API.

func (*ToolSet) Run

func (t *ToolSet) Run(ctx context.Context, name string, args map[string]any) (map[string]any, error)

Run executes the named GitHub tool.

func (*ToolSet) Specs

func (t *ToolSet) Specs(_ context.Context) ([]gollem.ToolSpec, error)

Specs returns the tool specifications for the five GitHub tools.

Jump to

Keyboard shortcuts

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