Expand description
Single source of truth for locating OpenCode’s global config file.
OpenCode accepts both opencode.json and opencode.jsonc. lean-ctx used to
hardcode opencode.json in every writer, so a user whose config was
opencode.jsonc got a second, competing global config containing nothing
but the lean-ctx MCP entry and shadow-mode denies — their providers, models
and foreign MCP servers appeared to vanish (#1585).
Resolution rule, applied by init, setup, doctor, the shadow-mode
permission updater and uninstall alike:
- exactly one of the two exists → that file
- both exist →
opencode.json(OpenCode’s own default name), reported viaResolved::ambiguousso callers can warn instead of silently picking - neither exists →
opencode.json, to be created
Structs§
- Resolved
- Where the OpenCode config lives, plus whether the choice was ambiguous.
Constants§
- CODE_
MODE_ KEY - OpenCode 2.x per-server MCP key: “Expose this server’s tools through Code
Mode. Defaults to true.” Under Code Mode the model sees only part of a
server’s tools, as functions inside
execute, soctx_readandctx_searchdrop out of view (#2295). lean-ctx sets it tofalse.
Functions§
- code_
mode_ key_ supported - Whether the installed OpenCode accepts
CODE_MODE_KEY(2.x or newer). - code_
mode_ key_ supported_ by - Whether an OpenCode with this
--versionoutput acceptsCODE_MODE_KEY. An unknown version does not: a key OpenCode 1.x rejects breaks the whole config, while a missing one only leaves Code Mode on. - config_
dir - Resolve OpenCode’s global config directory.
- disable_
code_ mode - Put
codemode: falseon a lean-ctx MCP server entry that has nocodemodevalue yet. A value the user set is kept. Returns whether the entry changed. - major_
version - Major version from
opencode --versionoutput such as2.2.1orv1.2.15. - resolve
- Resolve the global OpenCode config for a given home directory.
- resolve_
in_ dir - Resolve the config inside an OpenCode config directory.