config

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 6 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

Index

Constants

View Source
const (
	EnvAPIKey     = "DOCSGPT_API_KEY"     // agent API key, over the stored default
	EnvToken      = "DOCSGPT_TOKEN"       // personal access token (dgpt_pat_…)
	EnvURL        = "DOCSGPT_URL"         // API base URL
	EnvWebhookURL = "DOCSGPT_WEBHOOK_URL" // agent incoming webhook URL (agents trigger)
)

Environment variables consulted by the resolvers below. They let CI jobs run the CLI without a config file.

View Source
const (
	TokenSourceFlag   = "--token flag"
	TokenSourceEnv    = EnvToken + " environment variable"
	TokenSourceConfig = "config file"
)

Token sources reported by ResolveToken.

View Source
const DefaultBaseURL = "https://gptcloud.arc53.com"
View Source
const TokenPrefix = "dgpt_pat_"

TokenPrefix is the fixed prefix of a DocsGPT personal access token.

Variables

View Source
var ErrNoKey = errors.New("no API key")

ErrNoKey is returned by ResolveKey when no agent API key is configured.

Functions

func Dir

func Dir() string

Dir returns the directory holding CLI state (~/.docsgpt).

func MigrateIfNeeded

func MigrateIfNeeded() error

MigrateIfNeeded checks for old config files and migrates them.

func Path added in v1.7.0

func Path() string

Path returns the config file (~/.docsgpt/config.json).

func RedactKey added in v1.7.0

func RedactKey(key string) string

RedactKey renders an agent API key for display: its first and last four characters. Short values are fully hidden.

func RedactToken

func RedactToken(token string) string

RedactToken renders a credential safely for display: the first 15 characters (the dgpt_pat_ prefix plus the 6 characters the server also shows to tell tokens apart) followed by an ellipsis. Short values are fully hidden.

Types

type Config

type Config struct {
	BaseURL    string            `json:"base_url"`
	DefaultKey string            `json:"default_key"`
	Keys       map[string]string `json:"keys"`
	// Token is a personal access token (dgpt_pat_…) used by the account-level
	// commands (whoami, agents, sources, prompts, tools) and bench agent_id
	// runs. Stored by `login`, removed by `logout`.
	Token    string   `json:"token,omitempty"`
	Settings Settings `json:"settings"`
}

func DefaultConfig

func DefaultConfig() Config

func Load

func Load() (Config, error)

func (*Config) ResolveKey

func (c *Config) ResolveKey(override string) (name, key string, err error)

ResolveKey returns the agent API key to chat with and a name to show for it: the stored key named override (the --key flag) > DOCSGPT_API_KEY > the stored default key.

func (*Config) ResolveToken

func (c *Config) ResolveToken(override string) (token, source string)

ResolveToken returns the personal access token and where it came from: override (the --token flag) > DOCSGPT_TOKEN > config file. Both are empty when no token is configured.

func (*Config) ResolveURL

func (c *Config) ResolveURL(override string) string

ResolveURL returns the base URL: override (the --url flag) > DOCSGPT_URL > config file > built-in default.

func (*Config) Save

func (c *Config) Save() error

type Settings

type Settings struct {
	SendCurrentDirectory  bool `json:"send_current_directory"`
	SendDirectoryContents bool `json:"send_directory_contents"`
	SendLastCommands      bool `json:"send_last_commands"`
	// SendProjectInstructions sends AGENTS.md (or CLAUDE.md) files; a
	// config written before it existed gets the default.
	SendProjectInstructions bool   `json:"send_project_instructions"`
	NumberOfLastCommands    int    `json:"number_of_last_commands"`
	Theme                   string `json:"theme,omitempty"`                // "auto", "dark", "light"
	Banner                  string `json:"banner,omitempty"`               // "always", "once", "never"
	Mouse                   string `json:"mouse,omitempty"`                // "on" (the default), "off": the chat scrolls with the wheel and selects text to copy
	Hyperlinks              string `json:"hyperlinks,omitempty"`           // "auto" (the default), "on", "off": links in answers are clickable (OSC 8)
	Notify                  string `json:"notify,omitempty"`               // "on" (the default), "off": the chat notifies when an answer or approval waits and the terminal is not focused
	TabStatus               string `json:"tab_status,omitempty"`           // "auto" (the default), "on", "off": the chat shows what it is doing on the terminal's tab (iTerm2's session status)
	AutoUpdate              string `json:"auto_update,omitempty"`          // "on", "notify", "off"
	DisableUpdateCheck      bool   `json:"disable_update_check,omitempty"` // legacy, superseded by auto_update
	Retry                   string `json:"retry,omitempty"`                // "on" (the default), "off": send a chat request that failed before its answer again
	WhatsNew                string `json:"whats_new,omitempty"`            // "on" (the default), "off": show the release notes in the chat after an update
}

func (Settings) AutoUpdateMode

func (s Settings) AutoUpdateMode() string

AutoUpdateMode resolves the effective auto-update mode: "on" (stage and apply updates automatically, the default), "notify" (print a notice only), or "off". The legacy disable_update_check flag maps to "off".

Jump to

Keyboard shortcuts

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