opencode-setup is the public open-source onboarding repository for the
GonkaGate CLI that configures local opencode to use GonkaGate as a
custom provider without requiring users to hand-edit opencode.json, export
secrets through shell profiles, or understand OpenCode provider internals.
Recommended public flow:
npx @gonkagate/opencode-setupCurrent honest state:
- the real end-to-end public installer flow is implemented
- the public CLI validates local
opencode, collects a GonkaGate API key through the supported safe inputs, fetches live models, resolves model and scope before managed writes, verifies both the durable and current-session effective OpenCode config, and ends with plainopencode - the product docs, CI, package contract, and PRD are implemented and now describe the shipped runtime
- the live GonkaGate model picker is shipped and uses the
/v1/modelsresponse - the installer writes every fetched GonkaGate model id into
provider.gonkagate.modelsso OpenCode's/modelscommand can switch between managed GonkaGate models after setup - native Windows support is part of the current contract and is backed by
native Windows CI and integration proof, not only simulated
win32tests - the minimum verified OpenCode version remains
1.4.0, and the latest audited stable upstream OpenCode release isopencode-ai1.4.1as of April 9, 2026
If the implementation status, package name, security flow, config locations, transport contract, or verified OpenCode baseline changes, this file must be updated immediately so it stays truthful.
The intended happy path is:
- user runs
npx @gonkagate/opencode-setup - installer validates local
opencode - installer collects a GonkaGate
gp-...key through a hidden prompt,GONKAGATE_API_KEY, or--api-key-stdin - installer fetches
GET https://api.gonkagate.com/v1/modelswith Bearer auth - installer offers the live GonkaGate model picker in interactive mode and
accepts defaults through
--yesor safe non-interactive selection rules - installer asks for
userorprojectscope - installer writes the minimum safe OpenCode config layers
- installer verifies the durable OpenCode config and the current session's effective OpenCode config
- user returns to plain
opencode
For project scope, the user-level config owns the provider definition and
secret binding, while the repository-local opencode.json contains only
activation settings.
These decisions are part of the repo contract. Changing them is not a small refactor; it is a product change.
- the npm package is
@gonkagate/opencode-setup - the intended public npm entrypoint is
npx @gonkagate/opencode-setup - the stable provider id is
gonkagate - the canonical base URL is
https://api.gonkagate.com/v1 - the current transport target is
chat/completions - future
/v1/responsessupport should be added by migration, not by product rename - durable global config target is
~/.config/opencode/opencode.json OPENCODE_CONFIGis an additional higher-precedence override layer, not a replacement for the global config targetOPENCODE_CONFIG_CONTENTis a runtime-only higher-precedence override layer, not a durable install target- interactive mode keeps the live GonkaGate model picker visible even when only one GonkaGate model is currently available
--yesand safe non-interactive flows may accept the first fetched model without showing the picker- project config target is
opencode.json - the managed user-level provider key is
provider.gonkagate - the managed user-level provider catalog under
provider.gonkagate.modelsincludes every model id returned by/v1/models projectscope writes only activation settings- repo-local
opencode.jsonrewrites must keep rollback backups under~/.gonkagate/opencode/backups/project-configinstead of beside the repository file - provider definition and secret binding live in user scope
- the canonical installer-owned secret binding is exactly
provider.gonkagate.options.apiKey = {file:~/.gonkagate/opencode/api-key} - durable secret-binding provenance must be verified separately from resolved-
config verification, and
user_configis the only durable layer allowed to own that binding - scope normalization must remove only installer-owned GonkaGate activation
from the old target; unrelated top-level
model/small_modelvalues must be preserved and surfaced by verification if they still block the intended scope - installer success must be based on effective OpenCode config, not only file writes
- durable effective-config verification must keep
opencode debug config --pureas the final truth source instead of reimplementing the full upstream merge engine - resolved effective-config verification must stay responsible for
model,small_model,provider.gonkagate, transport and base URL shape, live model-catalog shape, and provider allow/deny gating - secret-binding provenance verification must separately enforce
provider.gonkagate.options.apiKeyownership instead of inferring it from redacted resolved-config output - effective-config verification must separately prove the durable plain-
opencodeoutcome and the current session's runtime-resolved outcome install-state.jsonmust remain the durable migration anchor, andlastDurableSetupAtmust mean "last durably verified setup" rather than "full success including later current-session verification"- effective-config verification must account for provider allow/deny lists
such as
enabled_providersanddisabled_providerswhen they disablegonkagate - exact durable blocker attribution is guaranteed only for locally inspectable
OPENCODE_CONFIG, user config, project config, and file-based system managed config layers - within those inspectable layers, durable blocker attribution must follow
current OpenCode precedence: user config, then
OPENCODE_CONFIG, then project config, then file-based system managed config - if the 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
OPENCODE_CONFIG_CONTENTmust not be treated as a durable install target; identical inline overrides may still pass for non-secret resolved keys, but any inlineprovider.gonkagate.options.apiKeyoverride must block the current-session check in v1- effective-config verification must not print raw resolved config containing substituted secrets
- v1 supports macOS, Linux, native Windows, and WSL-based OpenCode usage on Windows
- WSL remains the upstream-recommended Windows path for the best experience, but native Windows is a supported runtime path
- the installer must not write directly to
auth.json - no plain CLI flag may carry the secret
- secrets must not be accepted through a plain CLI flag such as
--api-key - safe secret inputs are:
- hidden interactive prompt
GONKAGATE_API_KEY--api-key-stdin
- shell profile mutation is out of scope
.envfile generation is out of scope- arbitrary custom base URLs are out of scope for v1
- arbitrary model ids not returned by
/v1/modelsare out of scope for v1 - the installer must not depend on
gonkagate doctor small_modelis explicitly set by the runtimemodelandsmall_modelselect the setup default; they are not the full GonkaGate model catalog- the live
/v1/modelsresponse is the runtime source of truth for model availability
- never print the GonkaGate
gp-...key - never accept secrets through plain
--api-key - never store the secret in repository-local files
- keep the secret under
~/.gonkagate/opencode/...; enforce owner-only permissions where the platform supports POSIX modes, and on native Windows keep managed user files inside the current user's profile so they inherit per-user ACLs - keep the canonical GonkaGate secret binding only in user config;
projectconfig,OPENCODE_CONFIG, file-based system managed config, andOPENCODE_CONFIG_CONTENTmust not defineprovider.gonkagate.options.apiKey - on POSIX-supported platforms, reruns must repair drifted managed-secret file and directory permissions in place when the secret contents already match, without rewriting the secret or creating a backup
- never print raw resolved-config output from
opencode debug config - redact secret-bearing fields from diagnostics or logs
- redact secret-bearing text on every user-facing CLI error path, including fallback entrypoint error handling
- preserve unrelated OpenCode config when editing user config
- create backups before replacing managed user files; when rewriting repo-local
opencode.json, keep the rollback backup under~/.gonkagate/opencode/backups/project-configinstead of beside the repository file - project config must stay commit-safe by default
- repo-local activation config must not contain the secret path
- higher-precedence custom or managed config must be checked before reporting setup success
These are implementation facts today, not future plans:
src/cli.tsis the shipped public runtime entrypoint and renders both human-readable and machine-readable installer resultsbin/gonkagate-opencode.jsis a thin wrapper overdist/cli.jssrc/install/now contains the shipped runtime foundations and orchestration for dependency injection, OpenCode detection, path resolution, platform classification, safe secret intake, managed secret/install-state persistence, managed provider catalog generation, managed config parse/merge/write, rerun-safe rollback, locally inspectable higher-precedence layer attribution, inferred fallback blocker reporting, installer-owned scope normalization, separate resolved-config versus secret-binding provenance verification, redacted effective-config diagnostics, and the end-to-end installer flow- the installer fetches
GET https://api.gonkagate.com/v1/modelsafter API-key intake and uses the live response for model selection,--modelvalidation, provider catalog writes, and verification - a mirrored skill pack is present under
.agents/skills/and.claude/skills/, imported fromcodex-setupas an initial shared engineering baseline docs/specs/opencode-setup-prd/spec.mdis the final product contracttest/package-contract.test.ts,test/docs-contract.test.ts, andtest/cli.test.tsprotect the shipped runtime contract.github/workflows/ci.ymlnow exercises Ubuntu and native Windows runners so the native Windows support claim has runner-backed prooftest/skills-contract.test.tsprotects mirrored skill integrity
This repo currently does:
- define the product contract for the OpenCode setup tool
- define security, scope, and transport constraints
- provide npm packaging, CI, release-please, and publish scaffolding
- provide a working public CLI entrypoint with a live GonkaGate model picker
- provide end-to-end managed config writes, a fetched GonkaGate model catalog
for OpenCode
/modelsswitching, scope-aware ownership, rerun-safe rollback, and redacted effective-config verification undersrc/install/ - provide docs and tests that protect the current contract
This repo currently does not do:
- expose arbitrary custom model ids or arbitrary base URL overrides
- claim
/v1/responsessupport today - verify live GonkaGate sessions
.
├── AGENTS.md
├── README.md
├── CHANGELOG.md
├── LICENSE
├── package.json
├── package-lock.json
├── tsconfig.json
├── tsconfig.build.json
├── .github/workflows/
├── bin/
│ └── gonkagate-opencode.js
├── docs/
│ ├── README.md
│ ├── model-validation.md
│ ├── how-it-works.md
│ ├── security.md
│ ├── troubleshooting.md
│ ├── specs/
│ │ └── opencode-setup-prd/spec.md
├── scripts/
│ └── run-tests.mjs
├── .agents/skills/
├── .claude/skills/
├── src/
│ ├── cli.ts
│ ├── constants/
│ └── install/
└── test/
├── cli.test.ts
├── docs-contract.test.ts
├── install/
├── package-contract.test.ts
└── contract-helpers.ts
Primary public repository summary. Keep implementation status, package name,
intended npx entrypoint, config targets, and security posture truthful.
The product source of truth for the setup tool.
Repository-level architecture contract for setup flow, scope behavior, and future migration path.
Security and secret-handling contract. Any change to auth flow, secret storage, or non-interactive setup must be reflected there.
Current public runtime entrypoint.
Shipped installer runtime including dependency injection, OpenCode detection, path resolution, platform classification, safe secret intake, managed secret/install-state persistence, managed config parse/merge/write seams for user/project ownership, rerun-safe rollback, and read-only effective-config verification.
Mirrored skill pack imported from codex-setup to give the repository a
useful engineering baseline from day one. Mirror updates across both trees when
the shared skill pack changes.
When behavior changes:
- update
AGENTS.md - update
README.md - update relevant files in
docs/ - update
CHANGELOG.mdwhen the change is meaningful to users or contributors - update tests under
test/if the repository contract changed - keep mirrored
.agentsand.claudeskill assets aligned - keep current-contract docs and historical planning docs explicitly labeled so they cannot contradict each other silently
The installer is now real:
- remove or revise any wording that drifts back toward scaffold-only language
- no repository update is needed when GonkaGate adds or removes a model from
/v1/models - add runtime behavior tests before claiming any new end-user capability
Current local validation baseline:
npm run ciThat command should stay green before treating scaffold, contract, or doc changes as ready.
@RTK.md
This project has a graphify knowledge graph at graphify-out/.
Rules:
- Before answering architecture or codebase questions, read graphify-out/GRAPH_REPORT.md for god nodes and community structure
- If graphify-out/wiki/index.md exists, navigate it instead of reading raw files
- After modifying code files in this session, run
python3 -c "from graphify.watch import _rebuild_code; from pathlib import Path; _rebuild_code(Path('.'))"to keep the graph current