Skip to content

feat(provider): add OpenCode Go#1895

Merged
zerob13 merged 2 commits into
devfrom
feat/opencode-go-provider
Jul 8, 2026
Merged

feat(provider): add OpenCode Go#1895
zerob13 merged 2 commits into
devfrom
feat/opencode-go-provider

Conversation

@zhangmo8

@zhangmo8 zhangmo8 commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add OpenCode Go as a built-in provider using the documented Go API endpoints
  • fetch Go models from the live /models endpoint and route documented /messages models through the Anthropic runtime
  • cover provider registration, model mapping, OpenAI-compatible routing, Anthropic routing, and Anthropic behavior presets

Validation

  • pnpm run format
  • pnpm run i18n
  • pnpm run lint
  • pnpm exec vitest run test/main/presenter/configPresenter/defaultProviders.test.ts test/main/presenter/llmProviderPresenter/basicApiKeyProviders.test.ts --pool=forks

Closes #1896

Summary by CodeRabbit

  • New Features
    • Added built-in support for the OpenCode Go provider, including provider details, model discovery, and mixed routing for chat and messages models.
    • Certain models now automatically use the appropriate runtime based on their endpoint type.
  • Documentation
    • Added feature plan, specification, and task-tracking docs for the new provider.
  • Tests
    • Expanded coverage for provider setup, model mapping/classification, routing behavior, and improved fetch mocking isolation.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds an opencode-go built-in provider, wires mixed OpenAI-compatible and Anthropic routing, maps live /models metadata, and adds tests plus feature documentation.

Changes

OpenCode Go Provider

Layer / File(s) Summary
Provider registration and strategy types
src/main/presenter/configPresenter/providers.ts, src/main/presenter/llmProviderPresenter/providerRegistry.ts
Adds opencode-go to DEFAULT_PROVIDERS, extends model-source and route strategy unions, and registers the provider with its check and credential settings.
Routing and model mapping implementation
src/main/presenter/llmProviderPresenter/providers/aiSdkProvider.ts
Adds the OpenCode Go Anthropic model allowlist, updates route selection, and implements model fetching/classification for OpenCode Go models.
Tests for provider definition, model mapping, and routing
test/main/presenter/configPresenter/defaultProviders.test.ts, test/main/presenter/llmProviderPresenter/basicApiKeyProviders.test.ts
Adds coverage for provider metadata, model mapping from /models, and routing through OpenAI-compatible and Anthropic runtimes.
Feature planning documentation
docs/features/opencode-go-provider/plan.md, docs/features/opencode-go-provider/spec.md, docs/features/opencode-go-provider/tasks.md
Adds planning, specification, and task-tracking docs for the OpenCode Go provider work.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant AiSdkProvider
  participant OpenAICompatibleRuntime
  participant AnthropicRuntime

  Client->>AiSdkProvider: request with modelId
  AiSdkProvider->>AiSdkProvider: resolveRouteDecision(modelId)
  alt modelId in OPENCODE_GO_ANTHROPIC_MODEL_IDS
    AiSdkProvider->>AnthropicRuntime: route via apiType anthropic, baseUrl
    AnthropicRuntime-->>Client: response
  else other model
    AiSdkProvider->>OpenAICompatibleRuntime: route via chat/completions
    OpenAICompatibleRuntime-->>Client: response
  end
Loading

Possibly related issues

Possibly related PRs

Suggested reviewers: zerob13

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding OpenCode Go as a provider.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/opencode-go-provider

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@zerob13 zerob13 merged commit 6afb57d into dev Jul 8, 2026
3 checks passed
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.

[feature] OpenCode Go provider

2 participants