feedback

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func DraftURL(repo string, iss Issue, category string) string

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

type Env struct {
	Version string
	Commit  string
	OS      string
	Arch    string
	Go      string
}

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

func RuntimeEnv(version, commit string) Env

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

type Issue struct {
	Title string
	Body  string
}

Issue is the rendered GitHub issue — a pure function of (Report, Env).

func BuildIssue

func BuildIssue(r Report, env Env) Issue

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.

func File

func File(ctx context.Context, r Report, env Env, cfg Config, confirm bool) (Result, error)

File renders the report and either opens a GitHub issue or returns a draft URL. It returns an error only for caller-side problems (empty title/body); a GitHub-side failure degrades to a draft URL with the cause in Note, so the feedback is never silently lost.

Jump to

Keyboard shortcuts

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