copilot

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 12 Imported by: 0 modules, 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 copilot turns a GitHub Copilot subscription into a memcode backend: it finds the GitHub token the machine already has (an env var or `gh auth token`), exchanges it for a short-lived Copilot API token, and returns the endpoint + identity headers the Copilot API requires. No vendor SDK — raw HTTP and one subprocess — so it composes into provider selection without a dependency cycle (it returns a plain Backend; the provider package adapts it to an Endpoint).

This is consent-gated upstream: it activates only when the user explicitly selects the copilot source (the first-run wizard, or MEMCODE_CREDENTIAL_SOURCE =copilot). It never reads `gh` behind the user's back.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Available

func Available() bool

Available reports whether a GitHub token the exchange could use is present — an env var or a gh install — without exchanging. For the wizard's menu.

Types

type Backend

type Backend struct {
	BaseURL string
	Token   string
	Headers map[string]string
}

Backend is the resolved Copilot endpoint: a Bearer token plus the identity headers every turn must carry. Consumed by the provider package.

func Resolve

func Resolve(ctx context.Context) (Backend, error)

Resolve finds the GitHub token, exchanges it (using a cached Copilot token while fresh), and returns the backend. An error explains the fix (sign in with gh, or the token type Copilot won't accept).

Jump to

Keyboard shortcuts

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