config

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: MIT Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AgentReviewer string = "reviewer" // Changed from AgentCoder
	AgentTask     string = "task"
)
View Source
const (
	EnvGeminiAPIKey = "GEMINI_API_KEY"
	EnvEditor       = "EDITOR"
)

Environment variable names

View Source
const (
	ModelGeminiFlash = "gemini-2.5-flash"
	ModelGeminiPro   = "gemini-2.5-pro"
)

Model names

View Source
const (
	ConfigDirName   = ".config"
	AppDirName      = "revcli"
	SessionsDirName = "sessions"
)

Config directory names

View Source
const (
	InitFlagFilename = "init"
)

Variables

This section is empty.

Functions

func GlobalConfig added in v0.4.0

func GlobalConfig() string

GlobalConfig returns the global configuration file path for the application.

func GlobalConfigData added in v0.4.0

func GlobalConfigData() string

GlobalConfigData returns the path to the main data directory for the application. this config is used when the app overrides configurations instead of updating the global config.

func GlobalSkillsDir added in v0.4.0

func GlobalSkillsDir() string

GlobalSkillsDir returns the default directory for Agent Skills. Skills in this directory are auto-discovered and their files can be read without permission prompts.

func HasInitialDataConfig added in v0.4.0

func HasInitialDataConfig() bool

func MarkProjectInitialized added in v0.4.0

func MarkProjectInitialized() error

func Merge added in v0.4.0

func Merge(data []io.Reader) (io.Reader, error)

func ProjectNeedsInitialization added in v0.4.0

func ProjectNeedsInitialization() (bool, error)

func Providers added in v0.4.0

func Providers(cfg *Config) ([]catwalk.Provider, error)

Providers returns the list of providers, taking into account cached results and whether or not auto update is enabled.

It will: 1. if auto update is disabled, it'll return the embedded providers at the time of release. 2. load the cached providers 3. try to get the fresh list of providers, and return either this new list, the cached list, or the embedded list if all others fail.

func PushPopCrushEnv added in v0.4.0

func PushPopCrushEnv() func()

func UpdateHyper added in v0.4.0

func UpdateHyper(pathOrURL string) error

UpdateHyper updates the Hyper provider information from a specified URL.

func UpdateProviders added in v0.4.0

func UpdateProviders(pathOrURL string) error

UpdateProviders updates the Catwalk providers list from a specified source.

Types

type Agent added in v0.4.0

type Agent struct {
	ID          string `json:"id,omitempty"`
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	// This is the id of the system prompt used by the agent
	Disabled bool `json:"disabled,omitempty"`

	Model SelectedModelType `json:"model" jsonschema:"required,description=The model type to use for this agent,enum=large,enum=small,default=large"`

	// The available tools for the agent
	//  if this is nil, all tools are available
	AllowedTools []string `json:"allowed_tools,omitempty"`

	// this tells us which MCPs are available for this agent
	//  if this is empty all mcps are available
	//  the string array is the list of tools from the AllowedMCP the agent has available
	//  if the string array is nil, all tools from the AllowedMCP are available
	AllowedMCP map[string][]string `json:"allowed_mcp,omitempty"`

	// Overrides the context paths for this agent
	ContextPaths []string `json:"context_paths,omitempty"`
}

type Attribution added in v0.4.0

type Attribution struct {
	TrailerStyle  TrailerStyle `` /* 169-byte string literal not displayed */
	CoAuthoredBy  *bool        `json:"co_authored_by,omitempty" jsonschema:"description=Deprecated: use trailer_style instead"`
	GeneratedWith bool         `` /* 138-byte string literal not displayed */
}

func (Attribution) JSONSchemaExtend added in v0.4.0

func (Attribution) JSONSchemaExtend(schema *jsonschema.Schema)

JSONSchemaExtend marks the co_authored_by field as deprecated in the schema.

type Completions added in v0.4.0

