Skip to content

Latest commit

 

History

History
114 lines (77 loc) · 6.99 KB

File metadata and controls

114 lines (77 loc) · 6.99 KB

opencode-databricks

An unofficial Databricks-flavored fork of anomalyco/opencode. Adds first-class support for Databricks Model Serving (Foundation Model APIs, custom endpoints, CLI auth) to the open-source opencode CLI coding agent.

This project is not affiliated with, endorsed by, or officially supported by the opencode project or SST. It is a personal fork maintained at github.com/dgokeeffe/opencode-databricks for use by Databricks field engineering.


Why this fork exists

The upstream opencode CLI supports many model providers (Anthropic, OpenAI, Bedrock, Vertex, etc.) but does not currently ship a first-class Databricks provider. Databricks workspaces can serve Claude, GPT-5, Gemini, Llama, Qwen, and other models through Foundation Model APIs, plus custom fine-tuned endpoints via Model Serving.

This fork adds:

  • Native Databricks provider (databricks/*) with automatic serving-endpoint discovery against your workspace
  • Auth via Databricks CLI profiles (~/.databrickscfg), PAT, OAuth, env vars, Azure MSI/CLI, GCP — the full Databricks SDK auth chain
  • Smart routing per model family — Claude models route through the native Anthropic compatibility path (/serving-endpoints/anthropic/v1), Gemini through the Google-native path, GPT/Codex through the OpenAI Responses API, and everything else through Chat Completions
  • Workarounds baked in for Databricks-specific proxy quirks (tool schema type: object coercion, Responses API streaming event fixes, oversized itemId truncation, etc.)

The changes are scoped to the provider system and the TUI auth flow; everything else tracks upstream.

Installation

This fork is not published to npm and not intended for general distribution. To try it, clone and run from source:

git clone https://github.com/dgokeeffe/opencode-databricks.git
cd opencode-databricks
bun install
bun dev        # run the TUI from source

You will need:

  • bun ≥ 1.3.11
  • Databricks CLI configured (databricks auth login --host <your-workspace>) or DATABRICKS_HOST + DATABRICKS_TOKEN in env
  • Access to the Databricks npm proxy (~/.npmrc should already point at this if you're on the Databricks network)

Configure the Databricks provider in opencode

In the TUI, run /login, pick Databricks, and either:

  1. Select a profile (reads databricks auth profiles and ~/.databrickscfg) — recommended
  2. Enter a workspace URL and then either use the Databricks CLI browser OAuth flow or paste a Personal Access Token

The provider will auto-discover all ready llm/v1/chat and llm/v1/responses serving endpoints the next time you open the model picker.

Relationship to upstream opencode

Aspect Behavior
Tracking dev on this fork is periodically merged from anomalyco/opencode:dev. Expect occasional long-lived feature branches during merges.
Upstream PR Databricks-specific changes are not proposed for merge into upstream opencode. They would pollute that project with vendor-specific code.
Issues File issues against this fork only. Do not open tickets against anomalyco/opencode for Databricks provider behavior.
Trademark "opencode" is the trademark of the opencode project. This fork is published under a distinct name (opencode-databricks) to avoid confusion.

Syncing with upstream

To pull newer changes from the official opencode project into this fork:

git remote add upstream https://github.com/anomalyco/opencode.git   # one-time
git fetch upstream
git checkout dev
git merge upstream/dev                                               # resolve conflicts if any
git push origin dev

Most conflicts concentrate in packages/opencode/src/provider/provider.ts, packages/opencode/src/provider/transform.ts, and the session/LLM files — the areas this fork modifies.

What's different from upstream

Source changes are kept small and auditable. Significant files touched:

  • packages/opencode/src/provider/provider.ts — adds the databricks custom loader and registers @databricks/ai-sdk-provider as a bundled provider
  • packages/opencode/src/provider/transform.ts — Databricks-specific tool schema fixes, reasoning effort mapping, itemId truncation, cache-control routing
  • packages/opencode/src/provider/databricks-profile.ts — helpers for parsing ~/.databrickscfg and picking an auth flow
  • packages/opencode/src/auth/auth.ts — adds the databricks-profile auth variant to the Auth.Info schema
  • packages/opencode/src/cli/cmd/tui/component/dialog-provider.tsx — adds the Databricks profile / host / OAuth / PAT login flow
  • packages/opencode/src/cli/cmd/tui/routes/session/sidebar.tsx — shows Databricks connection status in the session sidebar
  • packages/opencode/src/session/llm.ts — tool-call remapping middleware for Databricks Responses API
  • packages/opencode/src/session/processor.ts — override "other" finish reason to "tool-calls" when Databricks FMAPI returns it

Run git log dev ^anomalyco/dev --no-merges on this repo to see every non-merge delta from upstream.

Contributing

  • Databricks-specific improvements (provider, auth, model routing, known-issue workarounds): PRs welcome on this fork.
  • General opencode improvements (TUI, tooling, session management, other providers): submit those to upstream opencode — not here.

Before opening a PR, run:

bun install
bun turbo typecheck
cd packages/opencode && bun test --timeout 30000

License

This fork is distributed under the same MIT License as upstream opencode. See LICENSE for the full text. The MIT license from the upstream project explicitly permits modification, redistribution, and sublicensing, provided the original copyright notice is preserved — which it is.

  • Upstream copyright: Copyright (c) 2025 opencode (unchanged)
  • Modifications in this fork: Copyright (c) 2026 David O'Keeffe

The MIT license does not grant trademark rights. "opencode" is the trademark of its project maintainers; this fork is rebranded as opencode-databricks to make the distinction explicit.

Acknowledgments

All credit for the underlying agent, TUI, session engine, tool system, and plugin architecture belongs to the opencode team and its contributors. This fork is a thin Databricks-specific layer on top of their work.

Upstream README

The original upstream README is preserved at README.upstream.md for reference.