Documentation
¶
Overview ¶
Package github provides utilities for working with GitHub URLs and the GitHub API.
Index ¶
- func IsBlobURL(url string) bool
- func IsGitHubURL(url string) bool
- func IsTreeURL(url string) bool
- func ResolveSkillDirectory(ctx context.Context, owner, repo, ref, skillName string) (string, error)
- type Fetcher
- func (f *Fetcher) FetchDirectory(ctx context.Context, treeURL *TreeURL) ([]byte, error)
- func (f *Fetcher) FetchFile(ctx context.Context, parsed *TreeURL) ([]byte, error)
- func (f *Fetcher) FetchGitTree(ctx context.Context, owner, repo, ref string) ([]GitTreeEntry, error)
- func (f *Fetcher) WithToken(token string) *Fetcher
- type GitTreeEntry
- type TreeURL
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsGitHubURL ¶
IsGitHubURL checks if a URL is any kind of GitHub URL we can handle.
func ResolveSkillDirectory ¶ added in v0.13.0
ResolveSkillDirectory resolves the actual directory name for a skill in a repo. The skills.sh skillId (from SKILL.md name field) may differ from the directory name. For example, skillId "vercel-react-best-practices" might live in directory "react-best-practices".
Types ¶
type Fetcher ¶
type Fetcher struct {
// contains filtered or unexported fields
}
Fetcher handles downloading files and directories from GitHub.
func (*Fetcher) FetchDirectory ¶
FetchDirectory downloads all files from a GitHub directory and returns them as a zip.
func (*Fetcher) FetchFile ¶ added in v0.14.5
FetchFile downloads a single file from a GitHub blob URL and returns its content.
func (*Fetcher) FetchGitTree ¶ added in v0.14.5
func (f *Fetcher) FetchGitTree(ctx context.Context, owner, repo, ref string) ([]GitTreeEntry, error)
FetchGitTree fetches the full repo tree in a single API call. Returns an error if GitHub indicates the tree was truncated (repos with >100k entries).
type GitTreeEntry ¶ added in v0.14.5
type GitTreeEntry struct {
Path string `json:"path"`
Type string `json:"type"` // "blob" or "tree"
}
GitTreeEntry represents an item from the GitHub Git Trees API.
type TreeURL ¶
type TreeURL struct {
Owner string // Repository owner (e.g., "metabase")
Repo string // Repository name (e.g., "metabase")
Ref string // Branch, tag, or commit (e.g., "master")
Path string // Path within the repository (e.g., ".claude/skills/docs-write")
}
TreeURL represents a parsed GitHub tree URL pointing to a directory. Example: https://github.com/metabase/metabase/tree/master/.claude/skills/docs-write
func ParseBlobURL ¶ added in v0.14.5
ParseBlobURL parses a GitHub blob URL into a TreeURL (reusing the same struct). Returns nil if the URL is not a valid GitHub blob URL.
func ParseTreeURL ¶
ParseTreeURL parses a GitHub tree URL into its components. Returns nil if the URL is not a valid GitHub tree URL.
func (*TreeURL) ContentsAPIURL ¶
ContentsAPIURL returns the GitHub API URL for listing directory contents. Example: https://api.github.com/repos/metabase/metabase/contents/.claude/skills/docs-write?ref=master
func (*TreeURL) RawURL ¶
RawURL returns the raw.githubusercontent.com URL for a file within this tree. Example: https://raw.githubusercontent.com/metabase/metabase/master/.claude/skills/docs-write/SKILL.md