type Completions struct {
	MaxDepth *int `json:"max_depth,omitempty" jsonschema:"description=Maximum depth for the ls tool,default=0,example=10"`
	MaxItems *int `` /* 126-byte string literal not displayed */
}

Completions defines options for the completions UI.

func (Completions) Limits added in v0.4.0

func (c Completions) Limits() (depth, items int)

type Config added in v0.4.0

type Config struct {
	Schema string `json:"$schema,omitempty"`

	// We currently only support large/small as values here.
	Models map[SelectedModelType]SelectedModel `` /* 162-byte string literal not displayed */
	// Recently used models stored in the data directory config.
	RecentModels map[SelectedModelType][]SelectedModel `json:"recent_models,omitempty" jsonschema:"description=Recently used models sorted by most recent first"`

	// The providers that are configured
	Providers *csync.Map[string, ProviderConfig] `json:"providers,omitempty" jsonschema:"description=AI provider configurations"`

	MCP MCPs `json:"mcp,omitempty" jsonschema:"description=Model Context Protocol server configurations"`

	LSP LSPs `json:"lsp,omitempty" jsonschema:"description=Language Server Protocol configurations"`

	Options *Options `json:"options,omitempty" jsonschema:"description=General application options"`

	Permissions *Permissions `json:"permissions,omitempty" jsonschema:"description=Permission settings for tool usage"`

	Tools Tools `json:"tools,omitzero" jsonschema:"description=Tool configurations"`

	Agents map[string]Agent `json:"-"`
	// contains filtered or unexported fields
}

Config holds the configuration for revCLI.

func Get added in v0.4.0

func Get() *Config

func Init added in v0.4.0

func Init(workingDir, dataDir string, debug bool) (*Config, error)

func Load added in v0.4.0

func Load(workingDir, dataDir string, debug bool) (*Config, error)

Load loads the configuration from the default paths.

func LoadReader added in v0.4.0

func LoadReader(fd io.Reader) (*Config, error)

LoadReader config via io.Reader.

func (*Config) EnabledProviders added in v0.4.0

func (c *Config) EnabledProviders() []ProviderConfig

func (*Config) GetModel added in v0.4.0

func (c *Config) GetModel(provider, model string) *catwalk.Model

func (*Config) GetModelByType added in v0.4.0

func (c *Config) GetModelByType(modelType SelectedModelType) *catwalk.Model

func (*Config) GetProviderForModel added in v0.4.0

func (c *Config) GetProviderForModel(modelType SelectedModelType) *ProviderConfig

func (*Config) HasConfigField added in v0.4.0

func (c *Config) HasConfigField(key string) bool

func (*Config) ImportCopilot added in v0.4.0

func (c *Config) ImportCopilot() (*oauth.Token, bool)

func (*Config) IsConfigured added in v0.4.0

func (c *Config) IsConfigured() bool

IsConfigured return true if at least one provider is configured

func (*Config) LargeModel added in v0.4.0

func (c *Config) LargeModel() *catwalk.Model

func (*Config) RefreshOAuthToken added in v0.4.0

func (c *Config) RefreshOAuthToken(ctx context.Context, providerID string) error

RefreshOAuthToken refreshes the OAuth token for the given provider.

func (*Config) Resolve added in v0.4.0

func (c *Config) Resolve(key string) (string, error)

func (*Config) Resolver added in v0.4.0

func (c *Config) Resolver() VariableResolver

func (*Config) SetCompactMode added in v0.4.0

func (c *Config) SetCompactMode(enabled bool) error

func (*Config) SetConfigField added in v0.4.0

func (c *Config) SetConfigField(key string, value any) error

func (*Config) SetProviderAPIKey added in v0.4.0

func (c *Config) SetProviderAPIKey(providerID string, apiKey any) error

func (*Config) SetupAgents added in v0.4.0

func (c *Config) SetupAgents()

Tool filtering strategy for future modes: - Review mode: read-only tools by default, write tools optional (user configurable) - Build mode: all tools available (full code generation capability) - Ask mode: read-only tools + specific Q&A tools TODO(PlanC): Implement mode-based tool filtering in coordinator TODO(PlanC): Implement builderPrompt for build mode TODO(PlanC): Implement askerPrompt for ask mode

