-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopencode.jsonc
More file actions
174 lines (160 loc) · 7.6 KB
/
opencode.jsonc
File metadata and controls
174 lines (160 loc) · 7.6 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
{
"$schema": "https://opencode.ai/config.json",
// ── Instructions ──────────────────────────────────────────────────────────
// AGENTS.md loads Python project standards into every session.
// shell_strategy.md teaches agents to use non-interactive shell flags —
// uv-aware Python commands, bun-first frontend commands, no bare python/pip.
"instructions": ["./AGENTS.md", "./plugins/shell-strategy/shell_strategy.md"],
// ── LSP ───────────────────────────────────────────────────────────────────
// All LSP servers are auto-detected — no explicit configuration needed.
// pyright: auto-starts when pyright is installed as a project dependency
// typescript: auto-starts when typescript is a project dependency
// Both find the correct venv / tsconfig automatically from the project root.
// To disable a specific server: "lsp": { "pyright": { "disabled": true } }
// ── MCP Servers ───────────────────────────────────────────────────────────
// postgres is the only MCP server. It is spawned on demand by OpenCode as
// a local stdio process — no manual start/stop required.
// Disabled globally via "tools" below and re-enabled only on the db agent.
//
// Connection credentials are set per-project in a local opencode.json (git-ignored):
// {
// "mcp": {
// "postgres": {
// "type": "local",
// "command": ["uvx", "postgres-mcp", "--access-mode=unrestricted"],
// "environment": { "DATABASE_URI": "postgresql://..." }
// }
// }
// }
// NOTE: type + command are required by the schema — a partial environment-only
// override is not valid. The full server definition must be repeated.
"mcp": {
// postgres (crystaldba/postgres-mcp) ───────────────────────────────────
// Full-featured PostgreSQL MCP: schema discovery, SQL execution,
// EXPLAIN analysis, slow query detection, index recommendations,
// and DB health checks.
//
// Spawned automatically by OpenCode when the db agent is active.
// Reads DATABASE_URI from the project-level opencode.json (git-ignored).
//
// --access-mode=unrestricted allows EXPLAIN ANALYZE and advisory queries
// in addition to read-only SELECT statements.
"postgres": {
"type": "local",
"command": ["uvx", "postgres-mcp", "--access-mode=unrestricted"],
"enabled": true,
"environment": {
"DATABASE_URI": "{env:DATABASE_URI}",
},
},
},
// ── Formatters ────────────────────────────────────────────────────────────
// Built-in ruff and uv formatters are disabled — replaced by the three-step
// pipeline script that mirrors conform.nvim's exact sequence:
// ruff check --fix → ruff format → ruff check --select I --fix
// This ensures every Python file OpenCode touches comes out identical to
// what conform produces on save in Neovim.
"formatter": {
// Disable built-in Python formatters to prevent conflicts with the pipeline
"ruff": { "disabled": true },
"uv": { "disabled": true },
// Python: three-step pipeline (ruff_fix + ruff_format + ruff_organize_imports)
// Path uses {env:HOME} so it resolves correctly once deployed to ~/.config/opencode/
"ruff-pipeline": {
"command": [
"{env:HOME}/.config/opencode/scripts/ruff-format.sh",
"$FILE",
],
"extensions": [".py", ".pyi"],
},
// Lua: stylua with settings matching dotfiles/nvim stylua.toml
// (2-space indent, 120 col width)
"stylua": {
"command": [
"stylua",
"--indent-type",
"Spaces",
"--indent-width",
"2",
"--column-width",
"120",
"$FILE",
],
"extensions": [".lua"],
},
// Markdown: prettier via npx — no package.json required.
// --prose-wrap preserve prevents reflowing manually-wrapped prose paragraphs
// (important for AGENTS.md, READMEs, and exported session markdown).
"prettier-md": {
"command": [
"npx",
"--yes",
"prettier",
"--prose-wrap",
"preserve",
"--write",
"$FILE",
],
"extensions": [".md", ".mdx"],
},
// JS/TS/JSX/TSX/CSS/HTML — prettier fallback for frontend files.
// biome auto-overrides these per-project when biome.json is present
// (OpenCode's built-in biome detection requires no config here).
"prettier-web": {
"command": ["npx", "--yes", "prettier", "--write", "$FILE"],
"extensions": [".js", ".jsx", ".ts", ".tsx", ".css", ".html"],
},
// JSON/YAML — single formatter for all config and data files.
// biome auto-overrides .json/.yaml per-project when biome.json is present.
"prettier-config": {
"command": ["npx", "--yes", "prettier", "--write", "$FILE"],
"extensions": [".json", ".jsonc", ".yaml", ".yml"],
},
// Shell scripts — shfmt with standard formatting.
"shfmt": {
"command": ["shfmt", "-w", "$FILE"],
"extensions": [".sh", ".bash"],
},
},
// ── Watcher ───────────────────────────────────────────────────────────────
// Mirrors the ignore patterns from telescope.nvim's find_files/live_grep
// config plus Python/build artifacts — prevents noisy file-change events
// from generated and vendored directories.
"watcher": {
"ignore": [
"node_modules/**",
".git/**",
".venv/**",
".idea/**",
".ruff_cache/**",
"__pycache__/**",
"**/*.pyc",
"coverage/**",
".pytest_cache/**",
".aws-sam/**",
"**/*.egg-info/**",
"dist/**",
"build/**",
"frontend/node_modules/**",
"frontend/dist/**",
],
},
// ── Autoupdate ────────────────────────────────────────────────────────────
// Notify when a new version is available without auto-updating mid-session.
// Note: only works when opencode was not installed via a package manager
// (e.g. Homebrew). If installed via Homebrew, use `brew upgrade opencode`.
"autoupdate": "notify",
// ── Plugins ───────────────────────────────────────────────────────────────
// Loaded automatically by OpenCode at startup — no manual install needed.
// Requires node/npx to be available (verified by install.sh).
"plugin": [
"@tarquinen/opencode-dcp", // prunes stale tool outputs from context
"opencode-handoff", // session handoff prompts near context limit
],
// ── Global tool overrides ─────────────────────────────────────────────────
// Disable postgres MCP tools globally. Re-enabled only on the db agent
// via the agent-level "tools" configuration in agents/db.md.
"tools": {
"postgres_*": false,
},
}