Repository navigation
Expand file tree
/
Copy pathopencode.jsonc
More file actions
284 lines (284 loc) · 8.11 KB
/
Copy pathopencode.jsonc
File metadata and controls
284 lines (284 loc) · 8.11 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
{
// OpenCode Configuration for SBX + USAi
//
// INSTRUCTIONS:
// 1. Copy this file to your project root as `opencode.jsonc`
// 2. Customize the models list based on your USAi API key entitlements
// 3. Update the default model if needed
// 4. Set up your USAi API key as a SBX secret before the first run:
// sbx secret set-custom -g --host api.gsa.usai.gov --env USAI_API_KEY --value <your_api_key>
// 5. Run with: sbx run opencode .
//
// IMPORTANT: This file contains NO secrets.
// API key is injected via USAI_API_KEY secret.
"$schema": "https://opencode.ai/config.json",
"enabled_providers": [
"usai"
],
"provider": {
"usai": {
"npm": "@ai-sdk/openai-compatible",
"name": "GSA USAI",
"options": {
"baseURL": "https://api.gsa.usai.gov/api/v1",
"apiKey": "{env:USAI_API_KEY}",
"timeout": 3600000, // 1 hour, for long-running tasks
"headers": {
"User-Agent": "OpenCode-USAI/1.0"
}
},
"models": {
"claude_4_5_opus": {
"name": "Claude 4.5 Opus",
"limit": {
"context": 200000,
"output": 32768
}
},
"claude_4_5_sonnet": {
"name": "Claude 4.5 Sonnet",
"limit": {
"context": 200000,
"output": 32768
}
},
"claude_3_5_haiku": {
"name": "Claude 3.5 Haiku",
"limit": {
"context": 200000,
"output": 8192
}
},
"gpt-5.4-latest-guardrails-defaultv2": {
"name": "GPT-5.4 Latest — Guardrails Default v2",
"limit": {
"context": 400000,
"output": 32768
}
},
"gpt-5.2-latest-guardrails-defaultv2": {
"name": "GPT-5.2 Latest — Guardrails Default v2",
"limit": {
"context": 400000,
"output": 32768
}
},
"gemini-2.5-pro": {
"name": "Gemini 2.5 Pro",
"limit": {
"context": 1048576,
"output": 65536
}
},
"gemini-2.5-flash": {
"name": "Gemini 2.5 Flash",
"limit": {
"context": 1048576,
"output": 65536
}
},
"gemini-2.5-flash-lite": {
"name": "Gemini 2.5 Flash Lite",
"limit": {
"context": 1048576,
"output": 32768
}
},
"llama_4_maverick": {
"name": "Llama 4 Maverick",
"limit": {
"context": 128000,
"output": 16384
}
},
"cohere_english_v3": {
"name": "Cohere English v3",
"limit": {
"context": 128000,
"output": 8192
}
}
// Intentionally omitted:
// "text-embedding-005"
//
// That model appears to be an embedding model, not a chat/coding model.
// Add it only if OpenCode/USAI exposes a separate embedding-model config path.
}
}
},
// Main coding model.
"model": "usai/claude_4_5_sonnet",
// Lightweight model for small OpenCode tasks such as title generation.
"small_model": "usai/claude_3_5_haiku",
"agent": {
"compaction": {
// GPT-5.2 is a strong choice for context compaction.
"model": "usai/gpt-5.2-latest-guardrails-defaultv2"
}
},
"compaction": {
"auto": true,
"prune": true,
"reserved": 10000
},
"instructions": [
"AGENTS.md",
"CLAUDE.md",
"CONTRIBUTING.md",
".cursor/rules/*.md",
".github/copilot-instructions.md"
],
"permission": {
// Conservative default: anything not explicitly handled asks first.
"*": "ask",
// Read permissions.
//
// OpenCode already denies .env-style files by default, but keeping these
// rules explicit makes the policy clear and portable.
//
// Rule order matters: OpenCode uses "last matching rule wins", so examples
// must come after broader deny rules.
"read": {
"*": "allow",
".env": "deny",
".env.*": "deny",
"*.env": "deny",
"*.env.*": "deny",
"*.pem": "deny",
"*.key": "deny",
"*.p12": "deny",
"*.pfx": "deny",
"*id_rsa*": "deny",
"*id_ed25519*": "deny",
"*.tfvars": "deny",
"*.tfvars.json": "deny",
".env.example": "allow",
"*.env.example": "allow",
"*.tfvars.example": "allow"
},
// File modification.
//
// OpenCode controls edit, write, and apply_patch through the edit permission.
// Keep this as ask so the agent can propose changes but not silently modify files.
"edit": "ask",
// Workspace discovery and code intelligence.
"glob": "allow",
"grep": "allow",
// LSP is experimental in OpenCode and only active when the related
// experimental environment flag is enabled. Safe enough to allow.
"lsp": "allow",
// Todo tracking is useful for multi-step coding tasks and does not mutate
// the project workspace.
"todowrite": "allow",
// Let the agent ask structured clarification questions during a task.
"question": "allow",
// Skills can inject additional instructions. Useful, but keep gated because
// skills are effectively prompt/runtime behavior extensions.
"skill": "ask",
// Subagents can do substantial work. Keep gated unless you later define
// specific trusted subagents with narrower permissions.
"task": "ask",
// Web tools.
//
// webfetch retrieves a specific URL. websearch performs discovery through
// OpenCode's search integration, so keep search gated by default.
"webfetch": "allow",
"websearch": "ask",
// Safety guards.
"external_directory": "ask",
"doom_loop": "ask",
// Shell command policy:
// - allow low-risk inspection
// - ask for mutating, installing, testing, or network shell commands
// - deny obvious foot-guns and privilege/remote-access paths
"bash": {
"*": "ask",
// Basic inspection.
"pwd": "allow",
"ls": "allow",
"ls *": "allow",
"tree": "allow",
"tree *": "allow",
// Search/read-only discovery.
"rg": "allow",
"rg *": "allow",
"grep": "allow",
"grep *": "allow",
// Keep find gated. It can run -exec, traverse unexpected paths, or delete files.
"find": "ask",
"find *": "ask",
// Git read-only operations.
"git status": "allow",
"git status *": "allow",
"git diff": "allow",
"git diff *": "allow",
"git log": "allow",
"git log *": "allow",
"git show": "allow",
"git show *": "allow",
"git branch": "allow",
"git branch *": "allow",
// Git state-changing or remote operations.
"git checkout *": "ask",
"git switch *": "ask",
"git add *": "ask",
"git commit *": "ask",
"git push *": "ask",
"git pull *": "ask",
"git fetch *": "ask",
"git merge *": "ask",
"git rebase *": "ask",
"git reset *": "ask",
"git clean": "deny",
"git clean *": "deny",
// Language/package/test commands.
"uv *": "ask",
"python *": "ask",
"pytest *": "ask",
"npm *": "ask",
"pnpm *": "ask",
"bun *": "ask",
"go test *": "ask",
"cargo test *": "ask",
// Shell-based network access should stay gated.
"curl *": "ask",
"wget *": "ask",
// Destructive / privilege / remote access.
"rm": "deny",
"rm *": "deny",
"rmdir": "deny",
"rmdir *": "deny",
"mv *": "ask",
"cp *": "ask",
"chmod *": "ask",
"chown": "deny",
"chown *": "deny",
"sudo": "deny",
"sudo *": "deny",
"su": "deny",
"su *": "deny",
"ssh": "deny",
"ssh *": "deny",
"scp *": "deny",
"sftp *": "deny",
"rsync *": "ask"
}
},
"watcher": {
"ignore": [
".git/**",
"node_modules/**",
"dist/**",
"build/**",
".next/**",
".cache/**",
".venv/**",
"venv/**",
"__pycache__/**",
".pytest_cache/**",
".mypy_cache/**",
".ruff_cache/**",
"coverage/**"
]
}
}