fix: schema incorrectly marks optional fields as required (#1996)

huaiyuWangh created

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.

Change summary

internal/config/config.go |  6 +++---
schema.json               | 15 +++------------
2 files changed, 6 insertions(+), 15 deletions(-)

Detailed changes

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:"-"`
 

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"
     }
   }
 }