Documentation
¶
Index ¶
- Constants
- func BuildSystemPrompt(basePrompt, 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 HomeDir() string
- func IgnorePlaintextAPIKeyWarning(configPath string) error
- func IsPlaintextAPIKeyWarningIgnored(configPath string) (bool, error)
- func PreferredAPIKeyEnvVar(vendor, endpoint string, vendorAPIKey, endpointAPIKey string) string
- func PreferredEndpointAPIKeyEnvVar(vendor, endpoint string) string
- func PreferredVendorAPIKeyEnvVar(vendor string) string
- type APIKeyFinding
- type Config
- func (c *Config) ActiveEndpointConfig() *EndpointConfig
- func (c *Config) AddIMAdapter(name string, adapter IMAdapterConfig) error
- func (c *Config) AddIMTarget(adapterName string, target IMTargetConfig) error
- func (c *Config) EndpointNames(vendor string) []string
- func (c *Config) ExpandAllowedDirs(baseDir string) []string
- func (c *Config) RemoveMCPServer(name string) bool
- func (c *Config) ResolveActiveEndpoint() (*ResolvedEndpoint, error)
- func (c *Config) ResolveEndpoint(vendor, endpoint string) (*ResolvedEndpoint, error)
- func (c *Config) Save() error
- func (c *Config) SaveDefaultModePreference(mode string) error
- func (c *Config) SaveLanguagePreference(lang 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) SidebarVisible() bool
- func (c *Config) UpsertMCPServer(server MCPServerConfig) (replaced bool)
- func (c *Config) Validate() error
- func (c *Config) VendorNames() []string
- type EndpointConfig
- type IMAdapterConfig
- type IMConfig
- type IMSTTConfig
- type IMStreamingConfig
- type IMTargetConfig
- type MCPServerConfig
- type PluginCommandConfig
- type PluginConfigEntry
- type ResolvedEndpoint
- type SubAgentConfig
- type ToolPermission
- type UIConfig
- type VendorConfig
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.
## 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 ` + "`list_mcp_capabilities`" + ` before assuming MCP-backed browser, external service, or prompt/resource capabilities are available.
- 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.
- Use ` + "`@mentions`" + ` when referencing files for context.
## 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.
- Learn from stable user preferences across sessions.
`
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(basePrompt, workingDir, language string, toolNames []string, gitStatus string, customCmds []string) string
BuildSystemPrompt enhances the base system prompt with 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 IgnorePlaintextAPIKeyWarning ¶ added in v1.0.25
func IsPlaintextAPIKeyWarningIgnored ¶ added in v1.0.25
func PreferredAPIKeyEnvVar ¶ added in v1.1.23
func PreferredEndpointAPIKeyEnvVar ¶ added in v1.1.23
func PreferredVendorAPIKeyEnvVar ¶ added in v1.1.23
Types ¶
type APIKeyFinding ¶ added in v1.0.25
func DetectPlaintextAPIKeys ¶ added in v1.0.25
func DetectPlaintextAPIKeys(path string) ([]APIKeyFinding, error)
type Config ¶
type Config struct {
Vendor string `yaml:"vendor"`
Endpoint string `yaml:"endpoint"`
Model string `yaml:"model"`
Language string `yaml:"language"`
UI UIConfig `yaml:"ui,omitempty"`
IM IMConfig `yaml:"im,omitempty"`
SystemPrompt string `yaml:"system_prompt"`
Vendors map[string]VendorConfig `yaml:"vendors"`
AllowedDirs []string `yaml:"allowed_dirs"`
MaxIterations int `yaml:"max_iterations"`
ToolPerms map[string]ToolPermission `yaml:"tool_permissions"`
Plugins []PluginConfigEntry `yaml:"plugins"`
MCPServers []MCPServerConfig `yaml:"mcp_servers"`
Hooks hooks.HookConfig `yaml:"hooks"`
DefaultMode string `yaml:"default_mode"`
SubAgents SubAgentConfig `yaml:"subagents"`
FilePath string `yaml:"-"`
FirstRun bool `yaml:"-"`
}
Config is the top-level configuration.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a config with sensible defaults.
func (*Config) ActiveEndpointConfig ¶
func (c *Config) ActiveEndpointConfig() *EndpointConfig
ActiveEndpointConfig returns a copy of the active endpoint config.
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) 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) RemoveMCPServer ¶
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) SaveDefaultModePreference ¶ added in v1.1.18
func (*Config) SaveLanguagePreference ¶
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.
func (*Config) SetEndpointModels ¶ added in v1.0.12
SetEndpointModels replaces the known models for a configured endpoint while preserving active selections.
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"`
Protocol string `yaml:"protocol"`
BaseURL string `yaml:"base_url"`
AuthType string `yaml:"auth_type,omitempty"`
APIKey string `yaml:"api_key,omitempty"`
ContextWindow int `yaml:"context_window,omitempty"`
MaxTokens int `yaml:"max_tokens"`
SupportsVision *bool `yaml:"supports_vision,omitempty"`
DefaultModel string `yaml:"default_model,omitempty"`
SelectedModel string `yaml:"selected_model,omitempty"`
Models []string `yaml:"models,omitempty"`
Tags []string `yaml:"tags,omitempty"`
}
EndpointConfig describes a concrete vendor endpoint that maps to one protocol.
type IMAdapterConfig ¶ added in v1.1.32
type IMAdapterConfig struct {
Enabled bool `yaml:"enabled,omitempty"`
Platform string `yaml:"platform,omitempty"`
Transport string `yaml:"transport,omitempty"`
Command string `yaml:"command,omitempty"`
Args []string `yaml:"args,omitempty"`
Env map[string]string `yaml:"env,omitempty"`
AllowFrom []string `yaml:"allow_from,omitempty"`
Targets []IMTargetConfig `yaml:"targets,omitempty"`
Extra map[string]interface{} `yaml:"extra,omitempty"`
}
type IMConfig ¶ added in v1.1.32
type IMConfig struct {
Enabled bool `yaml:"enabled,omitempty"`
ActiveSessionPolicy string `yaml:"active_session_policy,omitempty"`
RequireLocalSession *bool `yaml:"require_local_session,omitempty"`
Streaming IMStreamingConfig `yaml:"streaming,omitempty"`
STT IMSTTConfig `yaml:"stt,omitempty"`
Adapters map[string]IMAdapterConfig `yaml:"adapters,omitempty"`
}
type IMSTTConfig ¶ added in v1.1.32
type IMStreamingConfig ¶ added in v1.1.32
type IMTargetConfig ¶ added in v1.1.32
type MCPServerConfig ¶
type MCPServerConfig struct {
Name string `yaml:"name"`
Type string `yaml:"type,omitempty"`
Command string `yaml:"command,omitempty"`
Args []string `yaml:"args,omitempty"`
Env map[string]string `yaml:"env,omitempty"`
URL string `yaml:"url,omitempty"`
Headers map[string]string `yaml:"headers,omitempty"`
Source string `yaml:"-"`
OriginPath string `yaml:"-"`
Migrated bool `yaml:"-"`
}
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 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"`
APIKey string `yaml:"api_key,omitempty"`
Endpoints map[string]EndpointConfig `yaml:"endpoints"`
}
VendorConfig holds a real supplier plus its available endpoints.