github

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package github interacts with the GitHub API to search and fetch repositories.

Index

Constants

View Source
const (
	// SkillTopic is the default topic to search for agent skills
	SkillTopic = "agent-skill"
	// APIURL is the GitHub API endpoint for searching repositories
	APIURL = "https://api.github.com/search/repositories"
)

Variables

This section is empty.

Functions

func GetAPIBaseURL added in v1.7.6

func GetAPIBaseURL(repo config.Repo) string

GetAPIBaseURL returns the API base URL for a repo. Defaults to "https://api.github.com" if not specified.

func GetTokenForRepo added in v1.7.6

func GetTokenForRepo(repo config.Repo) string

GetTokenForRepo returns the best available token for a given repo config. Priority: per-repo token → environment variable → empty string.

func ParseBrowserURL added in v1.3.3

func ParseBrowserURL(url string) (repoURL, branch, subDir, skillName string, ok bool)

ParseBrowserURL parses a GitHub browser URL and extracts components Input: https://github.com/owner/repo/tree/branch/path/to/skill Returns: repoURL, branch, subDir, skillName, ok

func ParseRepoURL added in v1.4.0

func ParseRepoURL(url string) (owner, repo string, err error)

ParseRepoURL parses a GitHub repository URL to extract owner and repo name Supports formats: - owner/repo - https://github.com/owner/repo - https://github.com/owner/repo.git - git@github.com:owner/repo.git

Types

type Client added in v1.7.8

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

Client provides GitHub API access

func NewClient added in v1.7.8

func NewClient() *Client

NewClient creates a new GitHub API client

func (*Client) GetRepoInfo added in v1.7.8

func (c *Client) GetRepoInfo(owner, repo string) (*RepoInfo, error)

GetRepoInfo fetches enriched repository metadata for trust scoring

type Content

type Content struct {
	Name    string `json:"name"`
	Type    string `json:"type"`
	HTMLURL string `json:"html_url"`
}

Content represents a file or directory in a GitHub repository

type RepoInfo added in v1.7.8

type RepoInfo struct {
	Stars      int
	Forks      int
	IsOrg      bool
	HasLicense bool
	OwnerAge   int // years since account creation
}

RepoInfo holds enriched repository metadata for scoring

type Repository

type Repository struct {
	Name            string    `json:"name"`
	FullName        string    `json:"full_name"`
	Description     string    `json:"description"`
	HTMLURL         string    `json:"html_url"`
	StargazersCount int       `json:"stargazers_count"`
	CloneURL        string    `json:"clone_url"`
	UpdatedAt       time.Time `json:"updated_at"`
	Source          string    `json:"-"` // Source name (e.g., "community", "anthropics")
	Owner           struct {
		Login string `json:"login"`
	} `json:"owner"`
}

Repository represents a GitHub repository structure

func FetchRepoDetails added in v0.7.2

func FetchRepoDetails(owner, repo string) (*Repository, error)

FetchRepoDetails fetches details of a GitHub repository including star count

func SearchDir

func SearchDir(owner, repo, path string) ([]Repository, error)

SearchDir searches a specific directory in a GitHub repository for subdirectories (skills)

func SearchTopic

func SearchTopic(topic, keyword string) ([]Repository, error)

SearchTopic searches GitHub for repositories with a specific topic and keyword

type SearchResult

type SearchResult struct {
	TotalCount int          `json:"total_count"`
	Items      []Repository `json:"items"`
}

SearchResult represents the response from GitHub search API

Jump to

Keyboard shortcuts

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