Documentation
¶
Overview ¶
Package context implements the `bitbottle context` command — a single one-call orientation primitive that returns the current host, project, slug, branch, default branch, ahead/behind counts vs the default branch, authenticated user, and backend type. This collapses what previously required three independent calls (auth status / repo view / git status) into a single structured response, principally for AI-agent integrations that pay a per-round-trip latency cost.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCmdContext ¶
NewCmdContext builds the cobra command. The command has no subcommands and takes no positional arguments — the entire shape is resolved from config, git state, and one backend round-trip (current user + branch list when inside a repo).
Types ¶
type Context ¶ added in v1.79.0
type Context struct {
Host string `json:"host"`
Project string `json:"project"`
Slug string `json:"slug"`
Branch string `json:"branch"`
DefaultBranch string `json:"default_branch"`
Ahead *int `json:"ahead,omitempty"`
Behind *int `json:"behind,omitempty"`
User ContextUser `json:"user"`
Backend string `json:"backend"`
}
Context is the orientation snapshot returned by `bitbottle context` and the MCP `get_context` tool. It collapses auth status, repo info, and git state into one structured response so callers can orient in a single round-trip.
Ahead and Behind use *int with omitempty so that "unknown" is encoded as absent JSON keys, never as 0/0 — which would falsely signal "in sync". Both pointers are populated as a pair: either both non-nil, or both nil.
This type lives in the cmd layer, not the backend domain, because it carries json tags purely for CLI --json / MCP output. No backend adapter returns or accepts it; it is assembled in Build().
func Build ¶
Build assembles a Context from config, git state, and the backend (current user + branch list when inside a repo). Exposed so the MCP `get_context` handler returns the exact same shape as the CLI.
Outside a git repository, BaseRepo() returns a non-nil error. That branch yields an empty Project / Slug / Branch / DefaultBranch / Ahead / Behind while still resolving Host, User, and Backend.
type ContextUser ¶ added in v1.79.0
ContextUser is the user shape embedded in Context. It mirrors backend.User but carries json tags so the output contract is stable regardless of future backend.User reshaping.