github

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

README

Search code, issues, and pull requests across configured GitHub repositories using a GitHub App for authentication.

Configuration

Environment Variable CLI Flag Required Description
WARREN_GITHUB_APP_ID --github-app-id Yes GitHub App ID
WARREN_GITHUB_APP_INSTALLATION_ID --github-app-installation-id Yes GitHub App Installation ID
WARREN_GITHUB_APP_PRIVATE_KEY --github-app-private-key Yes GitHub App private key (PEM format)
WARREN_GITHUB_APP_CONFIG --github-app-config No YAML config file path(s) for additional settings

Available Functions

Function Description
github_code_search Search for code across repositories. Supports filters: language, path, filename, repo_filter
github_issue_search Search issues and pull requests. Supports filters: state, labels, author, type, repo_filter
github_get_content Get file content from a specific repository by owner, repo, path, and ref

Setup

1. Create a GitHub App
  1. Go to Settings > Developer settings > GitHub Apps > New GitHub App
  2. Configure the app:
    • App name: A descriptive name (e.g., warren-code-search)
    • Homepage URL: Your organization URL
    • Webhook: Uncheck "Active" (not needed)
  3. Set permissions:
    • Repository permissions > Contents: Read-only
    • Repository permissions > Issues: Read-only
  4. Click Create GitHub App
  5. Note the App ID
2. Generate a Private Key
  1. In the app settings, scroll to Private keys
  2. Click Generate a private key
  3. Save the downloaded .pem file securely
3. Install the App
  1. Click Install App in the left sidebar
  2. Select your organization
  3. Choose repositories to grant access to
  4. Note the Installation ID from the URL after installation
4. Configure Warren
export WARREN_GITHUB_APP_ID="123456"
export WARREN_GITHUB_APP_INSTALLATION_ID="78901234"
export WARREN_GITHUB_APP_PRIVATE_KEY="$(cat /path/to/private-key.pem)"

The tool is automatically enabled when all required credentials are configured.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

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

func (*Action) Configure

func (x *Action) Configure(ctx context.Context) error

Configure implements interfaces.Tool

func (*Action) Flags

func (x *Action) Flags() []cli.Flag

func (*Action) GetConfigs

func (x *Action) GetConfigs() []*RepositoryConfig

func (*Action) Helper

func (x *Action) Helper() *cli.Command

func (*Action) LogValue

func (x *Action) LogValue() slog.Value

func (*Action) Name

func (x *Action) Name() string

func (*Action) Prompt

func (x *Action) Prompt(ctx context.Context) (string, error)

Prompt implements interfaces.Tool

func (*Action) Run

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

Run implements gollem.ToolSet

func (*Action) SetConfigs

func (x *Action) SetConfigs(configs []*RepositoryConfig)

func (*Action) SetGitHubClient

func (x *Action) SetGitHubClient(client *github.Client)

Helper methods for testing

func (*Action) SetTestData

func (x *Action) SetTestData(appID, installationID int64, privateKey string, configFiles []string)

func (*Action) Specs

func (x *Action) Specs(ctx context.Context) ([]gollem.ToolSpec, error)

Specs implements gollem.ToolSet

type CodeSearchResult

type CodeSearchResult struct {
	Repository   string    `json:"repository"`
	Path         string    `json:"path"`
	HTMLURL      string    `json:"html_url"`
	Matches      []string  `json:"matches"`
	Language     string    `json:"language,omitempty"`
	LastModified time.Time `json:"last_modified,omitempty"`
}

CodeSearchResult represents a code search result

type Config

type Config struct {
	Repositories []*RepositoryConfig `yaml:"repositories" json:"repositories"`
}

Config represents the GitHub tool configuration

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 result

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 an issue/PR search result

type RepositoryConfig

type RepositoryConfig struct {
	Owner         string `yaml:"owner" json:"owner"`
	Repository    string `yaml:"repository" json:"repository"`
	Description   string `yaml:"description" json:"description"`
	DefaultBranch string `yaml:"default_branch,omitempty" json:"default_branch,omitempty"`
}

RepositoryConfig represents a GitHub repository configuration

Jump to

Keyboard shortcuts

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