func (*Config) SmallModel added in v0.4.0

func (c *Config) SmallModel() *catwalk.Model

func (*Config) UpdatePreferredModel added in v0.4.0

func (c *Config) UpdatePreferredModel(modelType SelectedModelType, model SelectedModel) error

func (*Config) WorkingDir added in v0.4.0

func (c *Config) WorkingDir() string

type LSP added in v0.4.0

type LSP struct {
	Name string    `json:"name"`
	LSP  LSPConfig `json:"lsp"`
}

type LSPConfig added in v0.4.0

type LSPConfig struct {
	Disabled    bool              `json:"disabled,omitempty" jsonschema:"description=Whether this LSP server is disabled,default=false"`
	Command     string            `json:"command,omitempty" jsonschema:"required,description=Command to execute for the LSP server,example=gopls"`
	Args        []string          `json:"args,omitempty" jsonschema:"description=Arguments to pass to the LSP server command"`
	Env         map[string]string `json:"env,omitempty" jsonschema:"description=Environment variables to set to the LSP server command"`
	FileTypes   []string          `` /* 152-byte string literal not displayed */
	RootMarkers []string          `` /* 161-byte string literal not displayed */
	InitOptions map[string]any    `` /* 128-byte string literal not displayed */
	Options     map[string]any    `json:"options,omitempty" jsonschema:"description=LSP server-specific settings passed during initialization"`
}

func (LSPConfig) ResolvedEnv added in v0.4.0

func (l LSPConfig) ResolvedEnv() []string

type LSPs added in v0.4.0

type LSPs map[string]LSPConfig

func (LSPs) Sorted added in v0.4.0

func (l LSPs) Sorted() []LSP

type MCP added in v0.4.0

type MCP struct {
	Name string    `json:"name"`
	MCP  MCPConfig `json:"mcp"`
}

type MCPConfig added in v0.4.0

type MCPConfig struct {
	Command       string            `json:"command,omitempty" jsonschema:"description=Command to execute for stdio MCP servers,example=npx"`
	Env           map[string]string `json:"env,omitempty" jsonschema:"description=Environment variables to set for the MCP server"`
	Args          []string          `json:"args,omitempty" jsonschema:"description=Arguments to pass to the MCP server command"`
	Type          MCPType           `json:"type" jsonschema:"required,description=Type of MCP connection,enum=stdio,enum=sse,enum=http,default=stdio"`
	URL           string            `json:"url,omitempty" jsonschema:"description=URL for HTTP or SSE MCP servers,format=uri,example=http://localhost:3000/mcp"`
	Disabled      bool              `json:"disabled,omitempty" jsonschema:"description=Whether this MCP server is disabled,default=false"`
	DisabledTools []string          `` /* 126-byte string literal not displayed */
	Timeout       int               `` /* 140-byte string literal not displayed */

	// TODO: maybe make it possible to get the value from the env
	Headers map[string]string `json:"headers,omitempty" jsonschema:"description=HTTP headers for HTTP/SSE MCP servers"`
}

func (MCPConfig) ResolvedEnv added in v0.4.0

func (m MCPConfig) ResolvedEnv() []string

func (MCPConfig) ResolvedHeaders added in v0.4.0

func (m MCPConfig) ResolvedHeaders() map[string]string

type MCPType added in v0.4.0

type MCPType string
const (
	MCPStdio MCPType = "stdio"
	MCPSSE   MCPType = "sse"
	MCPHttp  MCPType = "http"
)

type MCPs added in v0.4.0

type MCPs map[string]MCPConfig

func (MCPs) Sorted added in v0.4.0

func (m MCPs) Sorted() []MCP

type Options added in v0.4.0

