config

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: MIT Imports: 5 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 (
	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

This section is empty.

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 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) ActiveKey

func (c *Config) ActiveKey() (string, error)

func (*Config) ResolveKey

func (c *Config) ResolveKey(overrideName string) (string, string, error)

ResolveKey returns the API key value, with a named override taking precedence.

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"`
	NumberOfLastCommands  int    `json:"number_of_last_commands"`
	Theme                 string `json:"theme,omitempty"`                // "auto", "dark", "light"
	Banner                string `json:"banner,omitempty"`               // "always", "once", "never"
	AutoUpdate            string `json:"auto_update,omitempty"`          // "on", "notify", "off"
	DisableUpdateCheck    bool   `json:"disable_update_check,omitempty"` // legacy, superseded by auto_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