Skip to content

feat(ai): add OpenCode Go provider - #4253

Open
AlexPlum405 wants to merge 7 commits into
binaricat:mainfrom
AlexPlum405:feat/opencode-go-provider
Open

AlexPlum405 wants to merge 7 commits into
binaricat:mainfrom
AlexPlum405:feat/opencode-go-provider

Conversation

@AlexPlum405

Copy link
Copy Markdown

Summary

Add OpenCode Go as a first-class AI provider. Selecting it only requires an API key: the Console endpoint, model catalog, and a default model are configured automatically.

Type of Change

  • New feature

Related Issue

N/A

Changes Made

  • New opencode-go preset with the Go Console endpoint and a curated model list.
  • Saving an API key picks a default model and activates the provider when no other provider is active.
  • Hide protocol/request-format controls and the custom-header editor; the Base URL is read-only because the endpoint paths are fixed by the service.
  • Route each model to its native API automatically: Chat Completions, Responses, Anthropic Messages, or Google GenerateContent. Unknown models fall back to Chat Completions, which the gateway also serves.
  • Send the required x-opencode-session header for routing and prompt-cache affinity, plus a Netcatty user agent, on opencode.ai hosts. Plugin model calls now carry a session id too.
  • Parse OpenCode's nested limit.context model metadata for context windows.
  • Add the provider icon, Console API-key link, settings search keyword, and translations.
  • Unit tests cover the preset, auto-config, per-model protocol routing, endpoint selection, request headers, and model discovery.

Screenshots / Demo

Settings → AI → Add Provider → OpenCode Go.

The form shows the API Key field, a read-only Base URL, and the model picker. Protocol style, request format, and custom headers are intentionally hidden because OpenCode Go fixes them.

Testing

  • I have tested these changes locally (npm run dev)
  • Linting passes (npm run lint)
  • Relevant test suites pass (provider preset, auto-config, per-model routing, endpoints, headers, discovery, i18n)
  • Full npm test — an unrelated hostOpen.integration test times out in this environment
  • No new console errors or warnings, if this affects app behavior

Checklist

  • My code follows the existing project style
  • I have added or updated relevant documentation
  • I have not introduced any breaking changes (or I have described them above)

Add OpenCode Go as a first-class AI provider preset for Catty:

- Pre-fill the Console endpoint (https://opencode.ai/inference/go/openai/v1)
  and a curated model list, with live discovery from /models.
- After the user pastes an API key and saves, select a sensible default
  model and activate the provider when no other provider is active.
- Parse nested limit.context values from model list payloads (OpenCode Go
  reports context windows this way).
- Point users at the Console API-key page from the provider form and make
  the settings search find the entry with "opencode".

The existing x-opencode-session header already covers chat routing for
opencode.ai hosts.
OpenCode Go exposes exactly one wire protocol and request format, so the
provider form must not offer Anthropic/Google styles or a Responses toggle.
Hide both controls for fixed-protocol presets, force the saved config back
to OpenAI Chat Completions, and ignore stale overrides at request time.
OpenCode Go's catalog is not uniformly Chat Completions: 20 models are
native chat, 5 are Responses, 6 are Anthropic Messages, and 1 is Google
GenerateContent. The Console gateway translates between them, but forcing
Chat Completions loses each model's native reasoning and tool handling.

Keep the protocol controls hidden, then pick the wire family from the
selected model:

- responses -> OpenAI Responses
- messages  -> Anthropic Messages (/anthropic/v1 prefix)
- google    -> Google GenerateContent (/google/v1beta prefix)
- default   -> OpenAI Chat Completions

Model discovery stays on the OpenAI prefix, and a read-only Base URL makes
it clear that the endpoint paths are fixed by the provider.
OpenCode Go needs `x-opencode-session` on every model call for routing and
prompt-cache affinity. Catty already forwards the chat session id; this also
covers plugin model invocations, which previously had no session header.

OpenCode also asks clients to identify themselves instead of presenting a
generic SDK user agent. Send `Netcatty-AI/1.0` for opencode.ai hosts while
keeping user-configured headers as the override.
OpenCode Go has one hosted endpoint and no proxy or self-signed setup to
configure, so the custom-header editor only adds noise. Hide it for
fixed-protocol presets and leave any previously stored headers untouched
instead of overwriting them with the hidden rows.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T14:12:04.631425Z 6f86386 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

The previous asset was a monochrome silhouette that was left-aligned and
touched the badge edges, so it read as a generic terminal glyph. Replace it
with the official OpenCode mark (white frame, gray block, dark background)
and render it full-color instead of applying the monochrome invert filter.
The 16px composer badge used a 6px radius, so the full-color mark read as a
black circle. Give full-color icons size-aware corners (3/4/6px) and move
the asset to a new filename so a stale 300px SVG from an earlier build cannot
be reused.
@AlexPlum405

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 6f86386923

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant