config

package
v1.1.94 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultSystemPrompt = `You are ggcode, an AI coding assistant running in a terminal.

## Core behavior
- Be precise, concise, and proactive.
- Prefer small, reversible changes over broad rewrites.
- Read before you edit, and inspect results before claiming success.
- Use ` + "`ask_user`" + ` only when a material clarification is needed, the answer will change what you do next, and there is no safe best guess from the current context.
- If something is uncertain or incomplete, say so plainly instead of guessing.
- Follow user instructions strictly and completely. Never skip steps, take shortcuts, or substitute your own judgment for explicit user requirements.

## Dependencies
- Always use the latest version of third-party libraries (` + "`go get pkg@latest`" + `). Never pin or accept outdated versions when a newer one is available.
- Minimize new dependencies. Before adding one, check if an existing dependency already provides the needed functionality.

## Tool routing
- For repository inspection, prefer built-in file and search tools first: ` + "`read_file`" + `, ` + "`list_directory`" + `, ` + "`search_files`" + `, and ` + "`glob`" + `. Do not reach for shell commands when a built-in tool is clearer.
- Use ` + "`edit_file`" + ` for targeted edits and ` + "`write_file`" + ` for creating or replacing whole files.
- Use ` + "`run_command`" + ` for one-shot execution such as builds, tests, git commands, and focused repro steps.
- Use the async command tools (` + "`start_command`" + `, ` + "`read_command_output`" + `, ` + "`wait_command`" + `, ` + "`write_command_input`" + `, ` + "`stop_command`" + `, ` + "`list_commands`" + `) for long-running, streaming, or interactive commands.
- Use the ` + "`skill`" + ` tool when a listed skill clearly matches the task; apply the returned workflow and then continue the task.

## Working style
- Prefer the smallest concrete check that proves the requested behavior.
- Batch related inspections or validations into a single assistant turn when the needed tool calls can be chosen together. Avoid one-tool-at-a-time exploration when several checks are obviously needed.
- Compare expected versus actual behavior when debugging; do not stack speculative fixes.
- Do not emit progress-only assistant messages while meaningful work remains. Continue directly to the next useful tool calls when you already know them.
- Treat ` + "`todo_write`" + ` as optional bookkeeping for genuinely multi-step work. Do not update it after every micro-step; only write todos when the task spans multiple meaningful phases or the plan materially changes.
- Keep user-facing summaries short and useful.

## Memory
- Use ` + "`save_memory`" + ` for durable patterns and decisions that will matter later.
- Check project memory files such as ` + "`GGCODE.md`" + `, ` + "`AGENTS.md`" + `, ` + "`CLAUDE.md`" + `, and ` + "`COPILOT.md`" + ` for project-specific guidance.

## Git conventions
- Always include "Co-Authored-By: ggcode <noreply@ggcode.dev>" in git commit messages.
`

DefaultSystemPrompt is the built-in system prompt used when no custom system_prompt is set.

Variables

This section is empty.

Functions

func BuildSystemPrompt

func BuildSystemPrompt(extraPrompt, workingDir, language string, toolNames []string, gitStatus string, customCmds []string) string

BuildSystemPrompt enhances the base system prompt with runtime context. BuildSystemPrompt builds the full system prompt by prepending the built-in default, appending the user's extra_prompt (if any), then runtime context.

func ConfigDir

func ConfigDir() string

ConfigDir returns ~/.ggcode

func ConfigPath

func ConfigPath() string

ConfigPath returns the default config file path.

func ExpandEnv

func ExpandEnv(s string) string

ExpandEnv replaces ${VAR} patterns in a string with environment variable values. If the variable is not set, the pattern is left unchanged.

func ExpandEnvRecursive

func ExpandEnvRecursive(m map[string]interface{}) map[string]interface{}

ExpandEnvRecursive expands ${VAR} in all string values of a map recursively.

func ExpandEnvRecursiveWithLookup added in v1.0.25

func ExpandEnvRecursiveWithLookup(m map[string]interface{}, lookup envLookupFunc) map[string]interface{}

func ExpandEnvWithLookup added in v1.0.25

func ExpandEnvWithLookup(s string, lookup envLookupFunc) string

func HasInstanceConfig added in v1.1.53

func HasInstanceConfig(workspace string) bool

HasInstanceConfig returns true if an instance config file exists for the workspace.

func HomeDir

func HomeDir() string

HomeDir returns the user's home directory. It respects the $HOME environment variable first (critical for test isolation), then falls back to os.UserHomeDir() (which reads the OS-level home on all platforms).

func IgnorePlaintextAPIKeyWarning added in v1.0.25

func IgnorePlaintextAPIKeyWarning(configPath string) error

