From 99aabb0179cb65f46166b4add30156360afb0ba9 Mon Sep 17 00:00:00 2001 From: huaiyuWangh <34158348+huaiyuWangh@users.noreply.github.com> Date: Wed, 28 Jan 2026 03:30:09 +0800 Subject: [PATCH] fix: schema incorrectly marks optional fields as required (#1996) This fixes two schema validation issues: 1. tools.ls incorrectly marked as required - Changed Tools.Ls and Config.Tools from omitzero to omitempty - The invopop/jsonschema library doesn't recognize Go 1.25's omitzero tag 2. lsp.command incorrectly marked as required - Removed jsonschema:"required" tag from LSPConfig.Command - The project's own crush.json doesn't include command field for gopls After this fix, users can use minimal configurations without being forced to specify tools.ls or lsp.command fields. --- internal/config/config.go | 6 +++--- schema.json | 15 +++------------ 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index 510685325fa779c7f53842435049478efeb389fb..d18d2d9c61d2f791ab9c6f9a0b7cd41029b70e60 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -187,7 +187,7 @@ type MCPConfig struct { 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"` + Command string `json:"command,omitempty" jsonschema:"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 `json:"filetypes,omitempty" jsonschema:"description=File types this LSP server handles,example=go,example=mod,example=rs,example=c,example=js,example=ts"` @@ -347,7 +347,7 @@ type Agent struct { } type Tools struct { - Ls ToolLs `json:"ls,omitzero"` + Ls ToolLs `json:"ls,omitempty"` } type ToolLs struct { @@ -380,7 +380,7 @@ type Config struct { Permissions *Permissions `json:"permissions,omitempty" jsonschema:"description=Permission settings for tool usage"` - Tools Tools `json:"tools,omitzero" jsonschema:"description=Tool configurations"` + Tools Tools `json:"tools,omitempty" jsonschema:"description=Tool configurations"` Agents map[string]Agent `json:"-"` diff --git a/schema.json b/schema.json index 0d236265a09cf301553da812c67079323c9ea20a..47b19589f29cdf6165f0b5c93a97168e3396e6bd 100644 --- a/schema.json +++ b/schema.json @@ -92,10 +92,7 @@ } }, "additionalProperties": false, - "type": "object", - "required": [ - "tools" - ] + "type": "object" }, "LSPConfig": { "properties": { @@ -162,10 +159,7 @@ } }, "additionalProperties": false, - "type": "object", - "required": [ - "command" - ] + "type": "object" }, "LSPs": { "additionalProperties": { @@ -702,10 +696,7 @@ } }, "additionalProperties": false, - "type": "object", - "required": [ - "ls" - ] + "type": "object" } } }