Documentation
¶
Index ¶
- Constants
- func BuildSystemPrompt(extraPrompt, workingDir, language string, toolNames []string, gitStatus string, ...) string
- func ConfigDir() string
- func ConfigPath() string
- func ExpandEnv(s string) string
- func ExpandEnvRecursive(m map[string]interface{}) map[string]interface{}
- func ExpandEnvRecursiveWithLookup(m map[string]interface{}, lookup envLookupFunc) map[string]interface{}
- func ExpandEnvWithLookup(s string, lookup envLookupFunc) string
- func HasInstanceConfig(workspace string) bool
- func HomeDir() string
- func IgnorePlaintextAPIKeyWarning(configPath string) error
- func InstanceConfigPath(workspace string) string
- func InstanceDir(workspace string) string
- func IsPlaintextAPIKeyWarningIgnored(configPath string) (bool, error)
- func KeysEnvPath() string
- func LoadInstanceKeysEnv(instanceDir string) error
- func LoadKeysEnv() error
- func MergeA2AConfig(base *A2AConfig, override *A2AConfig)
- func MergeInstance(global, instance *Config)
- func MigrateA2AYaml(workspace string) bool
- func PreferredAPIKeyEnvVar(vendor, endpoint string, vendorAPIKey, endpointAPIKey string) string
- func PreferredEndpointAPIKeyEnvVar(vendor, endpoint string) string
- func PreferredVendorAPIKeyEnvVar(vendor string) string
- type A2AAuthConfig
- type A2AConfig
- type A2AMTLSConfig
- type A2AOAuth2Config
- type A2AOIDCConfig
- type APIKeyFinding
- type Config
- func (c *Config) ActiveEndpointConfig() *EndpointConfig
- func (c *Config) AddEndpoint(vendor, endpointName, protocol, baseURL, apiKey string) error
- func (c *Config) AddIMAdapter(name string, adapter IMAdapterConfig) error
- func (c *Config) AddIMTarget(adapterName string, target IMTargetConfig) error
- func (c *Config) AddVendor(name, displayName, apiKey string) error
- func (c *Config) EndpointNames(vendor string) []string
- func (c *Config) ExpandAllowedDirs(baseDir string) []string
- func (c *Config) HasInstanceConfigAttached() bool
- func (c *Config) HasInstanceConfigFile() bool
- func (c *Config) InstanceDirPath() string
- func (c *Config) InstanceSummary() string
- func (c *Config) InstanceWorkspace() string
- func (c *Config) Knight() KnightConfig
- func (c *Config) NeedsOnboard() bool
- func (c *Config) RemoveEndpoint(vendor, endpoint string) error
- func (c *Config) RemoveIMAdapter(name string) error
- func (c *Config) RemoveMCPServer(name string) bool
- func (c *Config) RemoveVendor(name string) error
- func (c *Config) ResolveActiveEndpoint() (*ResolvedEndpoint, error)
- func (c *Config) ResolveEndpoint(vendor, endpoint string) (*ResolvedEndpoint, error)
- func (c *Config) ResolveEndpointSelection(vendor, endpoint, model string) (*ResolvedEndpoint, error)
- func (c *Config) ResolveKnightEndpoint() (*ResolvedEndpoint, error)
- func (c *Config) Save() error
- func (c *Config) SaveDefaultModePreference(mode string) error
- func (c *Config) SaveImpersonation(imp ImpersonationConfig) error
- func (c *Config) SaveInstance(workspace string) error
- func (c *Config) SaveLanguagePreference(lang string) error
- func (c *Config) SaveScoped(scope string) error
- func (c *Config) SaveSidebarPreference(visible bool) error
- func (c *Config) SetActiveSelection(vendor, endpoint, model string) error
- func (c *Config) SetEndpointAPIKey(vendor, endpoint, apiKey string, vendorScoped bool) error
- func (c *Config) SetEndpointModels(vendor, endpoint string, models []string) error
- func (c *Config) SetIMAdapterEnabled(name string, enabled bool) error
- func (c *Config) SetIMAdapterExtra(name, key, value string) error
- func (c *Config) SetInstancePaths(workspace string)
- func (c *Config) SetVendorAPIKey(vendor, apiKey string) error
- func (c *Config) SidebarVisible() bool
- func (c *Config) UpsertMCPServer(server MCPServerConfig) (replaced bool)
- func (c *Config) Validate() error
- func (c *Config) VendorNames() []string
- type EndpointConfig
- type EndpointPreset
- type HarnessConfig
- type IMAdapterConfig
- type IMConfig
- type IMSTTConfig
- type IMStreamingConfig
- type IMTargetConfig
- type ImpersonationConfig
- type KnightConfig
- type MCPServerConfig
- type PluginCommandConfig
- type PluginConfigEntry
- type ResolvedEndpoint
- type SubAgentConfig
- type SwarmConfig
- type ToolPermission
- type UIConfig
- type VendorConfig
- type VendorPreset
Constants ¶
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.
- Do not use emoji with Variation Selector-16 (VS16, U+FE0F) in your output, including tool descriptions, tool call arguments, and assistant messages. These characters (e.g. ⚠️ ✨️ ⚙️ ⭐️ ⏰️ 🔒️ 🔑️) cause terminal rendering alignment issues. Use plain text equivalents instead (e.g. "Warning:", "Note:", "Info:").
## 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 ExpandEnv ¶
ExpandEnv replaces ${VAR} patterns in a string with environment variable values. If the variable is not set, the pattern is left unchanged.
func ExpandEnvRecursive ¶
ExpandEnvRecursive expands ${VAR} in all string values of a map recursively.
func ExpandEnvRecursiveWithLookup ¶ added in v1.0.25
func ExpandEnvWithLookup ¶ added in v1.0.25
func HasInstanceConfig ¶ added in v1.1.53
HasInstanceConfig returns true if an instance config file exists for the workspace.
func HomeDir ¶
func HomeDir() string
HomeDir returns the user's home directory. Delegates to util.HomeDir which handles $HOME, os.UserHomeDir, and $USERPROFILE.
func IgnorePlaintextAPIKeyWarning ¶ added in v1.0.25
func InstanceConfigPath ¶ added in v1.1.53
InstanceConfigPath returns the full path to the instance config file. Returns empty string if InstanceDir fails.
func InstanceDir ¶ added in v1.1.53
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 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
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
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
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 PreferredEndpointAPIKeyEnvVar ¶ added in v1.1.23
func PreferredVendorAPIKeyEnvVar ¶ added in v1.1.23
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"`
// AllowUnauthenticated allows all requests without authentication.
// By default, unauthenticated requests are only allowed from localhost.
// Set to true to allow remote unauthenticated access (NOT recommended for production).
AllowUnauthenticated bool `yaml:"allow_unauthenticated,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
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.
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"`
ProbeContext bool `yaml:"probe_context,omitempty" json:"probe_context,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 LoadInstanceConfig ¶ added in v1.1.53
LoadInstanceConfig loads the instance-level config for a workspace. Returns nil if no instance config file exists.
func LoadWithInstance ¶ added in v1.1.53
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
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
AddVendor creates a new vendor with optional display name and API key.
func (*Config) EndpointNames ¶
EndpointNames returns configured endpoints for the given vendor in a stable order.
func (*Config) ExpandAllowedDirs ¶
ExpandAllowedDirs resolves allowed_dirs entries relative to baseDir.
func (*Config) HasInstanceConfigAttached ¶ added in v1.1.53
HasInstanceConfigAttached returns true if this config has an instance workspace attached.
func (*Config) HasInstanceConfigFile ¶ added in v1.1.53
HasInstanceConfigFile returns true if an instance config file actually exists on disk.
func (*Config) InstanceDirPath ¶ added in v1.1.53
InstanceDirPath returns the instance directory for this config, or empty string.
func (*Config) InstanceSummary ¶ added in v1.1.53
InstanceSummary returns a debug string about the instance config state.
func (*Config) InstanceWorkspace ¶ added in v1.1.53
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
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
RemoveEndpoint removes an endpoint from the given vendor.
func (*Config) RemoveIMAdapter ¶ added in v1.1.34
RemoveIMAdapter removes an IM adapter from the configuration.
func (*Config) RemoveMCPServer ¶
func (*Config) RemoveVendor ¶ added in v1.1.46
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 ¶
Save persists the config to its configured file path (global config). If an instance config was merged at load time (globalSnap is set), only 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 (*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
SaveInstance saves only the fields that differ from the global config into the instance-level override file at ~/.ggcode/instances/{sha256}/ggcode.yaml.
Strategy: read the existing instance file (if any), compute the diff between the current Config and the globalSnap (the original global values), and write only the changed fields. If no fields differ, the instance file is deleted.
This ensures the instance file remains minimal — only the override values, never a full copy of the config (which would bloat disk usage and leak system_prompt / vendor definitions / secrets into per-workspace files).
func (*Config) SaveLanguagePreference ¶
func (*Config) SaveScoped ¶ added in v1.1.53
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 (*Config) SetActiveSelection ¶
SetActiveSelection updates the current vendor, endpoint, and model.
func (*Config) SetEndpointAPIKey ¶
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
SetEndpointModels replaces the known models for a configured endpoint while preserving active selections.
func (*Config) SetIMAdapterEnabled ¶ added in v1.1.34
SetIMAdapterEnabled toggles the enabled state of an IM adapter.
func (*Config) SetIMAdapterExtra ¶ added in v1.1.34
SetIMAdapterExtra sets a single key in the adapter's Extra map.
func (*Config) SetInstancePaths ¶ added in v1.1.53
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
SetVendorAPIKey sets the vendor-level API key.
func (*Config) SidebarVisible ¶ added in v1.1.6
func (*Config) UpsertMCPServer ¶
func (c *Config) UpsertMCPServer(server MCPServerConfig) (replaced bool)
func (*Config) Validate ¶
Validate checks for invalid core configuration values that should fail fast.
func (*Config) VendorNames ¶
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
BaseURL 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 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: 0 (no timeout, run until task completes)
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.