1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# OpenCode Configuration Schema Generator
This tool generates a JSON Schema for the OpenCode configuration file. The schema can be used to validate configuration files and provide autocompletion in editors that support JSON Schema.
## Usage
```bash
go run cmd/schema/main.go > opencode-schema.json
```
This will generate a JSON Schema file that can be used to validate configuration files.
## Schema Features
The generated schema includes:
- All configuration options with descriptions
- Default values where applicable
- Validation for enum values (e.g., model IDs, provider types)
- Required fields
- Type checking
## Using the Schema
You can use the generated schema in several ways:
1. **Editor Integration**: Many editors (VS Code, JetBrains IDEs, etc.) support JSON Schema for validation and autocompletion. You can configure your editor to use the generated schema for `.opencode.json` files.
2. **Validation Tools**: You can use tools like [jsonschema](https://github.com/Julian/jsonschema) to validate your configuration files against the schema.
3. **Documentation**: The schema serves as documentation for the configuration options.
## Example Configuration
Here's an example configuration that conforms to the schema:
```json
{
"data": {
"directory": ".opencode"
},
"debug": false,
"providers": {
"anthropic": {
"apiKey": "your-api-key"
}
},
"agents": {
"primary": {
"model": "claude-3.7-sonnet",
"maxTokens": 5000,
"reasoningEffort": "medium"
},
"task": {
"model": "claude-3.7-sonnet",
"maxTokens": 5000
},
"title": {
"model": "claude-3.7-sonnet",
"maxTokens": 80
}
}
}
```
|