type Options struct {
	ContextPaths         []string    `` /* 151-byte string literal not displayed */
	SkillsPaths          []string    `` /* 178-byte string literal not displayed */
	TUI                  *TUIOptions `json:"tui,omitempty" jsonschema:"description=Terminal user interface options"`
	Debug                bool        `json:"debug,omitempty" jsonschema:"description=Enable debug logging,default=false"`
	DebugLSP             bool        `json:"debug_lsp,omitempty" jsonschema:"description=Enable debug logging for LSP servers,default=false"`
	DisableAutoSummarize bool        `json:"disable_auto_summarize,omitempty" jsonschema:"description=Disable automatic conversation summarization,default=false"`
	DataDirectory        string      `` // Relative to the cwd
	/* 159-byte string literal not displayed */
	DisabledTools             []string     `` /* 147-byte string literal not displayed */
	DisableProviderAutoUpdate bool         `json:"disable_provider_auto_update,omitempty" jsonschema:"description=Disable providers auto-update,default=false"`
	Attribution               *Attribution `json:"attribution,omitempty" jsonschema:"description=Attribution settings for generated content"`
	DisableMetrics            bool         `json:"disable_metrics,omitempty" jsonschema:"description=Disable sending metrics,default=false"`
	InitializeAs              string       `` /* 202-byte string literal not displayed */
}

type Permissions added in v0.4.0

type Permissions struct {
	AllowedTools []string `` // Tools that don't require permission prompts
	/* 133-byte string literal not displayed */
	SkipRequests bool `json:"-"` // Automatically accept all permissions (YOLO mode)
}

type ProjectInitFlag added in v0.4.0

type ProjectInitFlag struct {
	Initialized bool `json:"initialized"`
}

type ProviderConfig added in v0.4.0

type ProviderConfig struct {
	// The provider's id.
	ID string `json:"id,omitempty" jsonschema:"description=Unique identifier for the provider,example=openai"`
	// The provider's name, used for display purposes.
	Name string `json:"name,omitempty" jsonschema:"description=Human-readable name for the provider,example=OpenAI"`
	// The provider's API endpoint.
	BaseURL string `` /* 127-byte string literal not displayed */
	// The provider type, e.g. "openai", "anthropic", etc. if empty it defaults to openai.
	Type catwalk.Type `` /* 189-byte string literal not displayed */
	// The provider's API key.
	APIKey string `json:"api_key,omitempty" jsonschema:"description=API key for authentication with the provider,example=$OPENAI_API_KEY"`
	// The original API key template before resolution (for re-resolution on auth errors).
	APIKeyTemplate string `json:"-"`
	// OAuthToken for providers that use OAuth2 authentication.
	OAuthToken *oauth.Token `json:"oauth,omitempty" jsonschema:"description=OAuth2 token for authentication with the provider"`
	// Marks the provider as disabled.
	Disable bool `json:"disable,omitempty" jsonschema:"description=Whether this provider is disabled,default=false"`

	// Custom system prompt prefix.
	SystemPromptPrefix string `json:"system_prompt_prefix,omitempty" jsonschema:"description=Custom prefix to add to system prompts for this provider"`

	// Extra headers to send with each request to the provider.
	ExtraHeaders map[string]string `json:"extra_headers,omitempty" jsonschema:"description=Additional HTTP headers to send with requests"`
	// Extra body
	ExtraBody map[string]any `` /* 144-byte string literal not displayed */

	ProviderOptions map[string]any `json:"provider_options,omitempty" jsonschema:"description=Additional provider-specific options for this provider"`

	// Used to pass extra parameters to the provider.
	ExtraParams map[string]string `json:"-"`

	// The provider models
	Models []catwalk.Model `json:"models,omitempty" jsonschema:"description=List of models available from this provider"`
}

func (*ProviderConfig) SetupClaudeCode added in v0.4.0

func (pc *ProviderConfig) SetupClaudeCode()

func (*ProviderConfig) SetupGitHubCopilot added in v0.4.0

func (pc *ProviderConfig) SetupGitHubCopilot()

func (*ProviderConfig) TestConnection added in v0.4.0