func InstanceConfigPath added in v1.1.53

func InstanceConfigPath(workspace string) string

InstanceConfigPath returns the full path to the instance config file. Returns empty string if InstanceDir fails.

func InstanceDir added in v1.1.53

func InstanceDir(workspace string) string

InstanceDir returns the per-workspace instance config directory path. Format: ~/.ggcode/instances/{sha256(abs-workspace)[:16]} Returns empty string if the home directory cannot be resolved.

func IsPlaintextAPIKeyWarningIgnored added in v1.0.25

func IsPlaintextAPIKeyWarningIgnored(configPath string) (bool, error)

func KeysEnvPath added in v1.1.45

func KeysEnvPath() string

KeysEnvPath returns the path to the managed env file for API keys.

func LoadInstanceKeysEnv added in v1.1.53

func LoadInstanceKeysEnv(instanceDir string) error

LoadInstanceKeysEnv loads API keys from an instance directory's keys.env. Instance keys override global keys for the current process.

func LoadKeysEnv added in v1.1.45

func LoadKeysEnv() error

LoadKeysEnv loads API keys from ~/.ggcode/keys.env into the current process environment. Keys that are already set in the environment take precedence and are not overwritten.

func MergeA2AConfig added in v1.1.46

func MergeA2AConfig(base *A2AConfig, override *A2AConfig)

MergeA2AConfig applies instance-level overrides on top of global A2A config. Only non-zero fields from override are applied.

func MergeInstance added in v1.1.53

func MergeInstance(global, instance *Config)

MergeInstance applies instance config on top of global (base) config. Rule: global non-zero fields are never overwritten by instance values. Instance values only fill in gaps where global fields are zero/empty. Fields filled by instance are recorded in instanceFields to prevent them from leaking back into the global file on Save().

func MigrateA2AYaml added in v1.1.53

func MigrateA2AYaml(workspace string) bool

MigrateA2AYaml checks if a legacy .ggcode/a2a.yaml exists and offers to migrate it to the new instance config system. Returns true if migration was performed or already done.

func PreferredAPIKeyEnvVar added in v1.1.23

func PreferredAPIKeyEnvVar(vendor, endpoint string, vendorAPIKey, endpointAPIKey string) string

func PreferredEndpointAPIKeyEnvVar added in v1.1.23

func PreferredEndpointAPIKeyEnvVar(vendor, endpoint string) string

func PreferredVendorAPIKeyEnvVar added in v1.1.23

func PreferredVendorAPIKeyEnvVar(vendor string) string

Types

type A2AAuthConfig added in v1.1.46

type A2AAuthConfig struct {
	// APIKey is the simplest shared-secret auth. All clients use the same key.
	// Empty = no API key auth.
	APIKey string `yaml:"api_key,omitempty"`

	// APIKeys allows multiple API keys for different clients/teams.
	// Both api_key and api_keys are merged; any match authenticates.
	APIKeys []string `yaml:"api_keys,omitempty"`

	// OAuth2 + PKCE / Device Flow for human-interactive agents.
	OAuth2 *A2AOAuth2Config `yaml:"oauth2,omitempty"`

	// OpenID Connect — layered on top of OAuth2, provides identity tokens.
	OIDC *A2AOIDCConfig `yaml:"oidc,omitempty"`

	// Mutual TLS for machine-to-machine. No secrets needed.
	MTLS *A2AMTLSConfig `yaml:"mtls,omitempty"`
}

A2AAuthConfig configures which authentication mechanisms the A2A server accepts. Multiple schemes can be enabled simultaneously — clients choose any one.

type A2AConfig added in v1.1.43

type A2AConfig struct {
	Disabled     bool          `yaml:"disabled,omitempty"` // true to disable (default: enabled)
	Port         int           `yaml:"port"`               // 0 = auto-assign
	Host         string        `yaml:"host"`               // default "0.0.0.0" (if auth configured) or "127.0.0.1"
	APIKey       string        `yaml:"api_key"`            // empty = no auth
	MaxTasks     int           `yaml:"max_tasks"`          // concurrent task limit (default 5)
	TaskTimeout  string        `yaml:"task_timeout"`       // per-task timeout (default "5m")
	LANDiscovery bool          `yaml:"lan_discovery"`      // enable mDNS broadcast for LAN discovery
	Auth         A2AAuthConfig `yaml:"auth,omitempty"`
}

A2AConfig holds A2A protocol server configuration. A2A is enabled by default. Set disabled: true to turn it off.

func LoadA2AOverride added in v1.1.46

func LoadA2AOverride(workspace string) *A2AConfig

LoadA2AOverride loads instance-level A2A config from .ggcode/a2a.yaml in the given workspace directory. Returns nil if no override file exists. Fields set here override the corresponding fields from the global config.

