Documentation
¶
Index ¶
- func EnsureConfigExists() error
- func FilepathOr[T any](key string, value *T) error
- func HasEnvVars(content string) bool
- func LoadSystemPrompt(input string) (string, error)
- func SetConfigPath(path string)
- type AdaptiveColor
- type Config
- type CostConfig
- type CustomModelConfig
- type EnvSubstituter
- type GenerationParams
- type LimitConfig
- type MCPServerConfig
- type MarkdownThemeConfig
- type Theme
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureConfigExists ¶
func EnsureConfigExists() error
EnsureConfigExists checks if a config file exists and creates a default one if not. It searches for .kit.{yml,yaml,json} files in the user's home directory. If none exist, creates a default .kit.yml with examples.
func FilepathOr ¶
FilepathOr reads a configuration value that can be either a direct value or a filepath to a JSON/YAML file containing the value. If the value is a string starting with "~/" or a relative path, it's expanded to an absolute path. The contents of the file are then unmarshaled into the provided value pointer.
func HasEnvVars ¶
HasEnvVars checks if content contains environment variable patterns (${env://...}). This is useful for determining if substitution is needed before processing.
func LoadSystemPrompt ¶
LoadSystemPrompt loads system prompt from file or returns the string directly. If input is a path to an existing file, its contents are read and returned. Otherwise, the input string is returned as-is.
func SetConfigPath ¶
func SetConfigPath(path string)
SetConfigPath sets the configuration file path for resolving relative paths in configuration values. This should be called when the configuration file location is known.
Types ¶
type AdaptiveColor ¶
type AdaptiveColor struct {
Light string `json:"light,omitempty" yaml:"light,omitempty"`
Dark string `json:"dark,omitempty" yaml:"dark,omitempty"`
}
AdaptiveColor represents a color that adapts to light and dark themes. Either light or dark can be specified, or both for theme-aware coloring.
type Config ¶
type Config struct {
MCPServers map[string]MCPServerConfig `json:"mcpServers" yaml:"mcpServers"`
Model string `json:"model,omitempty" yaml:"model,omitempty"`
MaxSteps int `json:"max-steps,omitempty" yaml:"max-steps,omitempty"`
Debug bool `json:"debug,omitempty" yaml:"debug,omitempty"`
SystemPrompt string `json:"system-prompt,omitempty" yaml:"system-prompt,omitempty"`
ProviderAPIKey string `json:"provider-api-key,omitempty" yaml:"provider-api-key,omitempty"`
ProviderURL string `json:"provider-url,omitempty" yaml:"provider-url,omitempty"`
Stream *bool `json:"stream,omitempty" yaml:"stream,omitempty"`
Theme any `json:"theme" yaml:"theme"`
// Model generation parameters
MaxTokens int `json:"max-tokens,omitempty" yaml:"max-tokens,omitempty"`
Temperature *float32 `json:"temperature,omitempty" yaml:"temperature,omitempty"`
TopP *float32 `json:"top-p,omitempty" yaml:"top-p,omitempty"`
TopK *int32 `json:"top-k,omitempty" yaml:"top-k,omitempty"`
FrequencyPenalty *float32 `json:"frequency-penalty,omitempty" yaml:"frequency-penalty,omitempty"`
PresencePenalty *float32 `json:"presence-penalty,omitempty" yaml:"presence-penalty,omitempty"`
StopSequences []string `json:"stop-sequences,omitempty" yaml:"stop-sequences,omitempty"`
// Thinking / extended reasoning
ThinkingLevel string `json:"thinking-level,omitempty" yaml:"thinking-level,omitempty"`
// TLS configuration
TLSSkipVerify bool `json:"tls-skip-verify,omitempty" yaml:"tls-skip-verify,omitempty"`
// Prompt templates configuration
Prompts []string `json:"prompts,omitempty" yaml:"prompts,omitempty"`
NoPromptTemplates bool `json:"no-prompt-templates,omitempty" yaml:"no-prompt-templates,omitempty"`
// Custom model definitions (under custom/ provider)
CustomModels map[string]CustomModelConfig `json:"customModels,omitempty" yaml:"customModels,omitempty"`
// Per-model generation parameter overrides. Keys are "provider/model" strings
// (e.g. "anthropic/claude-sonnet-4-5-20250929", "openai/gpt-4o"). These
// settings act as model-level defaults — CLI flags and global config values
// take precedence when explicitly set.
ModelSettings map[string]GenerationParams `json:"modelSettings,omitempty" yaml:"modelSettings,omitempty"`
}
Config represents the complete application configuration including MCP servers, model settings, UI preferences, and API credentials. It supports both command-line flags and configuration file settings.
func LoadAndValidateConfig ¶
LoadAndValidateConfig loads configuration from viper, fixes environment variable casing issues, and validates the configuration. Returns an error if loading or validation fails.
type CostConfig ¶ added in v0.22.0
type CostConfig struct {
Input float64 `json:"input" yaml:"input"`
Output float64 `json:"output" yaml:"output"`
}
CostConfig defines the pricing for a custom model.
type CustomModelConfig ¶ added in v0.22.0
type CustomModelConfig struct {
Name string `json:"name" yaml:"name"`
BaseURL string `json:"baseUrl,omitempty" yaml:"baseUrl,omitempty"`
APIKey string `json:"apiKey,omitempty" yaml:"apiKey,omitempty"`
Family string `json:"family,omitempty" yaml:"family,omitempty"`
Attachment bool `json:"attachment,omitempty" yaml:"attachment,omitempty"`
Reasoning bool `json:"reasoning,omitempty" yaml:"reasoning,omitempty"`
Temperature bool `json:"temperature,omitempty" yaml:"temperature,omitempty"`
Knowledge string `json:"knowledge,omitempty" yaml:"knowledge,omitempty"`
Cost CostConfig `json:"cost" yaml:"cost"`
Limit LimitConfig `json:"limit" yaml:"limit"`
// Generation parameter defaults for this model.
// These are applied when the user hasn't explicitly set the corresponding
// CLI flag or global config value.
Params GenerationParams `json:"params,omitzero" yaml:"params,omitempty"`
}
CustomModelConfig defines a custom model that can be used with custom/custom or other custom/ prefixed models. These models are loaded from the config file and merged into the custom provider in the model registry.
type EnvSubstituter ¶
type EnvSubstituter struct{}
EnvSubstituter handles environment variable substitution in configuration strings, supporting both ${env://VAR} and ${env://VAR:-default} patterns.
func (*EnvSubstituter) SubstituteEnvVars ¶
func (e *EnvSubstituter) SubstituteEnvVars(content string) (string, error)
SubstituteEnvVars replaces ${env://VAR} and ${env://VAR:-default} patterns with environment variables. If a variable is not set and has a default value, the default is used. Returns an error if required variables (those without defaults) are not set.
type GenerationParams ¶ added in v0.46.0
type GenerationParams struct {
MaxTokens *int `json:"maxTokens,omitempty" yaml:"maxTokens,omitempty"`
Temperature *float32 `json:"temperature,omitempty" yaml:"temperature,omitempty"`
TopP *float32 `json:"topP,omitempty" yaml:"topP,omitempty"`
TopK *int32 `json:"topK,omitempty" yaml:"topK,omitempty"`
FrequencyPenalty *float32 `json:"frequencyPenalty,omitempty" yaml:"frequencyPenalty,omitempty"`
PresencePenalty *float32 `json:"presencePenalty,omitempty" yaml:"presencePenalty,omitempty"`
StopSequences []string `json:"stopSequences,omitempty" yaml:"stopSequences,omitempty"`
ThinkingLevel string `json:"thinkingLevel,omitempty" yaml:"thinkingLevel,omitempty"`
SystemPrompt string `json:"systemPrompt,omitempty" yaml:"systemPrompt,omitempty"`
}
GenerationParams defines generation parameter defaults that can be attached to individual models. These act as model-level defaults — CLI flags and global config values take precedence when explicitly set.
type LimitConfig ¶ added in v0.22.0
type LimitConfig struct {
Context int `json:"context" yaml:"context"`
Output int `json:"output" yaml:"output"`
}
LimitConfig defines context and output limits for a custom model.
type MCPServerConfig ¶
type MCPServerConfig struct {
Type string `json:"type"`
Command []string `json:"command,omitempty"`
Environment map[string]string `json:"environment,omitempty"`
URL string `json:"url,omitempty"`
AllowedTools []string `json:"allowedTools,omitempty" yaml:"allowedTools,omitempty"`
ExcludedTools []string `json:"excludedTools,omitempty" yaml:"excludedTools,omitempty"`
// OAuth configuration for remote servers that don't support dynamic
// client registration (e.g. GitHub). When OAuthClientID is set, it is
// passed directly to the transport's OAuthConfig instead of relying on
// dynamic registration.
OAuthClientID string `json:"oauthClientId,omitempty" yaml:"oauthClientId,omitempty"`
OAuthClientSecret string `json:"oauthClientSecret,omitempty" yaml:"oauthClientSecret,omitempty"`
OAuthScopes []string `json:"oauthScopes,omitempty" yaml:"oauthScopes,omitempty"`
// NoOAuth disables OAuth transport configuration for this server, even
// when the connection pool has an auth handler. Use this for public MCP
// servers (e.g. PubMed) that don't require authentication. Without this
// flag, the pool would attach OAuth transport to every remote server,
// causing proactive dynamic-client-registration attempts that fail on
// servers that don't support it.
NoOAuth bool `json:"noOAuth,omitempty" yaml:"noOAuth,omitempty"`
// TasksMode controls when this server's tools/call requests are augmented
// with MCP task metadata (turning a synchronous call into an asynchronous,
// pollable job — see https://modelcontextprotocol.io/specification/2025-11-25/basic/utilities/tasks).
//
// Valid values:
// - "" or "auto": (default) augment requests with task metadata only
// when the server advertises tasks/toolCalls capability during initialize.
// - "never": never augment — every tool call is synchronous, regardless
// of server capability.
// - "always": always augment, even when the server didn't advertise
// task support. The server may still respond synchronously; this just
// opts in unconditionally on the client side.
//
// In all modes, when the server returns a CreateTaskResult the client polls
// tasks/get / tasks/result until the task reaches a terminal state.
TasksMode string `json:"tasksMode,omitempty" yaml:"tasksMode,omitempty"`
// InProcessServer holds a live *server.MCPServer for in-process transport.
// When set (and Type is "inprocess"), the connection pool creates an
// in-process client instead of spawning a subprocess or making HTTP calls.
// This field is never serialized — it is only used programmatically via the SDK.
InProcessServer any `json:"-" yaml:"-"`
// Legacy fields for backward compatibility
Transport string `json:"transport,omitempty"`
Args []string `json:"args,omitempty"`
Env map[string]any `json:"env,omitempty"`
Headers []string `json:"headers,omitempty"`
}
MCPServerConfig represents configuration for an MCP server, supporting both local (stdio) and remote (StreamableHTTP/SSE) server types. It maintains backward compatibility with legacy configuration formats.
func (*MCPServerConfig) GetTransportType ¶
func (s *MCPServerConfig) GetTransportType() string
GetTransportType returns the transport type for the server config, mapping simplified type names to actual transport protocols. Supports legacy format detection and automatic type inference from configuration.
func (*MCPServerConfig) UnmarshalJSON ¶
func (s *MCPServerConfig) UnmarshalJSON(data []byte) error
UnmarshalJSON handles both new and legacy config formats for backward compatibility. New format uses "type" field with "local", "remote", or "builtin" values. Legacy format uses "transport", "command", "args", and "env" fields.
type MarkdownThemeConfig ¶ added in v0.15.0
type MarkdownThemeConfig struct {
Text AdaptiveColor `json:"text,omitzero" yaml:"text,omitempty"`
Muted AdaptiveColor `json:"muted,omitzero" yaml:"muted,omitempty"`
Heading AdaptiveColor `json:"heading,omitzero" yaml:"heading,omitempty"`
Emph AdaptiveColor `json:"emph,omitzero" yaml:"emph,omitempty"`
Strong AdaptiveColor `json:"strong,omitzero" yaml:"strong,omitempty"`
Link AdaptiveColor `json:"link,omitzero" yaml:"link,omitempty"`
Code AdaptiveColor `json:"code,omitzero" yaml:"code,omitempty"`
Error AdaptiveColor `json:"error,omitzero" yaml:"error,omitempty"`
Keyword AdaptiveColor `json:"keyword,omitzero" yaml:"keyword,omitempty"`
String AdaptiveColor `json:"string,omitzero" yaml:"string,omitempty"`
Number AdaptiveColor `json:"number,omitzero" yaml:"number,omitempty"`
Comment AdaptiveColor `json:"comment,omitzero" yaml:"comment,omitempty"`
}
MarkdownThemeConfig defines color overrides for markdown rendering and syntax highlighting.
type Theme ¶
type Theme struct {
Primary AdaptiveColor `json:"primary,omitzero" yaml:"primary,omitempty"`
Secondary AdaptiveColor `json:"secondary,omitzero" yaml:"secondary,omitempty"`
Success AdaptiveColor `json:"success,omitzero" yaml:"success,omitempty"`
Warning AdaptiveColor `json:"warning,omitzero" yaml:"warning,omitempty"`
Error AdaptiveColor `json:"error,omitzero" yaml:"error,omitempty"`
Info AdaptiveColor `json:"info,omitzero" yaml:"info,omitempty"`
Text AdaptiveColor `json:"text,omitzero" yaml:"text,omitempty"`
Muted AdaptiveColor `json:"muted,omitzero" yaml:"muted,omitempty"`
VeryMuted AdaptiveColor `json:"very-muted,omitzero" yaml:"very-muted,omitempty"`
Background AdaptiveColor `json:"background,omitzero" yaml:"background,omitempty"`
Border AdaptiveColor `json:"border,omitzero" yaml:"border,omitempty"`
MutedBorder AdaptiveColor `json:"muted-border,omitzero" yaml:"muted-border,omitempty"`
System AdaptiveColor `json:"system,omitzero" yaml:"system,omitempty"`
Tool AdaptiveColor `json:"tool,omitzero" yaml:"tool,omitempty"`
Accent AdaptiveColor `json:"accent,omitzero" yaml:"accent,omitempty"`
Highlight AdaptiveColor `json:"highlight,omitzero" yaml:"highlight,omitempty"`
// Diff block backgrounds
DiffInsertBg AdaptiveColor `json:"diff-insert-bg,omitzero" yaml:"diff-insert-bg,omitempty"`
DiffDeleteBg AdaptiveColor `json:"diff-delete-bg,omitzero" yaml:"diff-delete-bg,omitempty"`
DiffEqualBg AdaptiveColor `json:"diff-equal-bg,omitzero" yaml:"diff-equal-bg,omitempty"`
DiffMissingBg AdaptiveColor `json:"diff-missing-bg,omitzero" yaml:"diff-missing-bg,omitempty"`
// Code/output block backgrounds
CodeBg AdaptiveColor `json:"code-bg,omitzero" yaml:"code-bg,omitempty"`
GutterBg AdaptiveColor `json:"gutter-bg,omitzero" yaml:"gutter-bg,omitempty"`
WriteBg AdaptiveColor `json:"write-bg,omitzero" yaml:"write-bg,omitempty"`
// Markdown rendering and syntax highlighting
Markdown MarkdownThemeConfig `json:"markdown,omitzero" yaml:"markdown,omitempty"`
}
Theme defines the color scheme for the application UI with adaptive colors that support both light and dark modes.