config

package
v0.22.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterServeFlags

func RegisterServeFlags(fs *flag.FlagSet)

RegisterServeFlags registers serve-command flags on fs. The caller must call fs.Parse before passing fs to Load.

func ResetBareEnvWarned added in v0.16.0

func ResetBareEnvWarned()

ResetBareEnvWarned clears the warning dedup state. Exported for tests.

func ResolveDataDir

func ResolveDataDir() (string, error)

ResolveDataDir returns the effective data directory by applying defaults and environment overrides, without reading any files. Use this to determine where migration should target before calling Load or LoadMinimal.

Types

type Config

type Config struct {
	Host                 string         `json:"host" toml:"host"`
	Port                 int            `json:"port" toml:"port"`
	DataDir              string         `json:"data_dir" toml:"data_dir"`
	DBPath               string         `json:"-" toml:"-"`
	PublicURL            string         `json:"public_url,omitempty" toml:"public_url"`
	PublicOrigins        []string       `json:"public_origins,omitempty" toml:"public_origins"`
	Proxy                ProxyConfig    `json:"proxy,omitempty" toml:"proxy"`
	WatchExcludePatterns []string       `json:"watch_exclude_patterns,omitempty" toml:"watch_exclude_patterns"`
	CursorSecret         string         `json:"cursor_secret" toml:"cursor_secret"`
	GithubToken          string         `json:"github_token,omitempty" toml:"github_token"`
	Terminal             TerminalConfig `json:"terminal,omitempty" toml:"terminal"`
	AuthToken            string         `json:"auth_token,omitempty" toml:"auth_token"`
	RemoteAccess         bool           `json:"remote_access" toml:"remote_access"`
	NoBrowser            bool           `json:"no_browser" toml:"no_browser"`
	DisableUpdateCheck   bool           `json:"disable_update_check" toml:"disable_update_check"`
	NoSync               bool           `json:"-" toml:"-"`
	PG                   PGConfig       `json:"pg,omitempty" toml:"pg"`
	WriteTimeout         time.Duration  `json:"-" toml:"-"`

	// AgentDirs maps each AgentType to its configured
	// directories. Single-dir agents store a one-element
	// slice; unconfigured agents use nil.
	AgentDirs map[parser.AgentType][]string `json:"-" toml:"-"`

	ResultContentBlockedCategories []string `json:"result_content_blocked_categories,omitempty" toml:"result_content_blocked_categories"`

	// HostExplicit is true when the user passed --host on the CLI.
	// Used to prevent auto-bind to 0.0.0.0 when the user
	// explicitly requested a specific host.
	HostExplicit bool `json:"-" toml:"-"`
	// contains filtered or unexported fields
}

Config holds all application configuration.

func Default

func Default() (Config, error)

Default returns a Config with default values.

func Load

func Load(fs *flag.FlagSet) (Config, error)

Load builds a Config by layering: defaults < config file < env < flags. The provided FlagSet must already be parsed by the caller. Only flags that were explicitly set override the lower layers.

func LoadMinimal

func LoadMinimal() (Config, error)

LoadMinimal builds a Config from defaults, env, and config file, without parsing CLI flags. Use this for subcommands that manage their own flag sets.

func LoadPGServe added in v0.16.0

func LoadPGServe(fs *flag.FlagSet) (Config, error)

LoadPGServe builds a Config for `pg serve` by preserving shared and PG settings from defaults/env/config file while resetting serve-specific network/browser settings to defaults. Only explicitly provided serve flags are applied on top.

func (*Config) EnsureAuthToken added in v0.13.0

func (c *Config) EnsureAuthToken() error

EnsureAuthToken generates and persists an auth token if one does not already exist. Called when remote_access is enabled.

func (*Config) IsUserConfigured added in v0.10.0

func (c *Config) IsUserConfigured(
	agent parser.AgentType,
) bool

IsUserConfigured reports whether the agent's directories were explicitly set by the user (via env var or config file) rather than populated from defaults.

func (*Config) ResolveDirs added in v0.10.0

func (c *Config) ResolveDirs(
	agent parser.AgentType,
) []string

ResolveDirs returns the effective directories for an agent.

func (*Config) ResolvePG added in v0.16.0

func (c *Config) ResolvePG() (PGConfig, error)

ResolvePG returns a copy of PG config with defaults applied and environment variables expanded in URL.

func (*Config) SaveGithubToken

func (c *Config) SaveGithubToken(token string) error

SaveGithubToken persists the GitHub token to the config file.

func (*Config) SaveSettings added in v0.13.0

func (c *Config) SaveSettings(patch map[string]any) error

SaveSettings persists a partial settings update to the config file. The patch map contains config keys mapped to their new values. Only the keys present in patch are written; other config keys are preserved.

func (*Config) SaveTerminalConfig added in v0.12.0

func (c *Config) SaveTerminalConfig(tc TerminalConfig) error

SaveTerminalConfig persists terminal settings to the config file.

type PGConfig added in v0.16.0

type PGConfig struct {
	URL             string   `toml:"url" json:"url"`
	Schema          string   `toml:"schema" json:"schema"`
	MachineName     string   `toml:"machine_name" json:"machine_name"`
	AllowInsecure   bool     `toml:"allow_insecure" json:"allow_insecure"`
	Projects        []string `toml:"projects" json:"projects,omitempty"`
	ExcludeProjects []string `toml:"exclude_projects" json:"exclude_projects,omitempty"`
}

PGConfig holds PostgreSQL connection settings.

type ProxyConfig added in v0.13.0

type ProxyConfig struct {
	// Mode enables a managed proxy implementation.
	// Currently supported: "caddy".
	Mode string `json:"mode,omitempty" toml:"mode"`
	// Bin overrides the proxy executable path.
	Bin string `json:"bin,omitempty" toml:"bin"`
	// BindHost is the local interface/IP the proxy binds to.
	BindHost string `json:"bind_host,omitempty" toml:"bind_host"`
	// PublicPort is the external port exposed by the proxy.
	PublicPort int `json:"public_port,omitempty" toml:"public_port"`
	// TLSCert and TLSKey are used by managed HTTPS mode.
	TLSCert string `json:"tls_cert,omitempty" toml:"tls_cert"`
	TLSKey  string `json:"tls_key,omitempty" toml:"tls_key"`
	// AllowedSubnets restrict inbound clients to these CIDRs.
	AllowedSubnets []string `json:"allowed_subnets,omitempty" toml:"allowed_subnets"`
}

ProxyConfig controls an optional managed reverse proxy.

type TerminalConfig added in v0.12.0

type TerminalConfig struct {
	// Mode: "auto" (detect terminal), "custom" (use CustomBin),
	// or "clipboard" (never launch, always copy).
	Mode string `json:"mode" toml:"mode"`
	// CustomBin is the terminal binary path (used when Mode == "custom").
	CustomBin string `json:"custom_bin,omitempty" toml:"custom_bin"`
	// CustomArgs is a template for terminal args. Use {cmd} as
	// placeholder for the resume command (e.g. "-- bash -c {cmd}").
	CustomArgs string `json:"custom_args,omitempty" toml:"custom_args"`
}

TerminalConfig holds terminal launch preferences.

Jump to

Keyboard shortcuts

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