func (A2AConfig) HasAuth added in v1.1.47

func (c A2AConfig) HasAuth() bool

HasAuth returns true if at least one authentication mechanism is configured.

type A2AMTLSConfig added in v1.1.46

type A2AMTLSConfig struct {
	CertFile string `yaml:"cert_file"` // server certificate
	KeyFile  string `yaml:"key_file"`  // server private key
	CAFile   string `yaml:"ca_file"`   // CA to verify client certs
}

A2AMTLSConfig for mutual TLS authentication.

type A2AOAuth2Config added in v1.1.46

type A2AOAuth2Config struct {
	// Provider selects a built-in preset: "github", "google", "auth0", "azure".
	// When set, endpoint URLs and default_client_id are auto-populated.
	Provider string `yaml:"provider,omitempty"`

	// ClientID is the OAuth2 client ID. Auto-filled from provider preset.
	// Override to use your own registered OAuth App.
	ClientID string `yaml:"client_id,omitempty"`

	// ClientSecret is required for GitHub (confidential client).
	// Most other providers support PKCE without a secret.
	// Can also be set via GGCODE_OAUTH_CLIENT_SECRET env var.
	ClientSecret string `yaml:"client_secret,omitempty"`

	// IssuerURL is the OAuth2 issuer base URL. Auto-filled from provider preset.
	// For custom providers: "https://your-idp.example.com"
	IssuerURL string `yaml:"issuer_url,omitempty"`

	// Scopes are space-separated OAuth2 scopes. Auto-filled from provider preset.
	Scopes string `yaml:"scopes,omitempty"`

	// Flow selects the OAuth2 flow: "auto" (default), "pkce", or "device".
	// "auto" picks PKCE for desktop environments, Device Flow for headless.
	Flow string `yaml:"flow,omitempty"`
}

A2AOAuth2Config for OAuth2 Authorization Code + PKCE or Device Flow. Use "provider" for built-in presets or set fields manually for custom IdP.

type A2AOIDCConfig added in v1.1.46

type A2AOIDCConfig struct {
	Provider     string `yaml:"provider,omitempty"`
	ClientID     string `yaml:"client_id,omitempty"`
	ClientSecret string `yaml:"client_secret,omitempty"`
	IssuerURL    string `yaml:"issuer_url,omitempty"` // must have /.well-known/openid-configuration
	Scopes       string `yaml:"scopes,omitempty"`     // should include "openid"
	Flow         string `yaml:"flow,omitempty"`       // "auto", "pkce", "device"
}

A2AOIDCConfig adds OpenID Connect on top of OAuth2. Same provider preset and flow selection as OAuth2.

type APIKeyFinding added in v1.0.25

type APIKeyFinding struct {
	Vendor   string // vendor name (for section="vendor")
	Endpoint string // endpoint name (for section="vendor")
	Section  string // "vendor", "im", "mcp_env", "mcp_headers"
	KeyPath  string // dot-separated path for non-vendor findings (e.g. "im.adapters.ggcode.extra.token")
	EnvVar   string
}

func DetectPlaintextAPIKeys added in v1.0.25

func DetectPlaintextAPIKeys(path string) ([]APIKeyFinding, error)

func MigrateInstancePlaintextAPIKeys added in v1.1.53

func MigrateInstancePlaintextAPIKeys(path, instanceHash string) ([]APIKeyFinding, error)

MigrateInstancePlaintextAPIKeys is the instance-level version of MigratePlaintextAPIKeys. It writes keys to the instance directory's keys.env and uses instance-prefixed env var names (GGCODE_I_{hash}_*) to avoid collisions with global keys. instanceHash is the short SHA256 hash of the workspace path.

func MigratePlaintextAPIKeys added in v1.1.45

func MigratePlaintextAPIKeys(path string) ([]APIKeyFinding, error)

MigratePlaintextAPIKeys detects plaintext API keys in the config file, sets them as environment variables for the current process, persists them to ~/.ggcode/keys.env for future sessions, and rewrites the YAML to use ${VAR} references. Returns the list of migrated keys so callers can log the migration. If no plaintext keys are found, it returns an empty slice and nil error without touching any file.

type Config

