Skip to content

Commit 601d884

Browse files
committed
feat: add JSON Schema for config file autocomplete
Add dcp.schema.json with full schema for the DCP config file. Include $schema reference in default config template so new users get IDE autocomplete automatically. Closes #226
1 parent e1e0891 commit 601d884

File tree

2 files changed

+208
-0
lines changed

2 files changed

+208
-0
lines changed

dcp.schema.json

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "https://raw.githubusercontent.com/Opencode-DCP/opencode-dynamic-context-pruning/main/dcp.schema.json",
4+
"title": "DCP Plugin Configuration",
5+
"description": "Configuration schema for the OpenCode Dynamic Context Pruning plugin",
6+
"type": "object",
7+
"additionalProperties": false,
8+
"properties": {
9+
"$schema": {
10+
"type": "string",
11+
"description": "JSON Schema reference for IDE autocomplete"
12+
},
13+
"enabled": {
14+
"type": "boolean",
15+
"default": true,
16+
"description": "Enable or disable the DCP plugin"
17+
},
18+
"debug": {
19+
"type": "boolean",
20+
"default": false,
21+
"description": "Enable debug logging"
22+
},
23+
"pruneNotification": {
24+
"type": "string",
25+
"enum": ["off", "minimal", "detailed"],
26+
"default": "detailed",
27+
"description": "Level of notification shown when pruning occurs"
28+
},
29+
"turnProtection": {
30+
"type": "object",
31+
"description": "Protect recent tool outputs from being pruned",
32+
"additionalProperties": false,
33+
"properties": {
34+
"enabled": {
35+
"type": "boolean",
36+
"default": false,
37+
"description": "Enable turn-based protection"
38+
},
39+
"turns": {
40+
"type": "number",
41+
"default": 4,
42+
"description": "Number of recent turns to protect from pruning"
43+
}
44+
}
45+
},
46+
"protectedFilePatterns": {
47+
"type": "array",
48+
"items": {
49+
"type": "string"
50+
},
51+
"default": [],
52+
"description": "Glob patterns for files that should be protected from pruning (e.g., '**/*.config.ts')"
53+
},
54+
"tools": {
55+
"type": "object",
56+
"description": "Configuration for pruning tools",
57+
"additionalProperties": false,
58+
"properties": {
59+
"settings": {
60+
"type": "object",
61+
"description": "General tool settings",
62+
"additionalProperties": false,
63+
"properties": {
64+
"nudgeEnabled": {
65+
"type": "boolean",
66+
"default": true,
67+
"description": "Enable nudge reminders to prune context"
68+
},
69+
"nudgeFrequency": {
70+
"type": "number",
71+
"default": 10,
72+
"description": "Frequency of nudge reminders (in turns)"
73+
},
74+
"protectedTools": {
75+
"type": "array",
76+
"items": {
77+
"type": "string"
78+
},
79+
"default": [
80+
"task",
81+
"todowrite",
82+
"todoread",
83+
"discard",
84+
"extract",
85+
"batch",
86+
"write",
87+
"edit"
88+
],
89+
"description": "Tool names that should be protected from automatic pruning"
90+
}
91+
}
92+
},
93+
"discard": {
94+
"type": "object",
95+
"description": "Configuration for the discard tool",
96+
"additionalProperties": false,
97+
"properties": {
98+
"enabled": {
99+
"type": "boolean",
100+
"default": true,
101+
"description": "Enable the discard tool"
102+
}
103+
}
104+
},
105+
"extract": {
106+
"type": "object",
107+
"description": "Configuration for the extract tool",
108+
"additionalProperties": false,
109+
"properties": {
110+
"enabled": {
111+
"type": "boolean",
112+
"default": true,
113+
"description": "Enable the extract tool"
114+
},
115+
"showDistillation": {
116+
"type": "boolean",
117+
"default": false,
118+
"description": "Show distillation output in the UI"
119+
}
120+
}
121+
}
122+
}
123+
},
124+
"strategies": {
125+
"type": "object",
126+
"description": "Automatic pruning strategies",
127+
"additionalProperties": false,
128+
"properties": {
129+
"deduplication": {
130+
"type": "object",
131+
"description": "Remove duplicate tool outputs",
132+
"additionalProperties": false,
133+
"properties": {
134+
"enabled": {
135+
"type": "boolean",
136+
"default": true,
137+
"description": "Enable deduplication strategy"
138+
},
139+
"protectedTools": {
140+
"type": "array",
141+
"items": {
142+
"type": "string"
143+
},
144+
"default": [
145+
"task",
146+
"todowrite",
147+
"todoread",
148+
"discard",
149+
"extract",
150+
"batch",
151+
"write",
152+
"edit"
153+
],
154+
"description": "Tool names excluded from deduplication"
155+
}
156+
}
157+
},
158+
"supersedeWrites": {
159+
"type": "object",
160+
"description": "Replace older write/edit outputs when new ones target the same file",
161+
"additionalProperties": false,
162+
"properties": {
163+
"enabled": {
164+
"type": "boolean",
165+
"default": false,
166+
"description": "Enable supersede writes strategy"
167+
}
168+
}
169+
},
170+
"purgeErrors": {
171+
"type": "object",
172+
"description": "Remove tool outputs that resulted in errors",
173+
"additionalProperties": false,
174+
"properties": {
175+
"enabled": {
176+
"type": "boolean",
177+
"default": true,
178+
"description": "Enable purge errors strategy"
179+
},
180+
"turns": {
181+
"type": "number",
182+
"default": 4,
183+
"description": "Number of turns after which errors are purged"
184+
},
185+
"protectedTools": {
186+
"type": "array",
187+
"items": {
188+
"type": "string"
189+
},
190+
"default": [
191+
"task",
192+
"todowrite",
193+
"todoread",
194+
"discard",
195+
"extract",
196+
"batch",
197+
"write",
198+
"edit"
199+
],
200+
"description": "Tool names excluded from error purging"
201+
}
202+
}
203+
}
204+
}
205+
}
206+
}
207+
}

lib/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ function createDefaultConfig(): void {
488488
}
489489

490490
const configContent = `{
491+
"$schema": "https://raw.githubusercontent.com/Opencode-DCP/opencode-dynamic-context-pruning/main/dcp.schema.json",
491492
// Enable or disable the plugin
492493
"enabled": true,
493494
// Enable debug logging to ~/.config/opencode/logs/dcp/

0 commit comments

Comments
 (0)