func (c *ProviderConfig) TestConnection(resolver VariableResolver) error

func (*ProviderConfig) ToProvider added in v0.4.0

func (pc *ProviderConfig) ToProvider() catwalk.Provider

ToProvider converts the ProviderConfig to a catwalk.Provider.

type SelectedModel added in v0.4.0

type SelectedModel struct {
	// The model id as used by the provider API.
	// Required.
	Model string `json:"model" jsonschema:"required,description=The model ID as used by the provider API,example=gpt-4o"`
	// The model provider, same as the key/id used in the providers config.
	// Required.
	Provider string `` /* 129-byte string literal not displayed */

	// Only used by models that use the openai provider and need this set.
	ReasoningEffort string `` /* 146-byte string literal not displayed */

	// Used by anthropic models that can reason to indicate if the model should think.
	Think bool `json:"think,omitempty" jsonschema:"description=Enable thinking mode for Anthropic models that support reasoning"`

	// Overrides the default model configuration.
	MaxTokens        int64    `json:"max_tokens,omitempty" jsonschema:"description=Maximum number of tokens for model responses,maximum=200000,example=4096"`
	Temperature      *float64 `json:"temperature,omitempty" jsonschema:"description=Sampling temperature,minimum=0,maximum=1,example=0.7"`
	TopP             *float64 `json:"top_p,omitempty" jsonschema:"description=Top-p (nucleus) sampling parameter,minimum=0,maximum=1,example=0.9"`
	TopK             *int64   `json:"top_k,omitempty" jsonschema:"description=Top-k sampling parameter"`
	FrequencyPenalty *float64 `json:"frequency_penalty,omitempty" jsonschema:"description=Frequency penalty to reduce repetition"`
	PresencePenalty  *float64 `json:"presence_penalty,omitempty" jsonschema:"description=Presence penalty to increase topic diversity"`

	// Override provider specific options.
	ProviderOptions map[string]any `json:"provider_options,omitempty" jsonschema:"description=Additional provider-specific options for the model"`
}

type SelectedModelType added in v0.4.0

type SelectedModelType string
const (
	SelectedModelTypeLarge SelectedModelType = "large"
	SelectedModelTypeSmall SelectedModelType = "small"
)

type Shell added in v0.4.0

type Shell interface {
	Exec(ctx context.Context, command string) (stdout, stderr string, err error)
}

type TUIOptions added in v0.4.0

type TUIOptions struct {
	CompactMode bool   `json:"compact_mode,omitempty" jsonschema:"description=Enable compact mode for the TUI interface,default=false"`
	DiffMode    string `json:"diff_mode,omitempty" jsonschema:"description=Diff mode for the TUI interface,enum=unified,enum=split"`

	Completions Completions `json:"completions,omitzero" jsonschema:"description=Completions UI options"`
}

type ToolLs added in v0.4.0

type ToolLs struct {
	MaxDepth *int `json:"max_depth,omitempty" jsonschema:"description=Maximum depth for the ls tool,default=0,example=10"`
	MaxItems *int `` /* 126-byte string literal not displayed */
}

func (ToolLs) Limits added in v0.4.0

func (t ToolLs) Limits() (depth, items int)

type Tools added in v0.4.0

type Tools struct {
	Ls ToolLs `json:"ls,omitzero"`
}

type TrailerStyle added in v0.4.0

type TrailerStyle string
const (
	TrailerStyleNone         TrailerStyle = "none"
	TrailerStyleCoAuthoredBy TrailerStyle = "co-authored-by"
	TrailerStyleAssistedBy   TrailerStyle = "assisted-by"
)

type VariableResolver added in v0.4.0

type VariableResolver interface {
	ResolveValue(value string) (string, error)
}

func NewEnvironmentVariableResolver added in v0.4.0

func NewEnvironmentVariableResolver(env env.Env) VariableResolver

func NewShellVariableResolver added in v0.4.0

func NewShellVariableResolver(env env.Env) VariableResolver

Jump to

Keyboard shortcuts

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