type Config struct {
	Vendor        string                    `yaml:"vendor" json:"vendor"`
	Endpoint      string                    `yaml:"endpoint" json:"endpoint"`
	Model         string                    `yaml:"model" json:"model"`
	Language      string                    `yaml:"language" json:"language"`
	UI            UIConfig                  `yaml:"ui,omitempty" json:"ui,omitempty"`
	IM            IMConfig                  `yaml:"im,omitempty" json:"im,omitempty"`
	ExtraPrompt   string                    `yaml:"extra_prompt" json:"extra_prompt"`
	Vendors       map[string]VendorConfig   `yaml:"vendors" json:"vendors"`
	AllowedDirs   []string                  `yaml:"allowed_dirs" json:"allowed_dirs"`
	MaxIterations int                       `yaml:"max_iterations" json:"max_iterations"`
	ToolPerms     map[string]ToolPermission `yaml:"tool_permissions" json:"tool_permissions"`
	Plugins       []PluginConfigEntry       `yaml:"plugins" json:"plugins"`
	MCPServers    []MCPServerConfig         `yaml:"mcp_servers" json:"mcp_servers"`
	Hooks         hooks.HookConfig          `yaml:"hooks" json:"hooks"`
	DefaultMode   string                    `yaml:"default_mode" json:"default_mode"`
	SubAgents     SubAgentConfig            `yaml:"subagents" json:"subagents"`
	Impersonation ImpersonationConfig       `yaml:"impersonation,omitempty" json:"impersonation,omitempty"`
	KnightConfig  KnightConfig              `yaml:"knight,omitempty" json:"knight,omitempty"`
	Swarm         SwarmConfig               `yaml:"swarm,omitempty" json:"swarm,omitempty"`
	A2A           A2AConfig                 `yaml:"a2a,omitempty" json:"a2a,omitempty"`
	Harness       HarnessConfig             `yaml:"harness,omitempty" json:"harness,omitempty"`
	Stream        stream.StreamConfig       `yaml:"stream,omitempty" json:"stream,omitempty"`
	FilePath      string                    `yaml:"-" json:"-"`
	FirstRun      bool                      `yaml:"-" json:"-"`
	// contains filtered or unexported fields
}

Config is the top-level configuration.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a config with sensible defaults.

func Load

func Load(path string) (*Config, error)

Load reads config from the given path. If the file doesn't exist, returns defaults.

func LoadInstanceConfig added in v1.1.53

func LoadInstanceConfig(workspace string) *Config

LoadInstanceConfig loads the instance-level config for a workspace. Returns nil if no instance config file exists.

func LoadWithInstance added in v1.1.53

func LoadWithInstance(path, workspace string) (*Config, error)

LoadWithInstance loads the global config and applies instance-level overrides. workspace is the current working directory used to locate the instance config. It saves a snapshot of the global config so that Save() can avoid leaking instance-level fields back into the global file.

func (*Config) ActiveEndpointConfig

func (c *Config) ActiveEndpointConfig() *EndpointConfig

ActiveEndpointConfig returns a copy of the active endpoint config.

func (*Config) AddEndpoint added in v1.1.45

func (c *Config) AddEndpoint(vendor, endpointName, protocol, baseURL, apiKey string) error

AddEndpoint creates a new endpoint under the given vendor. If the endpoint already exists it is updated. The endpoint name is sanitized for use as a YAML map key (lowercase, no spaces).

func (*Config) AddIMAdapter added in v1.1.32

func (c *Config) AddIMAdapter(name string, adapter IMAdapterConfig) error

func (*Config) AddIMTarget added in v1.1.32

func (c *Config) AddIMTarget(adapterName string, target IMTargetConfig) error

func (*Config) AddVendor added in v1.1.46

func (c *Config) AddVendor(name, displayName, apiKey string) error

AddVendor creates a new vendor with optional display name and API key.

func (*Config) EndpointNames

func (c *Config) EndpointNames(vendor string) []string

EndpointNames returns configured endpoints for the given vendor in a stable order.

func (*Config) ExpandAllowedDirs

func (c *Config) ExpandAllowedDirs(baseDir string) []string

ExpandAllowedDirs resolves allowed_dirs entries relative to baseDir.

func (*Config) HasInstanceConfigAttached added in v1.1.53

func (c *Config) HasInstanceConfigAttached() bool

HasInstanceConfigAttached returns true if this config has an instance workspace attached.

func (*Config) HasInstanceConfigFile added in v1.1.53

func (c *Config) HasInstanceConfigFile() bool

HasInstanceConfigFile returns true if an instance config file actually exists on disk.

func (*Config) InstanceDirPath added in v1.1.53

func (c *Config) InstanceDirPath() string

InstanceDirPath returns the instance directory for this config, or empty string.

func (*Config) InstanceSummary added in v1.1.53

func (c *Config) InstanceSummary() string

InstanceSummary returns a debug string about the instance config state.

func (*Config) InstanceWorkspace added in v1.1.53

func (c *Config) InstanceWorkspace() string

InstanceWorkspace returns the workspace path for instance config, or empty string.

func (*Config) Knight added in v1.1.43

