Documentation
¶
Overview ¶
Package feedback turns an agent's report of an SDK problem into a GitHub issue on the SDK's own repository. It is the feedback channel shared by the two agent-facing surfaces — the brainapi CLI (`brainapi feedback`) and the brainapi-mcp server (the `report_issue` tool) — so that when an agent driving the SDK hits a real defect (a wrong response shape, a mis-classified error, a stale doc, a tool that errors unexpectedly) the finding is recorded upstream instead of being lost in the chat.
Two modes, picked automatically:
- github_api: when a token is configured (BRAINAPI_FEEDBACK_TOKEN, else GITHUB_TOKEN, else GH_TOKEN) AND the caller confirms, the issue is filed via POST /repos/{owner}/{repo}/issues and the new issue URL is returned.
- draft_url: otherwise, a prefilled `…/issues/new?title=…&body=…` URL is returned for a human to click. No token, no network — the safe default.
Filing opens an issue on a public tracker, so it is outward-facing and never happens implicitly: both surfaces require confirm=true (CLI: --confirm) to leave draft mode. If the GitHub call itself fails, File degrades to a draft URL rather than dropping the report — the channel always yields *some* way to land the feedback.
Index ¶
Constants ¶
const DefaultRepo = "wh0amibjm/brainapi-go-sdk"
DefaultRepo is the upstream SDK repository feedback lands on. Override with BRAINAPI_FEEDBACK_REPO (owner/repo form) when working from a fork.
Variables ¶
This section is empty.
Functions ¶
func DraftURL ¶
DraftURL builds a GitHub "new issue" URL with the title/body/labels prefilled — a click-to-file fallback that needs no token or network. The body is capped at maxDraftBodyChars so a long report can't produce a URL past GitHub's request-URI limit (the API-post path carries the full body).
Types ¶
type Config ¶
type Config struct {
Repo string // owner/repo
Token string // GitHub token; empty => draft-only
APIBase string // defaults to https://api.github.com
HTTP *http.Client // defaults to a 15s-timeout client
}
Config resolves where feedback goes and how to authenticate. APIBase and HTTP are injection points for tests; both default sensibly.
func ConfigFromEnv ¶
func ConfigFromEnv() Config
ConfigFromEnv reads the repo + token from the environment. Token precedence: BRAINAPI_FEEDBACK_TOKEN, then GITHUB_TOKEN, then GH_TOKEN.
type Env ¶
Env is the build/runtime context auto-appended to every issue body so the maintainer sees exactly which binary hit the bug. Built with RuntimeEnv.
func RuntimeEnv ¶
RuntimeEnv fills an Env from the caller-supplied build identity plus the current runtime. Version/commit come from the caller (internal/version) so this package stays free of any internal dependency.
type Issue ¶
Issue is the rendered GitHub issue — a pure function of (Report, Env).
func BuildIssue ¶
BuildIssue renders the issue from the report and env. Pure and deterministic.
type Report ¶
type Report struct {
Title string
Body string
Category string // bug | docs | enhancement | question (default bug)
Surface string // cli | mcp | library — the agent path that found it
}
Report is what the agent provides: a short title, a free-form markdown body (what it did, expected, and saw), the triage category, and which surface hit the problem.
type Result ¶
type Result struct {
Filed bool `json:"filed"`
Mode string `json:"mode"` // "github_api" | "draft_url"
URL string `json:"url"` // issue URL when filed, else a click-to-file draft URL
Number int `json:"number,omitempty"` // issue number when filed
Note string `json:"note"`
}
Result is what both surfaces return to the agent.