|
|
7 месяцев назад | |
|---|---|---|
| .. | ||
| README.md | 7 месяцев назад | |
| main.go | 7 месяцев назад | |
This tool automatically generates a JSON Schema for the Crush configuration file by using Go reflection to analyze the configuration structs. The schema provides validation, autocompletion, and documentation for configuration files.
# Generate the schema
go run cmd/schema/main.go > crush-schema.json
# Or use the task runner
task schema
The generator:
config.Config struct and all related typesThe generated schema includes:
To add new configuration options:
internal/config/Example:
type Options struct {
// ... existing fields ...
// New field with JSON tag and description
NewFeature bool `json:"new_feature,omitempty"`
}
The schema generator will automatically:
Most modern editors support JSON Schema:
VS Code: Add to your workspace settings:
{
"json.schemas": [
{
"fileMatch": ["crush.json", ".crush.json"],
"url": "./crush-schema.json"
}
]
}
JetBrains IDEs: Configure in Settings → Languages & Frameworks → Schemas and DTDs → JSON Schema Mappings
# Using jsonschema (Python)
pip install jsonschema
jsonschema -i crush.json crush-schema.json
# Using ajv-cli (Node.js)
npm install -g ajv-cli
ajv validate -s crush-schema.json -d crush.json
{
"models": {
"large": {
"model_id": "claude-3-5-sonnet-20241022",
"provider": "anthropic",
"reasoning_effort": "medium",
"max_tokens": 8192
},
"small": {
"model_id": "claude-3-5-haiku-20241022",
"provider": "anthropic"
}
},
"providers": {
"anthropic": {
"id": "anthropic",
"provider_type": "anthropic",
"api_key": "your-api-key",
"disabled": false
}
},
"agents": {
"coder": {
"id": "coder",
"name": "Coder",
"model": "large",
"disabled": false
},
"custom-agent": {
"id": "custom-agent",
"name": "Custom Agent",
"description": "A custom agent for specific tasks",
"model": "small",
"allowed_tools": ["glob", "grep", "view"],
"allowed_mcp": {
"filesystem": ["read", "write"]
}
}
},
"mcp": {
"filesystem": {
"command": "mcp-filesystem",
"args": ["--root", "/workspace"],
"type": "stdio"
}
},
"lsp": {
"typescript": {
"command": "typescript-language-server",
"args": ["--stdio"],
"enabled": true
}
},
"options": {
"context_paths": [
"README.md",
"docs/",
".cursorrules"
],
"data_directory": ".crush",
"debug": false,
"tui": {
"compact_mode": false
}
}
}
The schema generator is designed to be maintenance-free. As long as:
The schema will stay current with the codebase automatically.