func (c *Config) Knight() KnightConfig

Knight returns the Knight configuration, applying defaults for zero values.

func (*Config) NeedsOnboard added in v1.1.94

func (c *Config) NeedsOnboard() bool

NeedsOnboard returns true when the current config does not have a usable LLM provider and the user should be guided through first-time setup.

func (*Config) RemoveEndpoint added in v1.1.45

func (c *Config) RemoveEndpoint(vendor, endpoint string) error

RemoveEndpoint removes an endpoint from the given vendor.

func (*Config) RemoveIMAdapter added in v1.1.34

func (c *Config) RemoveIMAdapter(name string) error

RemoveIMAdapter removes an IM adapter from the configuration.

func (*Config) RemoveMCPServer

func (c *Config) RemoveMCPServer(name string) bool

func (*Config) RemoveVendor added in v1.1.46

func (c *Config) RemoveVendor(name string) error

RemoveVendor removes a vendor entirely.

func (*Config) ResolveActiveEndpoint

func (c *Config) ResolveActiveEndpoint() (*ResolvedEndpoint, error)

ResolveActiveEndpoint resolves the selected vendor + endpoint into runtime settings.

func (*Config) ResolveEndpoint added in v1.0.12

func (c *Config) ResolveEndpoint(vendor, endpoint string) (*ResolvedEndpoint, error)

ResolveEndpoint resolves the given vendor + endpoint into runtime settings.

func (*Config) ResolveEndpointSelection added in v1.1.43

func (c *Config) ResolveEndpointSelection(vendor, endpoint, model string) (*ResolvedEndpoint, error)

ResolveEndpointSelection resolves the given vendor + endpoint + optional explicit model.

func (*Config) ResolveKnightEndpoint added in v1.1.43

func (c *Config) ResolveKnightEndpoint() (*ResolvedEndpoint, error)

ResolveKnightEndpoint resolves Knight's optional dedicated provider selection. Any missing vendor/endpoint/model field falls back to the main active selection.

func (*Config) Save

func (c *Config) Save() error

fields that existed in the global config are written back. Instance-only fields are never leaked into the global file.

func (*Config) SaveDefaultModePreference added in v1.1.18

func (c *Config) SaveDefaultModePreference(mode string) error

func (*Config) SaveImpersonation added in v1.1.34

func (c *Config) SaveImpersonation(imp ImpersonationConfig) error

SaveImpersonation persists impersonation settings to the config file.

func (*Config) SaveInstance added in v1.1.53

func (c *Config) SaveInstance(workspace string) error

SaveInstance saves the current config as an instance-level override. Only non-zero fields are written. The config is saved to ~/.ggcode/instances/{sha256}/ggcode.yaml. workspace is used to compute the instance directory.

func (*Config) SaveLanguagePreference

func (c *Config) SaveLanguagePreference(lang string) error

func (*Config) SaveScoped added in v1.1.53

func (c *Config) SaveScoped(scope string) error

SaveScoped persists config changes to either global or instance config. scope: "global" saves to the global config file (default behavior). scope: "instance" saves to the instance config directory. Also sets c.saveScope so that subsequent Save*Preference calls use the same target.

func (*Config) SaveSidebarPreference added in v1.1.6

func (c *Config) SaveSidebarPreference(visible bool) error

func (*Config) SetActiveSelection

func (c *Config) SetActiveSelection(vendor, endpoint, model string) error

SetActiveSelection updates the current vendor, endpoint, and model.

func (*Config) SetEndpointAPIKey

func (c *Config) SetEndpointAPIKey(vendor, endpoint, apiKey string, vendorScoped bool) error

SetEndpointAPIKey updates the active endpoint or vendor-level API key. The key is stored as an environment variable reference (e.g. ${ZAI_API_KEY}) rather than plaintext, and the caller should set the actual value in the shell environment (os.Setenv) so the current session can use it immediately.

func (*Config) SetEndpointModels added in v1.0.12

func (c *Config) SetEndpointModels(vendor, endpoint string, models []string) error

SetEndpointModels replaces the known models for a configured endpoint while preserving active selections.

func (*Config) SetIMAdapterEnabled added in v1.1.34

func (c *Config) SetIMAdapterEnabled(name string, enabled bool) error

SetIMAdapterEnabled toggles the enabled state of an IM adapter.

func (*Config) SetIMAdapterExtra added in v1.1.34

func (c *Config) SetIMAdapterExtra(name, key, value string) error

SetIMAdapterExtra sets a single key in the adapter's Extra map.

func (*Config) SetInstancePaths added in v1.1.53

func (c *Config) SetInstancePaths(workspace string)

SetInstancePaths records the instance config directory and path on the Config. This is called after MergeInstance so that Save() can know about the instance context.

