GonkaGate needs a first-class setup tool for opencode, because the native
custom-provider path asks too much from end users:
- they need to know that GonkaGate is a custom provider
- they need to understand OpenCode provider config
- they need to hand-edit
opencode.json - they need to know the canonical
baseURL - they need to know the current transport contract
- they need to know how to feed the secret safely
That is too much friction for a coding-agent onboarding flow. The intended
experience should be one short setup command followed by plain opencode.
The user runs:
npx @gonkagate/opencode-setupThe tool:
- validates local
opencode - offers only curated GonkaGate model choices
- lets the user choose
userorprojectscope - accepts a GonkaGate API key through a hidden prompt,
GONKAGATE_API_KEY, or--api-key-stdin - writes the minimum safe configuration automatically
- verifies both the durable plain-
opencodeoutcome and the current session's effective OpenCode outcome - never requires manual edits to
opencode.json - never requires
.envfiles or shell exports - sends the user back to normal
opencode
Primary user:
- a developer with local
opencodewho wants GonkaGate without manual provider wiring
Secondary user:
- a team that wants a repeatable project activation path without leaking secrets into git
- one public npm package:
@gonkagate/opencode-setup - one public repository
- configuration of already installed local
opencode - hidden or automation-safe secret input
- curated model picker
userandprojectscope- managed user secret storage
- managed config writes with backups
- future-safe migration path for
/v1/responses
- installing
opencode - shell profile mutation
.envfile generation- plain
--api-key - runtime
/v1/modelsdiscovery as the main onboarding UX - arbitrary custom base URLs
- arbitrary custom model ids
- integration with
gonkagate doctor - claiming
/v1/responsessupport today
- canonical base URL:
https://api.gonkagate.com/v1 - current supported transport:
/v1/chat/completions /v1/responsesis not supported today- setup docs must stay honest about that current reality
- custom provider setup requires config, not only credentials
- user config,
OPENCODE_CONFIG,OPENCODE_CONFIG_CONTENT, project config, and managed settings merge together by precedence OPENCODE_CONFIGadds an extra higher-precedence config layer; it does not replace the global config target- for the durable file-backed layers this installer can inspect directly, the
current OpenCode precedence order is: user config, then
OPENCODE_CONFIG, then project config, then file-based system managed settings OPENCODE_CONFIG_CONTENTis a runtime-only higher-precedence override for the current process; it is not a durable install target- current chat-completions provider path uses
@ai-sdk/openai-compatible - current schema supports file-based secret substitution through
{file:...} - current docs clearly prove
{file:...}substitution in config files, but do not clearly prove equivalent inlineOPENCODE_CONFIG_CONTENTsecret-binding parity for this product contract, so v1 must not assume it - provider allow and deny lists such as
enabled_providersanddisabled_providerscan prevent a configured provider from loading and must be treated as part of the effective activation surface - file-based system managed settings can also win by precedence through
opencode.jsonoropencode.jsoncin/etc/opencode/,/Library/Application Support/opencode/, or%ProgramData%\\opencode - custom-provider model wiring can be overridden per model when transport requirements diverge
- higher-precedence custom, inline, or managed settings can override user or project config and must be accounted for before claiming setup success
- future
/v1/responsesmay require a different adapter path
- setup must feel simpler than manual custom-provider wiring
- secrets must stay out of git
- unrelated OpenCode config must be preserved
- project scope must be safe to commit
- rerunning the installer must be the official migration path
- package name:
@gonkagate/opencode-setup - stable provider id:
gonkagate - stable display name:
GonkaGate
The product identity must survive future transport migration.
The initial production baseline is:
opencode-ai >= 1.4.0
Installer behavior:
- missing
opencode: stop with install guidance - lower version than
1.4.0: stop and request upgrade - newer version: continue, but keep
1.4.0as the documented minimum verified baseline until re-audited
Allowed:
- hidden interactive prompt
GONKAGATE_API_KEY--api-key-stdin
Disallowed:
- plain
--api-key
The tool must not accept a normal secret flag because it can leak into shell history, logs, and process listings.
The installer does not rely on /connect or opencode providers login as its
primary integration path and does not write directly to auth.json.
Instead it stores the secret in a GonkaGate-managed user file:
- all supported platforms:
~/.gonkagate/opencode/api-key - native Windows resolved path:
%USERPROFILE%\\.gonkagate\\opencode\\api-key
Why:
- current OpenCode docs say OpenCode can run directly on Windows while still recommending WSL for the best experience
- current OpenCode config docs keep the durable global target at
~/.config/opencode/opencode.json - current OpenCode
{file:...}docs and source still support~/...expansion, which keeps the secret binding cross-platform - the Node/FS stack used here does not provide portable Windows ACL mutation,
so native Windows support must be explicit about relying on inherited
user-profile ACLs rather than installer-enforced owner-only
chmod
The user-level provider config references that file through OpenCode variable substitution.
The canonical installer-owned binding is exactly:
provider.gonkagate.options.apiKey = {file:~/.gonkagate/opencode/api-key}
Durable verification must prove that ownership separately from resolved-config comparison because redacted resolved output is not treated as proof of secret provenance.
On macOS, Linux, and WSL, the managed secret is only converged when both the contents and owner-only protection state are correct. If reruns find the same secret contents with drifted file or directory modes, they must repair those modes in place without rewriting the secret contents or creating a backup.
The installer also writes:
~/.gonkagate/opencode/install-state.json- native Windows resolved path:
%USERPROFILE%\\.gonkagate\\opencode\\install-state.json
This records:
- installer version
- selected model key
- selected scope
- current transport contract
lastDurableSetupAt, the timestamp of the last durably verified setup
That state file is the migration anchor for future upgrades, including the
eventual move to responses.
lastDurableSetupAt is intentionally a durable-verification timestamp, not a
promise that every later current-session verification also succeeded. It must
still advance when the durable plain-opencode result is verified and a later
OPENCODE_CONFIG_CONTENT check reports blocked or failed.
user scope:
- write provider definition to user config
- write activation settings to user config
- keep secret and managed state in user storage
- remove installer-owned stale GonkaGate activation from the old project target
project scope:
- still write provider definition to user config
- still keep secret and managed state in user storage
- write only activation settings to repo-local
opencode.json - keep any repo-local rollback backup under
~/.gonkagate/opencode/backups/project-config - remove installer-owned stale GonkaGate activation from the old user target
This keeps project config commit-safe and prevents secret paths from leaking into git, even when the installer needs rollback material for a repo-local rewrite.
- interactive mode keeps the public curated model picker visible even when exactly one validated GonkaGate model is currently available
- if exactly one validated GonkaGate model is available, safe non-interactive setup may select it automatically
- if multiple validated models are available, preselect one recommended default and allow the user to change it
- recommend
projectscope when the installer is running inside a git repository and recommenduserscope otherwise --yesaccepts the recommended defaults- prompts should explain scope in plain user language, not only in OpenCode config terms
Durable user config target:
~/.config/opencode/opencode.json- native Windows resolved path:
%USERPROFILE%\\.config\\opencode\\opencode.json
OPENCODE_CONFIG handling:
OPENCODE_CONFIGis an additional higher-precedence layer, not a replacement for the durable global config target- the installer must not treat writing only to
OPENCODE_CONFIGas sufficient for durable plain-opencodesetup - if
OPENCODE_CONFIGis set, the installer must inspect it as part of the effective config surface - if that custom layer overrides GonkaGate-managed keys, the installer must either reconcile the same managed keys there too or stop with a clear conflict message
OPENCODE_CONFIG_CONTENT handling:
OPENCODE_CONFIG_CONTENTis a runtime-only higher-precedence override and must never be treated as a durable install target- durable setup success must be verified separately from any inline runtime override
- if
OPENCODE_CONFIG_CONTENTis present when the installer verifies setup, the installer must also verify the current session with that inline layer still active - if the inline layer changes the current session away from the intended GonkaGate outcome, setup must report the session as blocked even when the durable install is otherwise correct
- identical inline overrides for non-secret resolved keys may pass when they still preserve the intended GonkaGate outcome
- inline
provider.gonkagate.options.apiKeyoverrides must always block the current-session check in v1 because the current upstream docs do not clearly prove equivalent inline{file:...}secret-binding parity for this product contract
Project config target:
<project-root>/opencode.json
Project-config rollback backup root:
~/.gonkagate/opencode/backups/project-config- native Windows resolved path:
%USERPROFILE%\\.gonkagate\\opencode\\backups\\project-config
Project root is the current working directory or the nearest enclosing git root.
The onboarding flow must not depend on runtime /v1/models discovery.
Instead it ships a curated model registry that records, per model:
- stable GonkaGate setup key
- upstream model id
- display name
- transport kind
- default adapter package
- validation status
- optional context and output limits
- optional compatibility metadata and managed config fragments required for the validated OpenCode flow, such as provider options, model options, or model headers
- optional migration metadata for future per-model adapter changes
Registry keys must map cleanly to OpenCode's provider_id/model_id format so
validated entries can be written under provider.gonkagate.models and the
selected setup default can be written as gonkagate/<model-key>.
Registry data must be sufficient for the installer to reproduce the exact provider and model config shape used during validation, not only the visible picker label or adapter package.
Only validated models should be shown to end users.
A model may be marked validated only after end-to-end verification against
the current verified OpenCode baseline for the workflows the product claims to
support.
Minimum validation proof for a curated GonkaGate model includes:
- an interactive
opencodesession opencode run- streaming text responses
- tool-calling and file-edit loops
- multi-turn continuation
- the
small_modelpath used by lightweight OpenCode tasks - any provider-level or model-level compatibility settings required for stable tool-calling, streaming, or continuation behavior on the verified baseline
- effective-config resolution in both
userandprojectscope
If GonkaGate later claims task, delegate, or subagent compatibility, the model must be re-validated for those flows before the product advertises that support.
A model must not be marked validated if its working setup depends on
undocumented manual tweaks that are not representable in the curated registry
contract.
The installer must explicitly set both:
modelsmall_model
In v1 they should be set to the same selected GonkaGate model.
The selected model is only the default activation target. The installer must
also write every validated curated model into provider.gonkagate.models so
OpenCode's /models command can switch between managed GonkaGate models after
setup.
Why:
- keeps default OpenCode traffic on an explicitly selected GonkaGate model
- avoids implicit cheaper-model paths that have not been validated yet
- is safer than guessing a provider-local cheaper model before a validated small-model strategy exists
Current v1 truth:
- transport contract:
chat_completions - adapter package:
@ai-sdk/openai-compatible - base URL:
https://api.gonkagate.com/v1
The setup tool must not imply responses support today.
The product must still be ready for the later addition of responses.
Migration contract:
- provider id remains
gonkagate - package identity remains
@gonkagate/opencode-setup - secret location remains stable
- rerunning the installer is the official migration path
- curated registry and install-state metadata decide whether migration happens
through:
- a whole-provider adapter change
- or a per-model provider override from
@ai-sdk/openai-compatibleto@ai-sdk/openai
The installer owns only the GonkaGate-managed subset of config.
User-level managed keys:
provider.gonkagatein the durable global config- the full validated GonkaGate catalog under
provider.gonkagate.models - validated GonkaGate compatibility settings under
provider.gonkagateand its model entries when the curated registry requires them - GonkaGate-managed activation settings when scope is
user - GonkaGate-managed
small_modelwhen scope isuser - stale activation cleanup in the old target only when the installer can prove
ownership through the currently selected curated GonkaGate ref or the
previously recorded managed curated ref from
install-state.json
Additional precedence-aware ownership:
- if
OPENCODE_CONFIGis set and contains overlapping GonkaGate-managed keys, the installer must treat that layer as part of the managed effective-config surface for the current machine user_configis the only durable layer allowed to ownprovider.gonkagate.options.apiKey- project config,
OPENCODE_CONFIG, and inspectable file-based system managed config must not defineprovider.gonkagate.options.apiKey enabled_providersanddisabled_providersare not GonkaGate-managed keys by default, but they are part of the effective provider-activation surface- if any higher-precedence layer excludes
gonkagatethroughenabled_providersordisabled_providers, the installer must treat that layer as a blocking conflict unless it is explicitly reconciling the same GonkaGate-managed list - the installer does not claim ownership over unrelated keys in remote config, admin-managed config, or user custom config outside the GonkaGate-managed subset
Project-level managed keys:
- GonkaGate-managed activation settings when scope is
project - GonkaGate-managed
small_modelwhen scope isproject
The installer must preserve all unrelated providers, agents, commands, plugins,
permissions, and UI settings.
It must also preserve unrelated top-level activation values, including
third-party model / small_model refs or non-owned GonkaGate refs, and let
verification surface them if they still block the intended scope.
When a target config already exists, the installer must:
- parse JSON or JSONC safely
- refuse to continue if safe merge is impossible
- create a timestamped backup; when the rewritten target is repo-local
opencode.json, store that rollback backup under~/.gonkagate/opencode/backups/project-configinstead of beside the repository file - preserve unrelated config
- add
$schemaif missing - rewrite only the GonkaGate-managed keys
- write stable and readable output
- evaluate higher-precedence override layers before claiming success
When scope normalization encounters non-owned activation in the old target, it must leave that value in place and rely on verification to report any resulting precedence conflict.
The setup tool should end with the minimal next step:
opencodeBut installer success must be based on the effective OpenCode config, not only on successful file writes.
Before claiming success, the installer must:
- use
opencode debug config --pureas the final durable success gate on the verified baseline instead of reimplementing the full upstream merge engine - use resolved-config verification for
model,small_model,provider.gonkagate, validated transport and base URL shape, curated model-catalog shape, and provider allow/deny gating - verify
provider.gonkagate.options.apiKeyprovenance separately instead of inferring secret ownership from redacted resolved output - detect higher-precedence custom or managed layers that keep GonkaGate from becoming effective when the resolved config proves a block or mismatch
- detect provider allow or deny lists such as
enabled_providersanddisabled_providersthat excludegonkagate - surface the blocking layer clearly when the effective config does not match the installer outcome
- guarantee exact durable blocker attribution only for locally inspectable
OPENCODE_CONFIG, user config, project config, and file-based system managed config layers - when more than one locally inspectable layer conflicts on the same GonkaGate-managed key, attribute the block according to real OpenCode precedence among those layers rather than file traversal order
- surface the exact blocking key when provider allow or deny lists prevent
gonkagatefrom loading - report an inferred higher-precedence or managed blocker when the resolved
config proves
enabled_providersordisabled_providersblocksgonkagatebut no locally inspectable layer explains it - prove the durable plain-
opencodeoutcome separately from runtime-only overrides such asOPENCODE_CONFIG_CONTENT - require
user_configto ownprovider.gonkagate.options.apiKey = {file:~/.gonkagate/opencode/api-key} - treat project config,
OPENCODE_CONFIG, and inspectable file-based system managed config as durable blockers when they defineprovider.gonkagate.options.apiKey - treat any inline
OPENCODE_CONFIG_CONTENTprovider.gonkagate.options.apiKeyoverride as a v1 current-session blocker - treat other
OPENCODE_CONFIG_CONTENTand similar runtime-only overrides as current-session blockers only when they change the resolved result for the current process away from the intended GonkaGate outcome - use
opencode debug configor an equivalent resolved-config inspection path when the verified OpenCode baseline provides one - treat resolved-config inspection as secret-bearing because
{file:...}and{env:...}substitutions may already be expanded there - capture and parse resolved-config output internally instead of printing raw stdout or stderr to the user
- redact secret-bearing fields from any user-facing diagnostics, logs, crash reports, or support output
The setup tool does not depend on gonkagate doctor.
It must not depend on gonkagate doctor.
- users must be able to configure GonkaGate for
opencodein onenpxcommand - users must not need to hand-edit
opencode.json - users must be able to choose
userorprojectscope - the installer must store the secret only outside the repository
- the installer must configure GonkaGate using the current
chat_completionscontract - the installer must use curated validated models
- the installer must preserve unrelated OpenCode config
- the installer must set
small_modelexplicitly - the installer must support rerun as the official update path
- the installer must not rely on
auth.json - the installer must not depend on
gonkagate doctor - the installer must treat
OPENCODE_CONFIGas an extra override layer, not as a replacement user-config target - the installer must treat
OPENCODE_CONFIG_CONTENTas a runtime-only override layer, not as a durable install target - the installer must verify the durable plain-
opencodeoutcome and the current session's effective config before reporting success - the installer must not print raw resolved-config output that may contain substituted secrets
- the curated model registry must be able to encode any validated compatibility settings required beyond model id and adapter choice
- the installer must write every validated curated model into
provider.gonkagate.modelsso OpenCode's/modelscommand can switch between managed GonkaGate models - the installer must treat
enabled_providersanddisabled_providersthat excludegonkagateas blocking conflicts unless it is explicitly reconciling a GonkaGate-managed list - the installer must only claim exact durable blocker attribution for
locally inspectable
OPENCODE_CONFIG, user config, project config, and file-based system managed config layers - when more than one locally inspectable layer conflicts on the same GonkaGate-managed key, durable blocker attribution must follow real OpenCode precedence among those layers rather than file traversal order
- when resolved config proves provider gating but no locally inspectable layer explains it, the installer must report an inferred higher-precedence or managed blocker instead of a generic mismatch
- the installer must enforce the canonical secret-binding provenance rule:
user_configownsprovider.gonkagate.options.apiKey = {file:~/.gonkagate/opencode/api-key} - the installer must block project config,
OPENCODE_CONFIG, and inspectable file-based system managed config when they defineprovider.gonkagate.options.apiKey - the installer must block any inline
OPENCODE_CONFIG_CONTENT.provider.gonkagate.options.apiKeyoverride in v1
- setup should feel simpler than manual custom-provider configuration
- secret handling must be safe by default
- config writes must be reversible through backups
- project scope must remain safe to commit
- the tool must be production-ready on macOS, Linux, native Windows, and WSL-based Windows usage
- native Windows secret and state handling must stay explicit about relying on
current-user profile ACL inheritance instead of claiming portable
owner-only
chmodenforcement - native Windows support claims must be backed by native Windows CI or
integration proof, not only simulated
platform: "win32"path tests - future
responsesmigration must not require a new package identity - setup should minimize prompts by accepting recommended defaults when it is safe to do so
- interactive setup should keep the public curated picker visible even when the curated validated list is small so the public UX stays stable
- on macOS, Linux, and WSL, reruns must repair drifted managed-secret file and directory modes without rewriting unchanged secret contents or creating backups
- uninstall or repair commands
- richer post-setup verification
- broader curated model registry
- validated cheaper small-model strategy
- future migration to
responses
- if secrets enter project config, users will leak keys into git
- if the tool overclaims
responses, product truth will drift - if runtime discovery becomes the onboarding truth, stability will degrade
- if unrelated config is overwritten, users will stop trusting the tool
- if
small_modelis left implicit, OpenCode may take an unvalidated cheaper model path or a fallback path we did not configure explicitly - if
OPENCODE_CONFIGis treated as a replacement target, plainopencodesetup may disappear outside that environment - if
OPENCODE_CONFIG_CONTENTis ignored during verification, the installer may report durable success while the current shell still resolves another provider or model - if secret-binding provenance is inferred only from redacted resolved output,
higher-precedence
provider.gonkagate.options.apiKeyoverrides may pass undetected - if higher-precedence managed or custom layers are ignored, the installer may report success while OpenCode still resolves to another provider
- if
enabled_providersordisabled_providersexcludegonkagateand the installer ignores them, setup may report success while the provider never loads - if resolved provider gating falls back to a generic mismatch instead of an inferred blocker, users may not understand that an unseen higher-precedence or managed layer is the real cause
- if native Windows path semantics drift from the current OpenCode contract, file substitution for secrets may fail
- if native Windows profile-directory ACL inheritance is mistaken for installer-enforced ACL repair, the product will overclaim its real security guarantee
- if validated compatibility settings are not captured in the curated registry, a model may look installable on paper but still fail in real OpenCode agent loops
- if raw resolved-config output is echoed during verification, secret material
from
{file:...}or{env:...}substitution may leak into terminals, logs, CI output, or support tickets
The correct v1 product shape is:
- a small onboarding CLI
- one stable provider id:
gonkagate - one curated model picker and a validated GonkaGate model catalog for
OpenCode
/modelsswitching - one safe secret flow
- zero manual config editing
- zero
.env - zero shell exports
- minimal prompting with recommended defaults
- one durable global config target plus precedence-aware conflict handling, including provider allow and deny blockers
- a curated registry that can carry the compatibility settings required for validated OpenCode behavior
- honest support for
chat_completionstoday - a deliberate migration path for future
responses - native Windows support with WSL still recommended upstream for the best Windows experience, backed by native Windows CI and integration proof