diff --git a/.gitattributes b/.gitattributes index d5273520ad5ecc37dd839a3077803b2c6581b2a1..6d364901268bb606a4b4bece3820294279894467 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ *.golden linguist-generated=true -text +.github/crush-schema.json linguist-generated=true diff --git a/.github/workflows/schema-update.yml b/.github/workflows/schema-update.yml new file mode 100644 index 0000000000000000000000000000000000000000..4694981718b98b7d651b56f4be9edd63393d9e4c --- /dev/null +++ b/.github/workflows/schema-update.yml @@ -0,0 +1,26 @@ +name: Update Schema + +on: + push: + branches: [main] + paths: + - "internal/config/**" + +jobs: + update-schema: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + - run: go run . schema > ./schema.json + - uses: stefanzweifel/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0 # v5 + with: + commit_message: "chore: auto-update generated files" + branch: main + commit_user_name: actions-user + commit_user_email: actions@github.com + commit_author: actions-user diff --git a/README.md b/README.md index ed10695741292e2e61f516c120d6aeef24ffbbad..def4746e289e99feee2b61c3470592ac34f77e7d 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,7 @@ like you would. LSPs can be added manually like so: ```json { + "$schema": "https://charm.land/crush.json", "lsp": { "go": { "command": "gopls" @@ -163,6 +164,7 @@ using `$(echo $VAR)` syntax. ```json { + "$schema": "https://charm.land/crush.json", "mcp": { "filesystem": { "type": "stdio", @@ -198,6 +200,7 @@ permissions. Use this with care. ```json { + "$schema": "https://charm.land/crush.json", "permissions": { "allowed_tools": [ "view", @@ -225,6 +228,7 @@ API. Don't forget to set `DEEPSEEK_API_KEY` in your environment. ```json { + "$schema": "https://charm.land/crush.json", "providers": { "deepseek": { "type": "openai", @@ -253,6 +257,7 @@ Custom Anthropic-compatible providers follow this format: ```json { + "$schema": "https://charm.land/crush.json", "providers": { "custom-anthropic": { "type": "anthropic", @@ -303,6 +308,7 @@ config: ```json { + "$schema": "https://charm.land/crush.json", "options": { "debug": true, "debug_lsp": true diff --git a/crush.json b/crush.json index 1b04ea6c24f8b64a3a12ceb47551f3177fa66302..ba4dc18bc63381ad4bdbca5470a1527986c74205 100644 --- a/crush.json +++ b/crush.json @@ -1,4 +1,5 @@ { + "$schema": "https://charm.land/crush.json", "lsp": { "Go": { "command": "gopls" diff --git a/go.mod b/go.mod index 528f03f421461c3f37e2884ce4ffbb6dd185134b..e59a663b839b01629c6b9517f0f0eff49748f5a4 100644 --- a/go.mod +++ b/go.mod @@ -25,6 +25,7 @@ require ( github.com/disintegration/imageorient v0.0.0-20180920195336-8147d86e83ec github.com/fsnotify/fsnotify v1.9.0 github.com/google/uuid v1.6.0 + github.com/invopop/jsonschema v0.13.0 github.com/joho/godotenv v1.5.1 github.com/mark3labs/mcp-go v0.34.0 github.com/muesli/termenv v0.16.0 @@ -47,7 +48,13 @@ require ( mvdan.cc/sh/v3 v3.12.1-0.20250726150758-e256f53bade8 ) -require golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect +require ( + github.com/bahlo/generic-list-go v0.2.0 // indirect + github.com/buger/jsonparser v1.1.1 // indirect + github.com/mailru/easyjson v0.7.7 // indirect + github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect + golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect +) require ( cloud.google.com/go v0.116.0 // indirect diff --git a/go.sum b/go.sum index 9d1238d2f54032218f266a8858888c721127daf2..86e5c230b0a8ab848c79039af97351c909604edb 100644 --- a/go.sum +++ b/go.sum @@ -64,8 +64,12 @@ github.com/aymanbagabas/go-udiff v0.3.1 h1:LV+qyBQ2pqe0u42ZsUEtPiCaUoqgA9gYRDs3v github.com/aymanbagabas/go-udiff v0.3.1/go.mod h1:G0fsKmG+P6ylD0r6N/KgQD/nWzgfnl8ZBcNLgcbrw8E= github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= +github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk= +github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= github.com/bmatcuk/doublestar/v4 v4.9.0 h1:DBvuZxjdKkRP/dr4GVV4w2fnmrk5Hxc90T51LZjv0JA= github.com/bmatcuk/doublestar/v4 v4.9.0/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= +github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= +github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= github.com/charlievieth/fastwalk v1.0.11 h1:5sLT/q9+d9xMdpKExawLppqvXFZCVKf6JHnr2u/ufj8= github.com/charlievieth/fastwalk v1.0.11/go.mod h1:yGy1zbxog41ZVMcKA/i8ojXLFsuayX5VvwhQVoj9PBI= github.com/charmbracelet/bubbles/v2 v2.0.0-beta.1.0.20250716191546-1e2ffbbcf5c5 h1:GTcMIfDQJKyNKS+xVt7GkNIwz+tBuQtIuiP50WpzNgs= @@ -154,8 +158,11 @@ github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUq github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/invopop/jsonschema v0.13.0 h1:KvpoAJWEjR3uD9Kbm2HWJmqsEaHt8lBUpd0qHcIi21E= +github.com/invopop/jsonschema v0.13.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -169,6 +176,8 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0 github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mark3labs/mcp-go v0.34.0 h1:eWy7WBGvhk6EyAAyVzivTCprE52iXJwNtvHV6Cv3bR0= github.com/mark3labs/mcp-go v0.34.0/go.mod h1:rXqOudj/djTORU/ThxYx8fqEVj/5pvTuuebQ2RC7uk4= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= @@ -263,6 +272,8 @@ github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= github.com/u-root/u-root v0.14.1-0.20250724181933-b01901710169 h1:f4cp2yGKkMuGpCwAyNEjzcw8szgVXmemK/wfOu4l5gc= github.com/u-root/u-root v0.14.1-0.20250724181933-b01901710169/go.mod h1:/0Qr7qJeDwWxoKku2xKQ4Szc+SwBE3g9VE8jNiamsmc= +github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc= +github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw= github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4= diff --git a/internal/cmd/schema.go b/internal/cmd/schema.go new file mode 100644 index 0000000000000000000000000000000000000000..f835e250c24ea91a9d5084c9a414ed0e1ae28474 --- /dev/null +++ b/internal/cmd/schema.go @@ -0,0 +1,30 @@ +package cmd + +import ( + "encoding/json" + "fmt" + + "github.com/charmbracelet/crush/internal/config" + "github.com/invopop/jsonschema" + "github.com/spf13/cobra" +) + +var schemaCmd = &cobra.Command{ + Use: "schema", + Short: "Generate JSON schema for configuration", + Long: "Generate JSON schema for the crush configuration file", + Hidden: true, + RunE: func(cmd *cobra.Command, args []string) error { + reflector := new(jsonschema.Reflector) + bts, err := json.MarshalIndent(reflector.Reflect(&config.Config{}), "", " ") + if err != nil { + return fmt.Errorf("failed to marshal schema: %w", err) + } + fmt.Println(string(bts)) + return nil + }, +} + +func init() { + rootCmd.AddCommand(schemaCmd) +} diff --git a/internal/config/config.go b/internal/config/config.go index 1307d3b2bab9d3b22855409dae40ea1177e90664..d029469418b4394ddcbc80c834d9f748ccc64fb1 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -49,48 +49,48 @@ const ( type SelectedModel struct { // The model id as used by the provider API. // Required. - Model string `json:"model"` + 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 `json:"provider"` + Provider string `json:"provider" jsonschema:"required,description=The model provider ID that matches a key in the providers config,example=openai"` // Only used by models that use the openai provider and need this set. - ReasoningEffort string `json:"reasoning_effort,omitempty"` + ReasoningEffort string `json:"reasoning_effort,omitempty" jsonschema:"description=Reasoning effort level for OpenAI models that support it,enum=low,enum=medium,enum=high"` // Overrides the default model configuration. - MaxTokens int64 `json:"max_tokens,omitempty"` + MaxTokens int64 `json:"max_tokens,omitempty" jsonschema:"description=Maximum number of tokens for model responses,minimum=1,maximum=200000,example=4096"` // Used by anthropic models that can reason to indicate if the model should think. - Think bool `json:"think,omitempty"` + Think bool `json:"think,omitempty" jsonschema:"description=Enable thinking mode for Anthropic models that support reasoning"` } type ProviderConfig struct { // The provider's id. - ID string `json:"id,omitempty"` + 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"` + Name string `json:"name,omitempty" jsonschema:"description=Human-readable name for the provider,example=OpenAI"` // The provider's API endpoint. - BaseURL string `json:"base_url,omitempty"` + BaseURL string `json:"base_url,omitempty" jsonschema:"description=Base URL for the provider's API,format=uri,example=https://api.openai.com/v1"` // The provider type, e.g. "openai", "anthropic", etc. if empty it defaults to openai. - Type catwalk.Type `json:"type,omitempty"` + Type catwalk.Type `json:"type,omitempty" jsonschema:"description=Provider type that determines the API format,enum=openai,enum=anthropic,enum=gemini,enum=azure,enum=vertexai,default=openai"` // The provider's API key. - APIKey string `json:"api_key,omitempty"` + APIKey string `json:"api_key,omitempty" jsonschema:"description=API key for authentication with the provider,example=$OPENAI_API_KEY"` // Marks the provider as disabled. - Disable bool `json:"disable,omitempty"` + 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"` + 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"` + ExtraHeaders map[string]string `json:"extra_headers,omitempty" jsonschema:"description=Additional HTTP headers to send with requests"` // Extra body - ExtraBody map[string]any `json:"extra_body,omitempty"` + ExtraBody map[string]any `json:"extra_body,omitempty" jsonschema:"description=Additional fields to include in request bodies"` // Used to pass extra parameters to the provider. ExtraParams map[string]string `json:"-"` // The provider models - Models []catwalk.Model `json:"models,omitempty"` + Models []catwalk.Model `json:"models,omitempty" jsonschema:"description=List of models available from this provider"` } type MCPType string @@ -102,41 +102,41 @@ const ( ) type MCPConfig struct { - Command string `json:"command,omitempty" ` - Env map[string]string `json:"env,omitempty"` - Args []string `json:"args,omitempty"` - Type MCPType `json:"type"` - URL string `json:"url,omitempty"` - Disabled bool `json:"disabled,omitempty"` + 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"` // TODO: maybe make it possible to get the value from the env - Headers map[string]string `json:"headers,omitempty"` + Headers map[string]string `json:"headers,omitempty" jsonschema:"description=HTTP headers for HTTP/SSE MCP servers"` } type LSPConfig struct { - Disabled bool `json:"enabled,omitempty"` - Command string `json:"command"` - Args []string `json:"args,omitempty"` - Options any `json:"options,omitempty"` + Disabled bool `json:"enabled,omitempty" jsonschema:"description=Whether this LSP server is disabled,default=false"` + Command string `json:"command" 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"` + Options any `json:"options,omitempty" jsonschema:"description=LSP server-specific configuration options"` } type TUIOptions struct { - CompactMode bool `json:"compact_mode,omitempty"` + CompactMode bool `json:"compact_mode,omitempty" jsonschema:"description=Enable compact mode for the TUI interface,default=false"` // Here we can add themes later or any TUI related options } type Permissions struct { - AllowedTools []string `json:"allowed_tools,omitempty"` // Tools that don't require permission prompts - SkipRequests bool `json:"-"` // Automatically accept all permissions (YOLO mode) + AllowedTools []string `json:"allowed_tools,omitempty" jsonschema:"description=List of tools that don't require permission prompts,example=bash,example=view"` // Tools that don't require permission prompts + SkipRequests bool `json:"-"` // Automatically accept all permissions (YOLO mode) } type Options struct { - ContextPaths []string `json:"context_paths,omitempty"` - TUI *TUIOptions `json:"tui,omitempty"` - Debug bool `json:"debug,omitempty"` - DebugLSP bool `json:"debug_lsp,omitempty"` - DisableAutoSummarize bool `json:"disable_auto_summarize,omitempty"` - DataDirectory string `json:"data_directory,omitempty"` // Relative to the cwd + ContextPaths []string `json:"context_paths,omitempty" jsonschema:"description=Paths to files containing context information for the AI,example=.cursorrules,example=CRUSH.md"` + 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 `json:"data_directory,omitempty" jsonschema:"description=Directory for storing application data (relative to working directory),default=.crush,example=.crush"` // Relative to the cwd } type MCPs map[string]MCPConfig @@ -219,7 +219,7 @@ type Agent struct { // This is the id of the system prompt used by the agent Disabled bool `json:"disabled,omitempty"` - Model SelectedModelType `json:"model"` + 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 @@ -242,18 +242,18 @@ type Agent struct { // Config holds the configuration for crush. type Config struct { // We currently only support large/small as values here. - Models map[SelectedModelType]SelectedModel `json:"models,omitempty"` + Models map[SelectedModelType]SelectedModel `json:"models,omitempty" jsonschema:"description=Model configurations for different model types,example={\"large\":{\"model\":\"gpt-4o\",\"provider\":\"openai\"}}"` // The providers that are configured - Providers *csync.Map[string, ProviderConfig] `json:"providers,omitempty"` + Providers *csync.Map[string, ProviderConfig] `json:"providers,omitempty" jsonschema:"description=AI provider configurations"` - MCP MCPs `json:"mcp,omitempty"` + MCP MCPs `json:"mcp,omitempty" jsonschema:"description=Model Context Protocol server configurations"` - LSP LSPs `json:"lsp,omitempty"` + LSP LSPs `json:"lsp,omitempty" jsonschema:"description=Language Server Protocol configurations"` - Options *Options `json:"options,omitempty"` + Options *Options `json:"options,omitempty" jsonschema:"description=General application options"` - Permissions *Permissions `json:"permissions,omitempty"` + Permissions *Permissions `json:"permissions,omitempty" jsonschema:"description=Permission settings for tool usage"` // Internal workingDir string `json:"-"` diff --git a/internal/csync/maps.go b/internal/csync/maps.go index 108c8a4cbb6f855687d6117b1764b85e27279bc9..67796baff9f68b2a02382de625de70b78e204f4a 100644 --- a/internal/csync/maps.go +++ b/internal/csync/maps.go @@ -96,6 +96,11 @@ var ( _ json.Marshaler = &Map[string, any]{} ) +func (Map[K, V]) JSONSchemaAlias() any { //nolint + m := map[K]V{} + return m +} + // UnmarshalJSON implements json.Unmarshaler. func (m *Map[K, V]) UnmarshalJSON(data []byte) error { m.mu.Lock() diff --git a/schema.json b/schema.json new file mode 100644 index 0000000000000000000000000000000000000000..05dcc56c573405c6e4c3eb67762dd7ffd2d38ad7 --- /dev/null +++ b/schema.json @@ -0,0 +1,393 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://github.com/charmbracelet/crush/internal/config/config", + "$ref": "#/$defs/Config", + "$defs": { + "Config": { + "properties": { + "models": { + "additionalProperties": { + "$ref": "#/$defs/SelectedModel" + }, + "type": "object", + "description": "Model configurations for different model types" + }, + "providers": { + "additionalProperties": { + "$ref": "#/$defs/ProviderConfig" + }, + "type": "object", + "description": "AI provider configurations" + }, + "mcp": { + "$ref": "#/$defs/MCPs", + "description": "Model Context Protocol server configurations" + }, + "lsp": { + "$ref": "#/$defs/LSPs", + "description": "Language Server Protocol configurations" + }, + "options": { + "$ref": "#/$defs/Options", + "description": "General application options" + }, + "permissions": { + "$ref": "#/$defs/Permissions", + "description": "Permission settings for tool usage" + } + }, + "additionalProperties": false, + "type": "object" + }, + "LSPConfig": { + "properties": { + "enabled": { + "type": "boolean", + "description": "Whether this LSP server is disabled", + "default": false + }, + "command": { + "type": "string", + "description": "Command to execute for the LSP server", + "examples": [ + "gopls" + ] + }, + "args": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Arguments to pass to the LSP server command" + }, + "options": { + "description": "LSP server-specific configuration options" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "command" + ] + }, + "LSPs": { + "additionalProperties": { + "$ref": "#/$defs/LSPConfig" + }, + "type": "object" + }, + "MCPConfig": { + "properties": { + "command": { + "type": "string", + "description": "Command to execute for stdio MCP servers", + "examples": [ + "npx" + ] + }, + "env": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "description": "Environment variables to set for the MCP server" + }, + "args": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Arguments to pass to the MCP server command" + }, + "type": { + "type": "string", + "enum": [ + "stdio", + "sse", + "http" + ], + "description": "Type of MCP connection", + "default": "stdio" + }, + "url": { + "type": "string", + "format": "uri", + "description": "URL for HTTP or SSE MCP servers", + "examples": [ + "http://localhost:3000/mcp" + ] + }, + "disabled": { + "type": "boolean", + "description": "Whether this MCP server is disabled", + "default": false + }, + "headers": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "description": "HTTP headers for HTTP/SSE MCP servers" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "type" + ] + }, + "MCPs": { + "additionalProperties": { + "$ref": "#/$defs/MCPConfig" + }, + "type": "object" + }, + "Model": { + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "cost_per_1m_in": { + "type": "number" + }, + "cost_per_1m_out": { + "type": "number" + }, + "cost_per_1m_in_cached": { + "type": "number" + }, + "cost_per_1m_out_cached": { + "type": "number" + }, + "context_window": { + "type": "integer" + }, + "default_max_tokens": { + "type": "integer" + }, + "can_reason": { + "type": "boolean" + }, + "has_reasoning_efforts": { + "type": "boolean" + }, + "default_reasoning_effort": { + "type": "string" + }, + "supports_attachments": { + "type": "boolean" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "id", + "name", + "cost_per_1m_in", + "cost_per_1m_out", + "cost_per_1m_in_cached", + "cost_per_1m_out_cached", + "context_window", + "default_max_tokens", + "can_reason", + "has_reasoning_efforts", + "supports_attachments" + ] + }, + "Options": { + "properties": { + "context_paths": { + "items": { + "type": "string", + "examples": [ + ".cursorrules", + "CRUSH.md" + ] + }, + "type": "array", + "description": "Paths to files containing context information for the AI" + }, + "tui": { + "$ref": "#/$defs/TUIOptions", + "description": "Terminal user interface options" + }, + "debug": { + "type": "boolean", + "description": "Enable debug logging", + "default": false + }, + "debug_lsp": { + "type": "boolean", + "description": "Enable debug logging for LSP servers", + "default": false + }, + "disable_auto_summarize": { + "type": "boolean", + "description": "Disable automatic conversation summarization", + "default": false + }, + "data_directory": { + "type": "string", + "description": "Directory for storing application data (relative to working directory)", + "default": ".crush", + "examples": [ + ".crush" + ] + } + }, + "additionalProperties": false, + "type": "object" + }, + "Permissions": { + "properties": { + "allowed_tools": { + "items": { + "type": "string", + "examples": [ + "bash", + "view" + ] + }, + "type": "array", + "description": "List of tools that don't require permission prompts" + } + }, + "additionalProperties": false, + "type": "object" + }, + "ProviderConfig": { + "properties": { + "id": { + "type": "string", + "description": "Unique identifier for the provider", + "examples": [ + "openai" + ] + }, + "name": { + "type": "string", + "description": "Human-readable name for the provider", + "examples": [ + "OpenAI" + ] + }, + "base_url": { + "type": "string", + "format": "uri", + "description": "Base URL for the provider's API", + "examples": [ + "https://api.openai.com/v1" + ] + }, + "type": { + "type": "string", + "enum": [ + "openai", + "anthropic", + "gemini", + "azure", + "vertexai" + ], + "description": "Provider type that determines the API format", + "default": "openai" + }, + "api_key": { + "type": "string", + "description": "API key for authentication with the provider", + "examples": [ + "$OPENAI_API_KEY" + ] + }, + "disable": { + "type": "boolean", + "description": "Whether this provider is disabled", + "default": false + }, + "system_prompt_prefix": { + "type": "string", + "description": "Custom prefix to add to system prompts for this provider" + }, + "extra_headers": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "description": "Additional HTTP headers to send with requests" + }, + "extra_body": { + "type": "object", + "description": "Additional fields to include in request bodies" + }, + "models": { + "items": { + "$ref": "#/$defs/Model" + }, + "type": "array", + "description": "List of models available from this provider" + } + }, + "additionalProperties": false, + "type": "object" + }, + "SelectedModel": { + "properties": { + "model": { + "type": "string", + "description": "The model ID as used by the provider API", + "examples": [ + "gpt-4o" + ] + }, + "provider": { + "type": "string", + "description": "The model provider ID that matches a key in the providers config", + "examples": [ + "openai" + ] + }, + "reasoning_effort": { + "type": "string", + "enum": [ + "low", + "medium", + "high" + ], + "description": "Reasoning effort level for OpenAI models that support it" + }, + "max_tokens": { + "type": "integer", + "maximum": 200000, + "minimum": 1, + "description": "Maximum number of tokens for model responses", + "examples": [ + 4096 + ] + }, + "think": { + "type": "boolean", + "description": "Enable thinking mode for Anthropic models that support reasoning" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "model", + "provider" + ] + }, + "TUIOptions": { + "properties": { + "compact_mode": { + "type": "boolean", + "description": "Enable compact mode for the TUI interface", + "default": false + } + }, + "additionalProperties": false, + "type": "object" + } + } +}