func (*Config) SetVendorAPIKey added in v1.1.46

func (c *Config) SetVendorAPIKey(vendor, apiKey string) error

SetVendorAPIKey sets the vendor-level API key.

func (*Config) SidebarVisible added in v1.1.6

func (c *Config) SidebarVisible() bool

func (*Config) UpsertMCPServer

func (c *Config) UpsertMCPServer(server MCPServerConfig) (replaced bool)

func (*Config) Validate

func (c *Config) Validate() error

Validate checks for invalid core configuration values that should fail fast.

func (*Config) VendorNames

func (c *Config) VendorNames() []string

VendorNames returns configured vendors in a stable order.

type EndpointConfig

type EndpointConfig struct {
	DisplayName    string   `yaml:"display_name" json:"display_name"`
	Protocol       string   `yaml:"protocol" json:"protocol"`
	BaseURL        string   `yaml:"base_url" json:"base_url"`
	AuthType       string   `yaml:"auth_type,omitempty" json:"auth_type,omitempty"`
	APIKey         string   `yaml:"api_key,omitempty" json:"api_key,omitempty"`
	ContextWindow  int      `yaml:"context_window,omitempty" json:"context_window,omitempty"`
	MaxTokens      int      `yaml:"max_tokens" json:"max_tokens"`
	SupportsVision *bool    `yaml:"supports_vision,omitempty" json:"supports_vision,omitempty"`
	DefaultModel   string   `yaml:"default_model,omitempty" json:"default_model,omitempty"`
	SelectedModel  string   `yaml:"selected_model,omitempty" json:"selected_model,omitempty"`
	Models         []string `yaml:"models,omitempty" json:"models,omitempty"`
	Tags           []string `yaml:"tags,omitempty" json:"tags,omitempty"`
}

EndpointConfig describes a concrete vendor endpoint that maps to one protocol.

type EndpointPreset added in v1.1.94

type EndpointPreset struct {
	ID           string
	DisplayName  string
	Protocol     string
	DefaultModel string
	Models       []string
}

EndpointPreset describes a built-in endpoint within a vendor.

type HarnessConfig added in v1.1.65

type HarnessConfig struct {
	AutoRun  string `yaml:"auto_run,omitempty" json:"auto_run,omitempty"`   // "off", "suggest", "on", "strict"
	AutoInit bool   `yaml:"auto_init,omitempty" json:"auto_init,omitempty"` // auto-create harness.yaml when missing
}

HarnessConfig controls automatic harness routing behavior. AutoRun modes:

  • "off": No automatic routing (default). Users run harness explicitly.
  • "suggest": Detect code-change tasks and prompt the user to use harness.
  • "on": Automatically route detected code-change tasks to harness.
  • "strict": Same as "on" but enforces worktree isolation; blocks direct file writes.

func (HarnessConfig) AutoRunMode added in v1.1.65

func (h HarnessConfig) AutoRunMode() string

AutoRunMode returns the normalized auto_run mode, defaulting to "off".

type IMAdapterConfig added in v1.1.32

type IMAdapterConfig struct {
	Enabled    bool                   `yaml:"enabled,omitempty" json:"enabled,omitempty"`
	Platform   string                 `yaml:"platform,omitempty" json:"platform,omitempty"`
	Transport  string                 `yaml:"transport,omitempty" json:"transport,omitempty"`
	Command    string                 `yaml:"command,omitempty" json:"command,omitempty"`
	Args       []string               `yaml:"args,omitempty" json:"args,omitempty"`
	Env        map[string]string      `yaml:"env,omitempty" json:"env,omitempty"`
	AllowFrom  []string               `yaml:"allow_from,omitempty" json:"allow_from,omitempty"`
	OutputMode string                 `yaml:"output_mode,omitempty" json:"output_mode,omitempty"` // adapter-level override: verbose, quiet, summary
	Targets    []IMTargetConfig       `yaml:"targets,omitempty" json:"targets,omitempty"`
	Extra      map[string]interface{} `yaml:"extra,omitempty" json:"extra,omitempty"`
}

type IMConfig added in v1.1.32

type IMConfig struct {
	Enabled             bool                       `yaml:"enabled,omitempty" json:"enabled,omitempty"`
	ActiveSessionPolicy string                     `yaml:"active_session_policy,omitempty" json:"active_session_policy,omitempty"`
	RequireLocalSession *bool                      `yaml:"require_local_session,omitempty" json:"require_local_session,omitempty"`
	OutputMode          string                     `yaml:"output_mode,omitempty" json:"output_mode,omitempty"` // verbose, quiet, summary (default: verbose)
	Streaming           IMStreamingConfig          `yaml:"streaming,omitempty" json:"streaming,omitempty"`
	STT                 IMSTTConfig                `yaml:"stt,omitempty" json:"stt,omitempty"`
	Adapters            map[string]IMAdapterConfig `yaml:"adapters,omitempty" json:"adapters,omitempty"`
}

