Documentation
¶
Index ¶
- Variables
- type AuthenticatedUser
- type Client
- func (c *Client) AuthenticatedUser(ctx context.Context) (AuthenticatedUser, error)
- func (c *Client) CreateRepo(ctx context.Context, owner, name, description string, private bool) (*github.Repository, error)
- func (c *Client) DownloadReleaseAsset(ctx context.Context, owner, repo string, id int64) (io.ReadCloser, error)
- func (c *Client) FetchDirectory(ctx context.Context, owner, repo, dirPath, ref string) ([]SkillFile, error)
- func (c *Client) FetchFile(ctx context.Context, owner, repo, path, ref string) ([]byte, error)
- func (c *Client) FileExists(ctx context.Context, owner, repo, path, ref string) (bool, error)
- func (c *Client) GetTree(ctx context.Context, owner, repo, ref string) ([]TreeEntry, error)
- func (c *Client) HasPushAccess(ctx context.Context, owner, repo string) (bool, error)
- func (c *Client) IsAuthenticated() bool
- func (c *Client) LatestCommitSHA(ctx context.Context, owner, repo, branch string) (string, error)
- func (c *Client) LatestRelease(ctx context.Context, owner, repo string) (*github.RepositoryRelease, error)
- func (c *Client) PushFiles(ctx context.Context, owner, repo string, files map[string]string, ...) error
- func (c *Client) PushFilesAtomic(ctx context.Context, owner, repo, branch string, files map[string][]byte, ...) (CommitResult, error)
- func (c *Client) ReleaseAssetDigest(ctx context.Context, owner, repo string, id int64) (string, error)
- func (c *Client) RepositoryDefaultBranch(ctx context.Context, owner, repo string) (string, error)
- func (c *Client) RepositoryIsPrivate(ctx context.Context, owner, repo string) (bool, error)
- type CommitResult
- type SkillFile
- type TreeEntry
Constants ¶
This section is empty.
Variables ¶
var ErrRepoExists = errors.New("repository already exists")
ErrRepoExists is returned when CreateRepo encounters a 422 "name already exists" error.
Functions ¶
This section is empty.
Types ¶
type AuthenticatedUser ¶
AuthenticatedUser describes the token owner used for author checks.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the go-github client with Scribe-specific helpers.
func NewClient ¶
NewClient creates a GitHub client using the auth chain:
- gh auth token (piggyback on gh CLI if installed)
- GITHUB_TOKEN environment variable
- token argument (pass "" to skip — loaded from config by caller)
- unauthenticated (public repos only)
func (*Client) AuthenticatedUser ¶
func (c *Client) AuthenticatedUser(ctx context.Context) (AuthenticatedUser, error)
AuthenticatedUser returns the login and visible email addresses for the current token. Private email addresses may be unavailable depending on token scopes, so callers should also check local git config when enforcing author.
func (*Client) CreateRepo ¶
func (c *Client) CreateRepo(ctx context.Context, owner, name, description string, private bool) (*github.Repository, error)
CreateRepo creates a new GitHub repository under the given owner. If owner matches the authenticated user, it creates a personal repo. Returns ErrRepoExists if the repo name is already taken.
func (*Client) DownloadReleaseAsset ¶
func (c *Client) DownloadReleaseAsset(ctx context.Context, owner, repo string, id int64) (io.ReadCloser, error)
DownloadReleaseAsset downloads a release asset by ID, following redirects.
func (*Client) FetchDirectory ¶
func (c *Client) FetchDirectory(ctx context.Context, owner, repo, dirPath, ref string) ([]SkillFile, error)
FetchDirectory downloads all files under dirPath at the given ref. Uses the Git Trees API (recursive) to enumerate files, then fetches each one.
func (*Client) FileExists ¶
FileExists checks whether a file exists in a GitHub repo at the given ref.
func (*Client) GetTree ¶
GetTree returns a recursive tree listing for the given ref. Uses the GitHub Trees API with recursive=true for a single API call.
func (*Client) HasPushAccess ¶
HasPushAccess checks whether the authenticated user has push (write) access to the given repository. Returns false if unauthenticated or access denied.
func (*Client) IsAuthenticated ¶
IsAuthenticated returns true if the client has a GitHub token.
func (*Client) LatestCommitSHA ¶
LatestCommitSHA returns the current HEAD SHA for a branch. Used to detect updates for branch-pinned skills (e.g. @main).
func (*Client) LatestRelease ¶
func (c *Client) LatestRelease(ctx context.Context, owner, repo string) (*github.RepositoryRelease, error)
LatestRelease fetches the latest published release for a repository.
func (*Client) PushFiles ¶
func (c *Client) PushFiles(ctx context.Context, owner, repo string, files map[string]string, message string) error
PushFiles pushes files to a GitHub repo via the Git Trees API. Handles both empty repos (initial commit) and repos with existing content.
func (*Client) PushFilesAtomic ¶
func (c *Client) PushFilesAtomic(ctx context.Context, owner, repo, branch string, files map[string][]byte, message, expectedHead string) (CommitResult, error)
PushFilesAtomic creates a single commit containing all file updates and moves refs/heads/<branch> to it. If expectedHead is non-empty and the branch moved since the caller checked it, the push is refused.
func (*Client) ReleaseAssetDigest ¶
func (c *Client) ReleaseAssetDigest(ctx context.Context, owner, repo string, id int64) (string, error)
ReleaseAssetDigest returns GitHub's SHA-256 digest for a release asset.
func (*Client) RepositoryDefaultBranch ¶
RepositoryDefaultBranch returns a repository's default branch.
type CommitResult ¶
CommitResult describes a pushed GitHub commit.