ghissue

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package ghissue is a minimal GitHub Issues client: obtaining a bearer token and filing one issue. It knows nothing about muster sessions, the daemon store, or Claude Code (plan issue-capture D5) — CreateIssue takes two strings (title, body) and posts them; the caller (internal/server) owns everything about what goes into those strings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunCommand

func RunCommand(ctx context.Context, name string, args ...string) (stdout, stderr string, err error)

RunCommand is the production execFunc: runs name with args, capturing stdout and stderr separately. Neither is ever logged by any caller (REQ-11).

Types

type Client

type Client struct {
	HTTPClient  *http.Client
	BaseURL     string
	TokenReader TokenReader
}

Client is a minimal GitHub Issues client. TokenReader is re-read on every CreateIssue call — REQ-8's "never stored, re-read on every use".

func (*Client) CreateIssue

func (c *Client) CreateIssue(ctx context.Context, repo, title, body string) (number int, htmlURL string, err error)

CreateIssue obtains a fresh bearer token via c.TokenReader, then POSTs {c.BaseURL}/repos/{repo}/issues with title/body (docs/protocol.md §3.13's measured headers), returning the created issue's number and html_url. The token travels only in the Authorization header — never logged, never echoed into a returned error (INV-3); this holds whether the failure happened obtaining the token (*ErrAuthFailed, returned unwrapped) or posting to GitHub (*ErrPostFailed).

type ErrAuthFailed

type ErrAuthFailed struct {
	Message string
}

ErrAuthFailed is returned by a TokenReader (and by CreateIssue, which returns it unwrapped when the failure happened at the token step) when a bearer token could not be obtained: gh missing, gh auth token exiting non-zero, or an empty token. Message never carries gh's stdout — that's where the token lives (REQ-11/INV-3).

func (*ErrAuthFailed) Error

func (e *ErrAuthFailed) Error() string

type ErrPostFailed

type ErrPostFailed struct {
	Message      string
	MaybeCreated bool
}

ErrPostFailed is returned by CreateIssue when the request to GitHub itself failed: non-2xx, a transport error, or a 2xx body that would not parse. MaybeCreated is true whenever the request reached GitHub and may have created the issue — an unreadable or unusable 2xx body (plan Edge Case 9).

func (*ErrPostFailed) Error

func (e *ErrPostFailed) Error() string

type TokenReader

type TokenReader func(ctx context.Context) (string, error)

TokenReader returns a GitHub bearer token. It is re-read on every call — mirrors internal/claudecode.TokenReader (credentials.go); callers must never cache a value.

func FileTokenReader

func FileTokenReader(path string) TokenReader

FileTokenReader reads the trimmed contents of path as the token — the -issue-token-file test seam (REQ-14), plain text (deliberately not the JSON shape of claudecode.FileTokenReader) that makes it structurally impossible for a test using it to fall through to a real `gh` invocation.

func GhCLITokenReader

func GhCLITokenReader(lookPath func(string) (string, error), run execFunc) TokenReader

GhCLITokenReader runs `gh auth token`, returning its trimmed stdout as the bearer token. lookPath and run are the test seams (production: exec.LookPath, RunCommand) — no test may execute the real `gh` binary. A missing gh, a non-zero exit, or an empty token all report *ErrAuthFailed carrying gh's trimmed stderr and naming `gh auth login`; gh's stdout is never included in an error.

Jump to

Keyboard shortcuts

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