type IMSTTConfig added in v1.1.32

type IMSTTConfig struct {
	Provider string `yaml:"provider,omitempty" json:"provider,omitempty"`
	BaseURL  string `yaml:"base_url,omitempty" json:"base_url,omitempty"`
	APIKey   string `yaml:"api_key,omitempty" json:"api_key,omitempty"`
	Model    string `yaml:"model,omitempty" json:"model,omitempty"`
}

type IMStreamingConfig added in v1.1.32

type IMStreamingConfig struct {
	Enabled         bool    `yaml:"enabled,omitempty" json:"enabled,omitempty"`
	Transport       string  `yaml:"transport,omitempty" json:"transport,omitempty"`
	EditIntervalSec float64 `yaml:"edit_interval_sec,omitempty" json:"edit_interval_sec,omitempty"`
	BufferThreshold int     `yaml:"buffer_threshold,omitempty" json:"buffer_threshold,omitempty"`
	Cursor          string  `yaml:"cursor,omitempty" json:"cursor,omitempty"`
}

type IMTargetConfig added in v1.1.32

type IMTargetConfig struct {
	ID       string            `yaml:"id,omitempty" json:"id,omitempty"`
	Label    string            `yaml:"label,omitempty" json:"label,omitempty"`
	Channel  string            `yaml:"channel,omitempty" json:"channel,omitempty"`
	Thread   string            `yaml:"thread,omitempty" json:"thread,omitempty"`
	Metadata map[string]string `yaml:"metadata,omitempty" json:"metadata,omitempty"`
}

type ImpersonationConfig added in v1.1.34

type ImpersonationConfig struct {
	Preset        string            `yaml:"preset,omitempty"`
	CustomVersion string            `yaml:"custom_version,omitempty"`
	CustomHeaders map[string]string `yaml:"custom_headers,omitempty"`
}

ImpersonationConfig holds persisted impersonation settings.

type KnightConfig added in v1.1.43

type KnightConfig struct {
	// Enabled controls whether Knight runs in daemon mode.
	Enabled bool `yaml:"enabled,omitempty"`

	// Vendor/Endpoint/Model optionally override the main agent LLM selection.
	// Any empty field falls back to the main active selection.
	Vendor   string `yaml:"vendor,omitempty"`
	Endpoint string `yaml:"endpoint,omitempty"`
	Model    string `yaml:"model,omitempty"`

	// TrustLevel controls Knight's autonomy for skill management.
	// "readonly" — Knight only analyzes, never writes anything
	// "staged"   — Knight writes to staging, user approves promotion (default)
	// "auto"     — Knight auto-promotes skills that pass validation
	TrustLevel string `yaml:"trust_level,omitempty"`

	// DailyTokenBudget is the maximum tokens Knight may consume per day.
	// Default: 50,000,000 (50M). Set to 0 to disable budget checking.
	DailyTokenBudget int `yaml:"daily_token_budget,omitempty"`

	// Capabilities lists what Knight is allowed to do.
	// Available: skill_creation, skill_validation, test_generation,
	//            regression_testing, doc_sync
	Capabilities []string `yaml:"capabilities,omitempty"`

	// QuietHours defines time ranges when Knight should not run tasks
	// or send notifications. Format: "HH:MM-HH:MM".
	QuietHours []string `yaml:"quiet_hours,omitempty"`

	// IdleDelaySec is how long to wait after the last user interaction
	// before Knight starts idle tasks. Default: 300 (5 minutes).
	IdleDelaySec int `yaml:"idle_delay_sec,omitempty"`
	// contains filtered or unexported fields
}

KnightConfig holds configuration for the Knight background agent.

func DefaultKnightConfig added in v1.1.43

func DefaultKnightConfig() KnightConfig

DefaultKnightConfig returns the default Knight configuration.

func (KnightConfig) HasExplicitDailyTokenBudget added in v1.1.43

func (kc KnightConfig) HasExplicitDailyTokenBudget() bool

HasExplicitDailyTokenBudget reports whether daily_token_budget was explicitly configured, including an explicit 0 to disable budget enforcement.

func (*KnightConfig) SetDefaults added in v1.1.53

func (kc *KnightConfig) SetDefaults()

SetDefaults fills in default values for any zero-valued fields.

func (*KnightConfig) UnmarshalYAML added in v1.1.43

