Unofficial. Not affiliated with Codebuff or Freebuff. This plugin uses the Freebuff free mode you already have, through the official
freebuffCLI.
Freebuff free mode only works through its official CLI, desktop app, or website.
This plugin respects that: it never calls Freebuff's chat API directly. Model
discovery reads Freebuff's own catalog, and every prompt is typed into the
installed freebuff CLI itself.
What you get is a normal OpenCode provider named freebuff, so the models show
up in /models next to your other providers:
freebuff/deepseek-v4-1-flash
freebuff/solar-mini-4
freebuff/glyph-cluster
At startup the OpenCode plugin:
- starts a small OpenAI-compatible bridge on
127.0.0.1(random free port), - registers a
freebuffprovider with a random per-process local API key, - adds the Freebuff catalog to
/modelsasfreebuff/<model>.
flowchart LR
A[OpenCode] -->|/v1/chat/completions| B[Local bridge<br/>127.0.0.1 · random port]
B -->|private PTY| C[Official freebuff CLI]
C --> D[Freebuff free mode]
B -->|/v1/models| E[Freebuff catalog<br/>read-only]
A real CLI session is opened only when a request contains an actual user prompt. Model listing, health checks, capability probes, compaction, title generation and transient generates never start the CLI, because Freebuff sessions are limited. For a real prompt the bridge briefly opens the CLI in a private PTY, temporarily selects the requested model in the CLI settings, and then restores the previous settings. Requests are serialized, so the bridge never races itself.
The plugin tags real turns with their OpenCode session ID. The first prompt in
a session creates a Freebuff chat; later prompts in that same OpenCode session
resume the chat with freebuff --continue, so the model keeps its own context
there. The session-to-chat mapping is stored outside the repo in the CLI config
directory (.freebuff-opencode-sessions.json), so it also survives an OpenCode
service restart. A new OpenCode session starts a new Freebuff chat.
While the CLI works, the bridge streams its own transcript back to OpenCode:
reasoning_contentcarries the model's thinking and a line for every tool or command it runs, so OpenCode shows what is happening;contentcarries the user-facing answer as it is written, so it is clear exactly when the model starts formulating the reply.
No credentials, tokens, or device keys are stored in this repository. The bridge
reads them from the official Freebuff CLI config, so freebuff login remains
the only sign-in step.
| Requirement | Details |
|---|---|
| OpenCode | 2.x |
| Freebuff CLI | installed and signed in |
| Node.js | 20 or newer |
| Python | 3.x, standard library only |
Check your sign-in:
freebuff doctorIf needed, sign in first:
freebuff loginClone the plugin somewhere stable:
git clone https://github.com/SimonStnn/freebuff-opencode-plugin.git \
~/.local/share/freebuff-opencode-pluginRegister it in your global OpenCode config (~/.config/opencode/opencode.jsonc)
so the models are available in every session, from any directory:
OpenCode does not expand ~ in this list, so paste an absolute path. Print the
one for your clone:
echo "$HOME/.local/share/freebuff-opencode-plugin/.opencode/plugins/freebuff"The entry must end in .opencode/plugins/freebuff.
Start OpenCode and open /models:
opencodeSelect any freebuff/... model. Follow-up messages in that OpenCode session
continue the same Freebuff chat, just like a native session. To check
registration without opening the TUI:
opencode models | grep '^freebuff/'To send one test prompt:
opencode run --model freebuff/solar-mini-4 "Reply with exactly: OK"Use --standalone if you want a separate OpenCode process instead of the
background service:
opencode models --standalone | grep '^freebuff/'
opencode run --standalone --model freebuff/solar-mini-4 "Reply with exactly: OK"A snapshot of the catalog is checked in, so /models is never empty; it is
refreshed from the live catalog in the background. A few examples:
| Model ID | Name | Context | Notes |
|---|---|---|---|
deepseek-v4-1-flash |
DeepSeek V4.1 Flash | 1M | default in opencode.jsonc |
deepseek-v4-1-flash-fast |
DeepSeek V4.1 Flash Fast | 1M | multimodal |
grok-5 |
Grok 5 | 2M | multimodal |
qwen4-max |
Qwen4 Max | 1M | multimodal |
gpt-6-2 |
GPT-6.2 | 400K | multimodal |
solar-mini-4 |
Solar Mini 4 | 500K | |
glyph-cluster |
Glyph Cluster | 256K | |
claude-opus-5-5-early-access |
Claude Opus 5.5 | 400K | early access |
The full, live list comes from your account. With the standalone bridge running
(npm start, see below), query it directly:
curl http://127.0.0.1:8787/v1/models -H 'Authorization: Bearer freebuff-local'The plugin starts the bridge automatically. For debugging, or to point another OpenAI-compatible client at Freebuff, run it yourself:
npm startIt listens on http://127.0.0.1:8787/v1 with API key freebuff-local:
curl http://127.0.0.1:8787/health
curl http://127.0.0.1:8787/v1/chat/completions \
-H 'Authorization: Bearer freebuff-local' \
-H 'Content-Type: application/json' \
-d '{"model":"solar-mini-4","stream":false,"messages":[{"role":"user","content":"Reply with exactly: OK"}]}'Standalone clients can opt into session continuity by sending a stable
x-freebuff-session header. Requests marked x-freebuff-kind: title,
compaction or generate are rejected without opening the CLI.
| Variable | Purpose |
|---|---|
FREEBUFF_API_BASE |
Override the Freebuff API origin for catalog reads (default https://www.codebuff.com). FREEBUFF_HOST is accepted as an alias. |
FREEBUFF_CONFIG_DIR |
Override the official CLI config directory. |
FREEBUFF_AUTH_TOKEN |
Use an auth token from the environment for catalog reads instead of the CLI credentials file. |
FREEBUFF_CLI |
Path to the official freebuff executable. |
FREEBUFF_CLI_CWD |
Directory passed to the CLI. Defaults to this repo (small and fast to index). |
FREEBUFF_CLI_TIMEOUT_MS |
Maximum wait for one CLI answer (default 180000). |
FREEBUFF_NO_ATTRIBUTION |
Default 1: strip Codebuff/AI attribution from CLI prompts and commits. Set to 0 to allow the official CLI's Co-Authored-By footer. |
FREEBUFF_PYTHON |
Python 3 executable used for the PTY helper. |
FREEBUFF_CLI_DEBUG=1 |
Print helper diagnostics to stderr. |
PORT, HOST, FREEBUFF_BRIDGE_KEY |
Standalone bridge listen address and API key. |
npm ci # install the TypeScript toolchain
npm test # unit tests (node:test via tsx)
npm run check # typecheck with tsc --noEmit
npm start # run the standalone bridge via tsxThe project has no runtime dependencies, only dev dependencies for TypeScript.
The official CLI indexes its working directory on launch, which is why
FREEBUFF_CLI_CWD defaults to this small repo.
.opencode/plugins/freebuff/index.ts OpenCode V2 plugin: bridge lifecycle + model registration
scripts/freebuff-cli.py PTY helper that drives the official CLI and reads its transcript
src/cli.ts Node wrapper around the official-CLI helper
src/bridge.ts OpenAI-compatible HTTP endpoints
src/freebuff.ts Read-only Freebuff catalog client
src/models.ts Catalog snapshot used as a fallback list
src/util.ts Prompt/SSE conversion helpers
src/types.ts Shared TypeScript types
tsconfig.json Strict TypeScript configuration
opencode.jsonc Default OpenCode model
test/bridge.test.ts Unit tests
.github/workflows/ci.yml CI: typecheck, tests, package smoke test
.github/workflows/release.yml Tag-triggered GitHub Release
Releases are cut from tags named exactly vx.x.x, and the version has to match
package.json:
npm version 1.1.0 --no-git-tag-version # or edit the version by hand
git commit -am "Bump version to 1.1.0"
git tag -a v1.1.0 -m "v1.1.0" # annotated, so --follow-tags picks it up
git push origin main --follow-tagsThe release title is just the tag, for example v1.1.0. Pushing the tag runs
release.yml: it typechecks, re-runs the tests, packs the tarball and publishes
a GitHub Release with notes generated from the merged pull requests, categorised
by the labels in .github/release.yml.
| Symptom | Fix |
|---|---|
Freebuff is not signed in |
Run freebuff login, then freebuff doctor. |
Invalid API key in the catalog log |
Sign in again with freebuff login; the bridge reads the CLI's credentials from disk. |
No freebuff/... models in /models |
Check the plugin path in opencode.jsonc; it must be the absolute path ending in .opencode/plugins/freebuff. |
| Chat times out | Raise FREEBUFF_CLI_TIMEOUT_MS. First launches of the CLI are slow. |
| CLI helper fails to start | Ensure python3 is on PATH, or set FREEBUFF_PYTHON. |
| Answers take minutes | Point FREEBUFF_CLI_CWD at a small directory; the CLI indexes its cwd on launch. |
| Model missing from the list | Refresh the snapshot in src/models.ts, or let the bridge fetch the live catalog. |
- OpenCode tool calls are not forwarded: the official CLI owns its own tool runtime, so the bridge is text in, text out. Commands that the CLI itself runs are visible as activity in the reasoning stream, but OpenCode cannot control them.
- Thinking is read from the CLI's transcript. Models that do not write reasoning blocks simply produce no reasoning stream; the answer is unaffected.
- Model availability and plans are controlled by Freebuff and can change at any time; the checked-in snapshot is a convenience, not a contract.
- The bridge binds to loopback only. Do not expose it publicly.
- AI attribution is disabled by default:
AGENTS.mdtells the CLI not to add footers, andFREEBUFF_NO_ATTRIBUTION=1adds the same instruction to every request. SetFREEBUFF_NO_ATTRIBUTION=0if you want the CLI's normal footer.
MIT © Simon Stijnen
{ "plugins": [ "/home/YOUR_USER/.local/share/freebuff-opencode-plugin/.opencode/plugins/freebuff" ] }