@khalilgharbaoui/opencode-claude-code-plugin 0.8.2 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -5
- package/dist/index.d.ts +32 -0
- package/dist/index.js +797 -147
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# @khalilgharbaoui/opencode-claude-code-plugin
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@khalilgharbaoui/opencode-claude-code-plugin)
|
|
4
|
+
|
|
3
5
|
An [opencode](https://opencode.ai) plugin that wraps the **Claude Code CLI** (`claude`) and routes model traffic through it instead of the Anthropic HTTP API. You get to use opencode's UI, agents, MCP, and permission system while authenticating and billing through whichever method `claude` is logged into (Pro/Max plan, Bedrock, Vertex, or API key).
|
|
4
6
|
|
|
5
7
|
> Maintained fork of [`unixfox/opencode-claude-code-plugin`](https://github.com/unixfox/opencode-claude-code-plugin). Published as `@khalilgharbaoui/opencode-claude-code-plugin` on npm.
|
|
@@ -101,16 +103,21 @@ This plugin drives Claude Code headlessly (`claude --print`), which Anthropic bi
|
|
|
101
103
|
| Pro | $20 |
|
|
102
104
|
| Max 5x | $100 |
|
|
103
105
|
| Max 20x | $200 |
|
|
104
|
-
| Team Standard | $20
|
|
105
|
-
| Team Premium | $100
|
|
106
|
-
| Enterprise (
|
|
106
|
+
| Team (Standard seats) | $20 |
|
|
107
|
+
| Team (Premium seats) | $100 |
|
|
108
|
+
| Enterprise (usage-based) | $20 |
|
|
109
|
+
| Enterprise (seat-based Premium seats) | $200 |
|
|
110
|
+
|
|
111
|
+
Credits are **per user, not pooled** across a team, and Standard seats on seat-based Enterprise plans aren't eligible. See Anthropic's [Agent SDK credit article](https://support.claude.com/en/articles/15036540-use-the-claude-agent-sdk-with-your-claude-plan) for the authoritative table.
|
|
107
112
|
|
|
108
113
|
What this means for plugin users:
|
|
109
114
|
|
|
110
|
-
- **Claim the credit once.** It's a one-time opt-in via your Claude account
|
|
115
|
+
- **Claim the credit once.** It's a one-time opt-in via your Claude account; eligible users get an email with claim instructions before June 15, 2026. After that it refreshes every billing cycle, and unused credit does not roll over.
|
|
116
|
+
- **Agent SDK usage drains the credit first**, before any other source.
|
|
111
117
|
- **When the credit runs out, plugin requests stop** until the next billing cycle — unless you enable usage credits in your Claude account, in which case overflow is billed at standard API rates.
|
|
112
118
|
- **The credit is denominated in dollars at standard API rates**, so the Price × column above maps directly to how fast each model drains it — Fable 5 / Mythos 5 burn it 10× faster than Haiku, 2× faster than Opus 4.8.
|
|
113
119
|
- **API-key auth is unaffected.** If your `claude` CLI authenticates with an Anthropic API key / Console billing instead of a subscription, nothing changes — pay-as-you-go as before.
|
|
120
|
+
- **Watch for a stray `ANTHROPIC_API_KEY`.** If that variable (or `ANTHROPIC_AUTH_TOKEN`) is present in your environment, Claude Code uses it and bills pay-as-you-go — silently bypassing the subscription credit even when `claude` is logged into a plan. The plugin logs a one-time warning when it detects a key. To force subscription auth, set `ignoreAnthropicApiKey: true`, which strips the key from the `claude` spawn environment.
|
|
114
121
|
- **Interactive Claude Code in your terminal is unaffected.** The change targets programmatic usage only: the Agent SDK, `claude -p`, Claude Code GitHub Actions, and third-party apps like this plugin.
|
|
115
122
|
|
|
116
123
|
Two related dates:
|
|
@@ -209,6 +216,11 @@ The account model IDs are internally suffixed, for example `claude-sonnet-4-6@wo
|
|
|
209
216
|
| `multiStepContinuation` | boolean | `true` | Append a system-prompt hint nudging Claude to chain tool calls within one turn instead of pausing between subtasks. Each opencode turn boundary requires the user to manually press "continue", so for multi-step tasks this reduces friction. Set `false` to disable. |
|
|
210
217
|
| `autoContinueIncompleteTurns` | boolean \| `"smart"` | `"smart"` | Smartly continue incomplete Claude CLI results inside the same opencode turn. Reduces manual "continue" presses when Claude ends after reasoning/tool activity without a useful final answer. Set `false` to disable. |
|
|
211
218
|
| `compactionModel` | string | `"claude-haiku-4-5"` | Model used when opencode invokes `/compact`. Override per-process via the `CLAUDE_CODE_COMPACTION_MODEL` env var (env wins over config). See [Compaction](#compaction). |
|
|
219
|
+
| `ignoreAnthropicApiKey` | boolean | `false` | Strip `ANTHROPIC_API_KEY` / `ANTHROPIC_AUTH_TOKEN` from every spawned `claude` process so it authenticates with your logged-in subscription instead of pay-as-you-go API billing. The plugin warns once at startup whenever an API key is detected, regardless of this setting. See [Billing](#billing-change-june-15-2026-agent-sdk-credit). |
|
|
220
|
+
| `interactive` | boolean | `false` | **Experimental.** Drive the interactive `claude` TUI (subscription billing) instead of headless `--print`. Requires opencode running under Bun with PTY support; silently falls back to headless otherwise. Env: `CLAUDE_CODE_INTERACTIVE_TRANSPORT=1`. See [Interactive transport](#interactive-transport-experimental). |
|
|
221
|
+
| `interactiveBypass` | boolean | `false` | Deprecated/no-op with `interactive`: Claude Code's TUI shows a manual safety confirmation for `bypassPermissions`, so the plugin intentionally does not pass it. |
|
|
222
|
+
| `interactiveAllowTools` | string[] | `["Bash", "Edit", "Write", "Read", "WebFetch"]` | With `interactive`: built-in tools pre-allowed without prompting (replaces the default list). MCP server wildcards (`mcp__<server>__*`) are always added from the bridged config. |
|
|
223
|
+
| `interactiveSystemPrompt` | boolean | `true` | With `interactive`: append this plugin's CLI/AGENTS/continuation prompt via `--append-system-prompt-file`. The transport intentionally does not forward opencode's own system prompt, because it can trigger Claude Code's third-party-app usage gate on subscription accounts. Set `false` only for diagnostics. |
|
|
212
224
|
|
|
213
225
|
### Overriding model metadata
|
|
214
226
|
|
|
@@ -234,6 +246,39 @@ Anything you supply is merged on top of the defaults; you don't need to redeclar
|
|
|
234
246
|
|
|
235
247
|
---
|
|
236
248
|
|
|
249
|
+
## Interactive transport (experimental)
|
|
250
|
+
|
|
251
|
+
By default the plugin spawns `claude --print` (headless). From **June 15, 2026** that usage bills against the separate [Agent SDK credit](#billing-change-june-15-2026-agent-sdk-credit) on subscription plans. The interactive transport instead drives the real interactive `claude` TUI — which bills as **normal plan usage** — under a native PTY inside opencode's Bun runtime, types your prompt into it, and streams the session transcript (`~/.claude/projects/<cwd>/<session-id>.jsonl`) back through the same pipeline the headless transport uses.
|
|
252
|
+
|
|
253
|
+
```json
|
|
254
|
+
"options": { "interactive": true }
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
Or per-process: `CLAUDE_CODE_INTERACTIVE_TRANSPORT=1`.
|
|
258
|
+
|
|
259
|
+
### Requirements
|
|
260
|
+
|
|
261
|
+
- opencode must be running under **Bun** with `Bun.Terminal` (PTY) support. If it isn't, the flag is ignored and the headless transport is used — nothing breaks.
|
|
262
|
+
- A logged-in `claude` (subscription auth). The whole point is plan billing, so API-key auth gains nothing here.
|
|
263
|
+
|
|
264
|
+
### What carries over from the headless transport
|
|
265
|
+
|
|
266
|
+
- The plugin's appended prompt (Claude CLI context, AGENTS.md guidance, continuation rules). The interactive transport intentionally does not forward opencode's own system prompt, because live testing showed that payload can trigger Claude Code's third-party-app usage gate on subscription accounts.
|
|
267
|
+
- The MCP bridge: bridged servers are passed via `--mcp-config` + `--strict-mcp-config`, and every bridged server is pre-allowed as `mcp__<server>__*`.
|
|
268
|
+
- Model selection, session reuse, and the whole streaming/usage pipeline.
|
|
269
|
+
|
|
270
|
+
Set `interactiveSystemPrompt: false` only for diagnostics. While disabled, the interactive session will not receive the plugin's CLI context, AGENTS.md guidance, or continuation hints.
|
|
271
|
+
|
|
272
|
+
### What's different
|
|
273
|
+
|
|
274
|
+
- **Permissions:** the interactive TUI has no `can_use_tool` control channel, so tools can't be approved per-call through opencode. Built-in tools are pre-allowed via a settings allow list (default `Bash, Edit, Write, Read, WebFetch`; override with `interactiveAllowTools`). `bypassPermissions` is intentionally not used here because Claude Code shows a manual safety confirmation in the TUI and defaults to exit.
|
|
275
|
+
- **Input is text-only:** images and other non-text blocks are dropped (with a logged warning); tool results are rendered as labeled text.
|
|
276
|
+
- **Output granularity:** text arrives per transcript record, not token-by-token, so it can feel chunkier than headless streaming.
|
|
277
|
+
- **Turn timeout:** a turn that produces no terminal stop within 30 minutes is reported honestly as an error result (visible truncation), not silently ended.
|
|
278
|
+
- `/compact` always uses the headless transport regardless of this setting.
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
237
282
|
## Selective tool proxy
|
|
238
283
|
|
|
239
284
|
This is the core feature.
|
|
@@ -500,7 +545,7 @@ Partial support since v0.5.1. DCP runs in a useful degraded mode: automatic stra
|
|
|
500
545
|
| DCP feature | Status | Notes |
|
|
501
546
|
|---|---|---|
|
|
502
547
|
| `experimental.chat.messages.transform` (compression placeholders, dedup, error purge) | ✅ Works | Transforms run inside opencode before reaching this plugin. |
|
|
503
|
-
| `experimental.chat.system.transform` (context-limit nudges, iteration reminders) | ✅ Works |
|
|
548
|
+
| `experimental.chat.system.transform` (context-limit nudges, iteration reminders) | ✅ Works in headless | Headless spawns forward system-role content via `--append-system-prompt-file`. Interactive mode intentionally omits opencode's forwarded system prompt and keeps only this plugin's CLI/AGENTS/continuation prompt. |
|
|
504
549
|
| `/dcp compress`, `/dcp sweep`, `/dcp manual`, `/dcp context`, `/dcp stats` slash commands | ✅ Works | Handled by opencode's `command.execute.before` hook, not the model. |
|
|
505
550
|
| Automatic `deduplication` + `purgeErrors` strategies | ✅ Works | Message-transform only, no model tool calls. |
|
|
506
551
|
| Autonomous model-driven `compress` tool calls | ❌ Not supported | DCP registers `compress` as an opencode-native tool. Claude CLI only sees its own built-ins and MCP-bridged servers, so the model never sees `compress`. The plugin prepends a runtime note instructing Claude to ignore any system instruction that asks it to call `compress`/`distill`/`prune`. |
|
package/dist/index.d.ts
CHANGED
|
@@ -138,6 +138,16 @@ type LogMode = "silent" | "debug";
|
|
|
138
138
|
interface ClaudeCodeConfig {
|
|
139
139
|
provider: string;
|
|
140
140
|
cliPath: string;
|
|
141
|
+
/** Drive interactive claude (subscription) instead of headless --print. */
|
|
142
|
+
interactive?: boolean;
|
|
143
|
+
/** Deprecated/no-op with interactive: Claude Code's TUI requires manual confirmation for bypassPermissions. */
|
|
144
|
+
interactiveBypass?: boolean;
|
|
145
|
+
/** With interactive: built-in tools to allow without prompting (replaces
|
|
146
|
+
* the default Bash/Edit/Write/Read/WebFetch list; MCP wildcards are always
|
|
147
|
+
* derived from the bridged config). */
|
|
148
|
+
interactiveAllowTools?: string[];
|
|
149
|
+
/** With interactive: append this plugin's own prompts via --append-system-prompt-file. Defaults to true. */
|
|
150
|
+
interactiveSystemPrompt?: boolean;
|
|
141
151
|
cwd?: string;
|
|
142
152
|
account?: string;
|
|
143
153
|
configDir?: string;
|
|
@@ -157,6 +167,7 @@ interface ClaudeCodeConfig {
|
|
|
157
167
|
multiStepContinuation?: boolean;
|
|
158
168
|
autoContinueIncompleteTurns?: boolean | "smart";
|
|
159
169
|
compactionModel?: string;
|
|
170
|
+
ignoreAnthropicApiKey?: boolean;
|
|
160
171
|
logging?: LoggingConfig;
|
|
161
172
|
}
|
|
162
173
|
interface LoggingConfig {
|
|
@@ -190,6 +201,16 @@ interface LoggingConfig {
|
|
|
190
201
|
type WebSearchRouting = "claude" | "disabled" | (string & {});
|
|
191
202
|
interface ClaudeCodeProviderSettings {
|
|
192
203
|
cliPath?: string;
|
|
204
|
+
/** Drive interactive claude (subscription) instead of headless --print. */
|
|
205
|
+
interactive?: boolean;
|
|
206
|
+
/** Deprecated/no-op with interactive: Claude Code's TUI requires manual confirmation for bypassPermissions. */
|
|
207
|
+
interactiveBypass?: boolean;
|
|
208
|
+
/** With interactive: built-in tools to allow without prompting (replaces
|
|
209
|
+
* the default Bash/Edit/Write/Read/WebFetch list; MCP wildcards are always
|
|
210
|
+
* derived from the bridged config). */
|
|
211
|
+
interactiveAllowTools?: string[];
|
|
212
|
+
/** With interactive: append this plugin's own prompts via --append-system-prompt-file. Defaults to true. */
|
|
213
|
+
interactiveSystemPrompt?: boolean;
|
|
193
214
|
cwd?: string;
|
|
194
215
|
name?: string;
|
|
195
216
|
providerID?: string;
|
|
@@ -247,6 +268,17 @@ interface ClaudeCodeProviderSettings {
|
|
|
247
268
|
* (see opencode's agent docs).
|
|
248
269
|
*/
|
|
249
270
|
proxyTools?: string[];
|
|
271
|
+
/**
|
|
272
|
+
* Strip `ANTHROPIC_API_KEY` / `ANTHROPIC_AUTH_TOKEN` from the environment of
|
|
273
|
+
* every spawned `claude` process. When an API key is present, Claude Code
|
|
274
|
+
* authenticates with it (pay-as-you-go Console billing) instead of the
|
|
275
|
+
* logged-in Pro/Max subscription — silently bypassing the Agent SDK plan
|
|
276
|
+
* credit. Set this to `true` to force the CLI to fall back to its stored
|
|
277
|
+
* subscription auth. Defaults to `false` (the key is passed through, so
|
|
278
|
+
* deliberate API-key users are unaffected). Regardless of this setting, the
|
|
279
|
+
* plugin logs a one-time warning at startup when an API key is detected.
|
|
280
|
+
*/
|
|
281
|
+
ignoreAnthropicApiKey?: boolean;
|
|
250
282
|
/**
|
|
251
283
|
* Routing for Claude's built-in `WebSearch` tool.
|
|
252
284
|
*
|