func (kc *KnightConfig) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML keeps track of whether daily_token_budget was explicitly set so runtime defaults can distinguish "unset" from "set to 0 (unlimited)".

type MCPServerConfig

type MCPServerConfig struct {
	Name              string            `yaml:"name" json:"name"`
	Type              string            `yaml:"type,omitempty" json:"type,omitempty"`
	Command           string            `yaml:"command,omitempty" json:"command,omitempty"`
	Args              []string          `yaml:"args,omitempty" json:"args,omitempty"`
	Env               map[string]string `yaml:"env,omitempty" json:"env,omitempty"`
	URL               string            `yaml:"url,omitempty" json:"url,omitempty"`
	Headers           map[string]string `yaml:"headers,omitempty" json:"headers,omitempty"`
	OAuthClientID     string            `yaml:"oauth_client_id,omitempty" json:"oauth_client_id,omitempty"`
	OAuthClientSecret string            `yaml:"oauth_client_secret,omitempty" json:"oauth_client_secret,omitempty"`
	Source            string            `yaml:"-" json:"-"`
	OriginPath        string            `yaml:"-" json:"-"`
	Migrated          bool              `yaml:"-" json:"-"`
}

MCPServerConfig defines an MCP server to connect to.

type PluginCommandConfig

type PluginCommandConfig struct {
	Name        string   `yaml:"name"`
	Description string   `yaml:"description"`
	Execute     string   `yaml:"execute"`
	Args        []string `yaml:"args"`
}

PluginCommandConfig describes a single command tool within a plugin.

type PluginConfigEntry

type PluginConfigEntry struct {
	Name     string                 `yaml:"name"`
	Path     string                 `yaml:"path"`
	Type     string                 `yaml:"type"`
	Commands []PluginCommandConfig  `yaml:"commands"`
	Extra    map[string]interface{} `yaml:",inline"`
}

PluginConfigEntry describes a single plugin from the config file.

type ResolvedEndpoint

type ResolvedEndpoint struct {
	VendorID       string
	VendorName     string
	EndpointID     string
	EndpointName   string
	Protocol       string
	AuthType       string
	BaseURL        string
	APIKey         string
	EnterpriseURL  string
	Model          string
	ContextWindow  int
	MaxTokens      int
	SupportsVision bool
	Models         []string
	Tags           []string
}

ResolvedEndpoint is the runtime selection after config inheritance is applied.

type SubAgentConfig

type SubAgentConfig struct {
	MaxConcurrent int           `yaml:"max_concurrent"`
	Timeout       time.Duration `yaml:"timeout"`
	ShowOutput    bool          `yaml:"show_output"`
}

SubAgentConfig holds sub-agent configuration.

type SwarmConfig added in v1.1.45

type SwarmConfig struct {
	MaxTeammatesPerTeam int           `yaml:"max_teammates_per_team"` // default: 5
	TeammateTimeout     time.Duration `yaml:"teammate_timeout"`       // default: 30m
	InboxSize           int           `yaml:"inbox_size"`             // default: 32
	PollInterval        time.Duration `yaml:"poll_interval"`          // default: 1s — how often idle teammates check the task board
}

SwarmConfig holds swarm/team multi-agent configuration.

type ToolPermission

type ToolPermission string

ToolPermission defines per-tool permission level in config.

const (
	ToolPermAsk   ToolPermission = "ask"
	ToolPermAllow ToolPermission = "allow"
	ToolPermDeny  ToolPermission = "deny"
)

type UIConfig added in v1.1.6

type UIConfig struct {
	SidebarVisible *bool `yaml:"sidebar_visible,omitempty"`
}

type VendorConfig

type VendorConfig struct {
	DisplayName string                    `yaml:"display_name" json:"display_name"`
	APIKey      string                    `yaml:"api_key,omitempty" json:"api_key,omitempty"`
	Endpoints   map[string]EndpointConfig `yaml:"endpoints" json:"endpoints"`
}

VendorConfig holds a real supplier plus its available endpoints.

type VendorPreset added in v1.1.94

type VendorPreset struct {
	ID              string // vendor key, e.g. "anthropic"
	DisplayName     string // human-readable, e.g. "Anthropic"
	APIKeyEnvHint   string // env var hint, e.g. "ANTHROPIC_API_KEY"
	DefaultEndpoint string // first endpoint key
	NeedsAPIKey     bool   // false for oauth-only vendors like github-copilot
	Endpoints       []EndpointPreset
}

VendorPreset describes a built-in vendor template for the onboard wizard.

func VendorPresets added in v1.1.94

func VendorPresets() []VendorPreset

VendorPresets returns all built-in vendor templates from DefaultConfig, suitable for displaying in the onboard wizard.

Jump to

Keyboard shortcuts

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