README.md

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